mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Use edition of macro_rules
when compiling the macro
This commit is contained in:
parent
a1838660c3
commit
993e084eb1
@ -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();
|
||||
|
@ -1,11 +0,0 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/macro_rules_edition_from_pm.rs:24:5
|
||||
|
|
||||
LL | assert!(edition_inner!(const {}) == 2024);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: edition_inner!(const {}) == 2024', $DIR/macro_rules_edition_from_pm.rs:24:5
|
||||
|
|
||||
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
@ -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!{}
|
||||
@ -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() {}
|
||||
|
@ -1,17 +0,0 @@
|
||||
error: unsafe attribute used without unsafe
|
||||
--> $DIR/unsafe-attributes-from-pm.rs:13:1
|
||||
|
|
||||
LL | unsafe_attributes_pm::macro_rules_missing_unsafe!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ usage of unsafe attribute
|
||||
...
|
||||
LL | make_fn!();
|
||||
| ---------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `make_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: wrap the attribute in `unsafe(...)`
|
||||
|
|
||||
LL | ununsafe(safe_attributes_pm::macro_rules_missing_unsafe!());
|
||||
| +++++++ +
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -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
|
||||
@ -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!();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user