Do not consider built-in attributes as candidates when resolving non-attribute macro invocations
This is needed to avoid regressions on stable channel
This commit is contained in:
parent
d2f56378da
commit
e7ee6fb2a2
@ -669,7 +669,10 @@ enum WhereToResolve<'a> {
|
||||
}
|
||||
}
|
||||
WhereToResolve::BuiltinAttrs => {
|
||||
if is_builtin_attr_name(ident.name) {
|
||||
// FIXME: Only built-in attributes are not considered as candidates for
|
||||
// non-attributes to fight off regressions on stable channel (#53205).
|
||||
// We need to come up with some more principled approach instead.
|
||||
if is_attr && is_builtin_attr_name(ident.name) {
|
||||
let binding = (Def::NonMacroAttr(NonMacroAttrKind::Builtin),
|
||||
ty::Visibility::Public, ident.span, Mark::root())
|
||||
.to_name_binding(self.arenas);
|
||||
|
@ -10,5 +10,5 @@
|
||||
|
||||
fn main() {
|
||||
concat!(test!());
|
||||
//~^ ERROR expected a macro, found built-in attribute
|
||||
//~^ ERROR cannot find macro `test!` in this scope
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: expected a macro, found built-in attribute
|
||||
error: cannot find macro `test!` in this scope
|
||||
--> $DIR/issue-11692-2.rs:12:13
|
||||
|
|
||||
LL | concat!(test!());
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
#[derive(inline)] //~ ERROR expected a macro, found built-in attribute
|
||||
#[derive(inline)] //~ ERROR cannot find derive macro `inline` in this scope
|
||||
struct S;
|
||||
|
||||
fn main() {
|
||||
inline!(); //~ ERROR expected a macro, found built-in attribute
|
||||
inline!(); //~ ERROR cannot find macro `inline!` in this scope
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
error: expected a macro, found built-in attribute
|
||||
error: cannot find derive macro `inline` in this scope
|
||||
--> $DIR/macro-path-prelude-fail-3.rs:13:10
|
||||
|
|
||||
LL | #[derive(inline)] //~ ERROR expected a macro, found built-in attribute
|
||||
LL | #[derive(inline)] //~ ERROR cannot find derive macro `inline` in this scope
|
||||
| ^^^^^^
|
||||
|
||||
error: expected a macro, found built-in attribute
|
||||
error: cannot find macro `inline!` in this scope
|
||||
--> $DIR/macro-path-prelude-fail-3.rs:17:5
|
||||
|
|
||||
LL | inline!(); //~ ERROR expected a macro, found built-in attribute
|
||||
| ^^^^^^
|
||||
LL | inline!(); //~ ERROR cannot find macro `inline!` in this scope
|
||||
| ^^^^^^ help: you could try the macro: `line`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -21,7 +21,9 @@ macro_rules! add_macro_expanded_things_to_macro_prelude {() => {
|
||||
|
||||
mod m1 {
|
||||
fn check() {
|
||||
inline!(); //~ ERROR `inline` is ambiguous
|
||||
inline!(); // OK. Theoretically ambiguous, but we do not consider built-in attributes
|
||||
// as candidates for non-attribute macro invocations to avoid regressions
|
||||
// on stable channel
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,42 +1,21 @@
|
||||
error[E0659]: `inline` is ambiguous
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:24:9
|
||||
|
|
||||
LL | inline!(); //~ ERROR `inline` is ambiguous
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `inline` could refer to the name imported here
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:16:5
|
||||
|
|
||||
LL | #[macro_use]
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | add_macro_expanded_things_to_macro_prelude!();
|
||||
| ---------------------------------------------- in this macro invocation
|
||||
note: `inline` could also refer to the name defined here
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:24:9
|
||||
|
|
||||
LL | inline!(); //~ ERROR `inline` is ambiguous
|
||||
| ^^^^^^
|
||||
= note: macro-expanded macro imports do not shadow
|
||||
|
||||
error[E0659]: `std` is ambiguous
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:37:9
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:39:9
|
||||
|
|
||||
LL | std::panic!(); //~ ERROR `std` is ambiguous
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: `std` could refer to the name imported here
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:35:9
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:37:9
|
||||
|
|
||||
LL | use m2::*; // glob-import user-defined `std`
|
||||
| ^^^^^
|
||||
note: `std` could also refer to the name defined here
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:37:9
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:39:9
|
||||
|
|
||||
LL | std::panic!(); //~ ERROR `std` is ambiguous
|
||||
| ^^^
|
||||
= note: consider adding an explicit import of `std` to disambiguate
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
Loading…
Reference in New Issue
Block a user