Skip to content

Commit 993e084

Browse files
committedNov 21, 2024
Use edition of macro_rules when compiling the macro
1 parent a183866 commit 993e084

6 files changed

+4
-34
lines changed
 

‎compiler/rustc_resolve/src/def_collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
191191
ItemKind::Const(..) => DefKind::Const,
192192
ItemKind::Fn(..) | ItemKind::Delegation(..) => DefKind::Fn,
193193
ItemKind::MacroDef(def) => {
194-
let edition = self.resolver.tcx.sess.edition();
194+
let edition = i.span.edition();
195195
let macro_data =
196196
self.resolver.compile_macro(def, i.ident, &i.attrs, i.span, i.id, edition);
197197
let macro_kind = macro_data.ext.macro_kind();

‎tests/ui/proc-macro/macro_rules_edition_from_pm.edition2021.stderr

-11
This file was deleted.

‎tests/ui/proc-macro/macro_rules_edition_from_pm.edition2024.stderr

Whitespace-only changes.

‎tests/ui/proc-macro/macro_rules_edition_from_pm.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//@[edition2021] edition:2021
88
//@[edition2024] edition:2024
99
//@[edition2024] compile-flags: -Zunstable-options
10-
//@[edition2024] check-pass
10+
//@ check-pass
1111

1212
// This checks how the expr fragment specifier works.
1313
macro_rules_edition_pm::make_edition_macro!{}
@@ -21,8 +21,7 @@ macro_rules_edition_pm::make_nested_edition_macro!{}
2121
make_inner!{}
2222

2323
const _: () = {
24-
assert!(edition_inner!(const {}) == 2024);
25-
//[edition2021]~^ ERROR evaluation of constant value failed
24+
assert!(edition_inner!(const {}) == 2021);
2625
};
2726

2827
fn main() {}

‎tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm.edition2024.stderr

-17
This file was deleted.

‎tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// See https://github.com/rust-lang/rust/issues/132906
33

44
//@ revisions: edition2021 edition2024
5-
//@[edition2021] check-pass
5+
//@ check-pass
66
//@[edition2021] edition:2021
77
//@[edition2024] edition:2024
88
//@[edition2024] compile-flags: -Zunstable-options
@@ -11,7 +11,6 @@
1111
unsafe_attributes_pm::missing_unsafe!();
1212

1313
unsafe_attributes_pm::macro_rules_missing_unsafe!();
14-
//[edition2024]~^ ERROR unsafe attribute used without unsafe
1514

1615
make_fn!();
1716

0 commit comments

Comments
 (0)
Please sign in to comment.