Skip to content

Introduce ModernIdent type to unify macro 2.0 hygiene handling #144439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2025

Conversation

xizheyin
Copy link
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
Copy link
Collaborator

rustbot commented Jul 25, 2025

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
Member

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

@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
@petrochenkov
Copy link
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).

Copy link
Member Author

@xizheyin xizheyin left a comment

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

@bors

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@xizheyin
Copy link
Member Author

xizheyin commented Aug 4, 2025

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
@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
Copy link
Member Author

@xizheyin xizheyin left a comment

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

@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
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 6, 2025

📌 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
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 7, 2025
Introduce ModernIdent type to unify macro 2.0 hygiene handling

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`
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 7, 2025
Introduce ModernIdent type to unify macro 2.0 hygiene handling

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``
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 7, 2025
Introduce ModernIdent type to unify macro 2.0 hygiene handling

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```
bors added a commit that referenced this pull request Aug 7, 2025
Rollup of 20 pull requests

Successful merges:

 - #137831 (Tweak auto trait errors)
 - #143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching)
 - #143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order)
 - #143808 (Port `#[should_panic]` to the new attribute parsing infrastructure )
 - #143906 (Miri: non-deterministic floating point operations in `foreign_items`)
 - #143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps)
 - #144133 (Stabilize const TypeId::of)
 - #144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling)
 - #144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - #144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - #144705 (compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled)
 - #144807 (Streamline config in bootstrap)
 - #144900 (Stabilize `unsigned_signed_diff` feature)
 - #144903 (Rename `begin_panic_handler` to `panic_handler`)
 - #144931 ([win][arm64ec] Fix msvc-wholearchive for Arm64EC)
 - #144974 (compiler-builtins subtree update)
 - #144997 (bump bootstrap compiler to 1.90 beta)
 - #145004 (Couple of minor cleanups)
 - #145009 (A couple small changes for rust-analyzer next-solver work)
 - #145014 (Revert "Preserve the .debug_gdb_scripts section")

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 7, 2025
Rollup of 19 pull requests

Successful merges:

 - #137831 (Tweak auto trait errors)
 - #138689 (add nvptx_target_feature)
 - #140267 (implement continue_ok and break_ok for ControlFlow)
 - #143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching)
 - #143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order)
 - #143808 (Port `#[should_panic]` to the new attribute parsing infrastructure )
 - #143906 (Miri: non-deterministic floating point operations in `foreign_items`)
 - #143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps)
 - #144133 (Stabilize const TypeId::of)
 - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - #144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling)
 - #144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - #144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`)
 - #144650 (Additional tce tests)
 - #144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - #144682 (Stabilize `strict_overflow_ops`)
 - #145026 (Update books)
 - #145033 (Reimplement `print_region` in `type_name.rs`.)
 - #145040 (rustc-dev-guide subtree update)

Failed merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c97e64a into rust-lang:master Aug 7, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 7, 2025
rust-timer added a commit that referenced this pull request Aug 7, 2025
Rollup merge of #144439 - xizheyin:symbol-rs, r=petrochenkov

Introduce ModernIdent type to unify macro 2.0 hygiene handling

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````
@Zalathar
Copy link
Contributor

Zalathar commented Aug 8, 2025

@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
Copy link
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%)

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 8, 2025
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#137831 (Tweak auto trait errors)
 - rust-lang/rust#138689 (add nvptx_target_feature)
 - rust-lang/rust#140267 (implement continue_ok and break_ok for ControlFlow)
 - rust-lang/rust#143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching)
 - rust-lang/rust#143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order)
 - rust-lang/rust#143808 (Port `#[should_panic]` to the new attribute parsing infrastructure )
 - rust-lang/rust#143906 (Miri: non-deterministic floating point operations in `foreign_items`)
 - rust-lang/rust#143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps)
 - rust-lang/rust#144133 (Stabilize const TypeId::of)
 - rust-lang/rust#144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - rust-lang/rust#144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling)
 - rust-lang/rust#144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - rust-lang/rust#144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`)
 - rust-lang/rust#144650 (Additional tce tests)
 - rust-lang/rust#144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - rust-lang/rust#144682 (Stabilize `strict_overflow_ops`)
 - rust-lang/rust#145026 (Update books)
 - rust-lang/rust#145033 (Reimplement `print_region` in `type_name.rs`.)
 - rust-lang/rust#145040 (rustc-dev-guide subtree update)

Failed merges:

 - rust-lang/rust#143857 (Port #[macro_export] to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Aug 11, 2025
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#137831 (Tweak auto trait errors)
 - rust-lang/rust#138689 (add nvptx_target_feature)
 - rust-lang/rust#140267 (implement continue_ok and break_ok for ControlFlow)
 - rust-lang/rust#143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching)
 - rust-lang/rust#143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order)
 - rust-lang/rust#143808 (Port `#[should_panic]` to the new attribute parsing infrastructure )
 - rust-lang/rust#143906 (Miri: non-deterministic floating point operations in `foreign_items`)
 - rust-lang/rust#143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps)
 - rust-lang/rust#144133 (Stabilize const TypeId::of)
 - rust-lang/rust#144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - rust-lang/rust#144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling)
 - rust-lang/rust#144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - rust-lang/rust#144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`)
 - rust-lang/rust#144650 (Additional tce tests)
 - rust-lang/rust#144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - rust-lang/rust#144682 (Stabilize `strict_overflow_ops`)
 - rust-lang/rust#145026 (Update books)
 - rust-lang/rust#145033 (Reimplement `print_region` in `type_name.rs`.)
 - rust-lang/rust#145040 (rustc-dev-guide subtree update)

Failed merges:

 - rust-lang/rust#143857 (Port #[macro_export] to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Aug 12, 2025
Rollup of 19 pull requests

Successful merges:

 - rust-lang#137831 (Tweak auto trait errors)
 - rust-lang#138689 (add nvptx_target_feature)
 - rust-lang#140267 (implement continue_ok and break_ok for ControlFlow)
 - rust-lang#143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching)
 - rust-lang#143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order)
 - rust-lang#143808 (Port `#[should_panic]` to the new attribute parsing infrastructure )
 - rust-lang#143906 (Miri: non-deterministic floating point operations in `foreign_items`)
 - rust-lang#143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps)
 - rust-lang#144133 (Stabilize const TypeId::of)
 - rust-lang#144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - rust-lang#144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling)
 - rust-lang#144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - rust-lang#144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`)
 - rust-lang#144650 (Additional tce tests)
 - rust-lang#144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - rust-lang#144682 (Stabilize `strict_overflow_ops`)
 - rust-lang#145026 (Update books)
 - rust-lang#145033 (Reimplement `print_region` in `type_name.rs`.)
 - rust-lang#145040 (rustc-dev-guide subtree update)

Failed merges:

 - rust-lang#143857 (Port #[macro_export] to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
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