Skip to content

Introduce ModernIdent type to unify macro 2.0 hygiene handling - #144439

Merged
bors merged 1 commit into
rust-lang:masterfrom
xizheyin:symbol-rs
Aug 7, 2025
Merged

bors merged 1 commit into
rust-lang:masterfrom
xizheyin:symbol-rs

Conversation

@xizheyin

Copy link
Copy Markdown
Member

This pr introduce ModernIdent type to unify macro 2.0 hygiene handling

  1. Added ModernIdent type. Wraps Ident and automatically calls normalize_to_macros_2_0()
  2. Unified identifier normalization. Replaced scattered ident.normalize_to_macros_2_0() calls with ModernIdent::new(ident)

r? @petrochenkov

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2025
@rustbot

rustbot commented Jul 25, 2025

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 25, 2025
@fee1-dead

Copy link
Copy Markdown
Member

What problem is this intended to solve? ModernIdent seems like a quite confusing name.

Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment thread compiler/rustc_resolve/src/macros.rs Resolved
Comment thread compiler/rustc_resolve/src/lib.rs Resolved
Comment thread compiler/rustc_resolve/src/lib.rs Resolved
Comment thread compiler/rustc_resolve/src/late.rs Resolved
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2025
Comment thread compiler/rustc_span/src/symbol.rs Resolved
@petrochenkov

Copy link
Copy Markdown
Contributor

In general, I have mixed feelings about both this and MacroRulesNormalizedIdent.
It clearly can potentially catch some mistakes or inefficiencies (like it did in fn define_macro, I think), on the other hand it can only be used opportunistically because most places either do not care about the normalization, or care but the normalization should be different in different cases (like in rib.bindings, I guess).

@xizheyin xizheyin left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this version, I removed some unnecessary uses.
The modifications are mainly centered around two fields.

  1. BindingKey::ident
  2. Resolver::extern_prelude

Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment thread compiler/rustc_resolve/src/lib.rs Resolved
Comment thread compiler/rustc_resolve/src/lib.rs Resolved
Comment thread compiler/rustc_resolve/src/lib.rs Resolved
@bors

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@xizheyin

ghost commented Aug 4, 2025

Copy link
Copy Markdown
Member Author

I rebased it @rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 4, 2025
Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment thread compiler/rustc_resolve/src/lib.rs Resolved
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 5, 2025
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>

ghost left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's getting clearer.

@rustbot ready

Comment thread compiler/rustc_resolve/src/imports.rs Resolved
Comment thread compiler/rustc_resolve/src/imports.rs Resolved
Comment thread compiler/rustc_span/src/symbol.rs Resolved
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 6, 2025
@petrochenkov

ghost commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

@bors r+

@bors

ghost commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 6e7b9d5 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 6, 2025
@bors
bors merged commit c97e64a into rust-lang:master Aug 7, 2025
@rustbot rustbot added this to the 1.91.0 milestone Aug 7, 2025
@Zalathar

ghost commented Aug 8, 2025

Copy link
Copy Markdown
Member

@rust-timer build b5d3bba

@rust-timer

This comment has been minimized.

@xizheyin
xizheyin deleted the symbol-rs branch August 8, 2025 03:18
@rust-timer

ghost commented Aug 8, 2025

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b5d3bba): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.1% [2.4%, 3.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.2%, -3.1%] 2
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.1%, secondary -1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [1.8%, 2.4%] 2
Regressions ❌
(secondary)
3.2% [2.3%, 4.4%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-5.2%, -2.5%] 6
All ❌✅ (primary) 2.1% [1.8%, 2.4%] 2

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 465.283s -> 464.187s (-0.24%)
Artifact size: 377.41 MiB -> 377.33 MiB (-0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants