Skip to content

Commit

Permalink
Use edition of macro_rules when compiling the macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Nov 21, 2024
1 parent a183866 commit 94c2a92
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 34 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 0 additions & 11 deletions tests/ui/proc-macro/macro_rules_edition_from_pm.edition2021.stderr

This file was deleted.

5 changes: 2 additions & 3 deletions tests/ui/proc-macro/macro_rules_edition_from_pm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//@[edition2021] edition:2021
//@[edition2024] edition:2024
//@[edition2024] compile-flags: -Zunstable-options
//@[edition2024] check-pass
//@ check-pass

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

const _: () = {
assert!(edition_inner!(const {}) == 2024);
//[edition2021]~^ ERROR evaluation of constant value failed
assert!(edition_inner!(const {}) == 2021);
};

fn main() {}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See https://github.com/rust-lang/rust/issues/132906

//@ revisions: edition2021 edition2024
//@[edition2021] check-pass
//@ check-pass
//@[edition2021] edition:2021
//@[edition2024] edition:2024
//@[edition2024] compile-flags: -Zunstable-options
Expand All @@ -11,7 +11,6 @@
unsafe_attributes_pm::missing_unsafe!();

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

make_fn!();

Expand Down

0 comments on commit 94c2a92

Please sign in to comment.