diff options
| author | bors <bors@rust-lang.org> | 2024-11-27 04:54:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-27 04:54:08 +0000 |
| commit | 83965efe6ad57a2baf3b5d5678d094bf9cd936dd (patch) | |
| tree | 3b4dd763282381ba82a65d5db14fb3db54c36c53 /compiler/rustc_resolve/src | |
| parent | 48696f5bd64f58e1a3d98ccb2a801e079ddef30b (diff) | |
| parent | 993e084eb1eb8bc29eae0620bbbb2c3009cec6dd (diff) | |
| download | rust-83965efe6ad57a2baf3b5d5678d094bf9cd936dd.tar.gz rust-83965efe6ad57a2baf3b5d5678d094bf9cd936dd.zip | |
Auto merge of #133274 - ehuss:macro_rules-edition-from-pm, r=compiler-errors
Use edition of `macro_rules` when compiling the macro This changes the edition assigned to a macro_rules macro when it is compiled to use the edition of where the macro came from instead of the local crate's edition. This fixes a problem when a macro_rules macro is created by a proc-macro. Previously that macro would be tagged with the local edition, which would cause problems with using the correct edition behavior inside the macro. For example, the check for unsafe attributes would cause errors in 2024 when using proc-macros from older editions. This is partially related to https://github.com/rust-lang/rust/issues/132906. Unfortunately this is only a half fix for that issue. It fixes the error that happens in 2024, but does not fix the lint firing in 2021. I'm still trying to think of some way to fix that, but I'm running low on ideas.
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/def_collector.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index bf27b767a49..7536869e2fe 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -191,7 +191,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { ItemKind::Const(..) => DefKind::Const, ItemKind::Fn(..) | ItemKind::Delegation(..) => DefKind::Fn, ItemKind::MacroDef(def) => { - let edition = self.resolver.tcx.sess.edition(); + let edition = i.span.edition(); let macro_data = self.resolver.compile_macro(def, i.ident, &i.attrs, i.span, i.id, edition); let macro_kind = macro_data.ext.macro_kind(); |
