Auto merge of #53471 - petrochenkov:biattr2, r=oli-obk

resolve: Some macro resolution refactoring

Work towards completing https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393

The last commit also fixes https://github.com/rust-lang/rust/issues/53269 by not using `def_id()` on `Def::Err` and also fixes https://github.com/rust-lang/rust/issues/53512.
This commit is contained in:
bors 2018-08-21 20:33:31 +00:00
commit d0d81b7fc1
25 changed files with 426 additions and 391 deletions

View file

@ -22,7 +22,7 @@ extern crate proc_macro_gates as foo;
use foo::*;
#[foo::a] //~ ERROR: paths of length greater than one
#[foo::a] //~ ERROR: non-ident attribute macro paths are unstable
fn _test() {}
fn _test_inner() {

View file

@ -2,37 +2,37 @@ error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:34:5
|
LL | my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it
| ^^^^^^^^^^^^
| ^^^^^^^^
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:37:5
|
LL | my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:40:5
|
LL | MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it
| ^^^^^^^^^^^
| ^^^^^^^
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:43:1
--> $DIR/macro-namespace-reserved-2.rs:43:3
|
LL | #[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it
| ^^^^^^^^^^^
| ^^^^^^^^
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:45:1
--> $DIR/macro-namespace-reserved-2.rs:45:3
|
LL | #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it
| ^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:47:1
--> $DIR/macro-namespace-reserved-2.rs:47:3
|
LL | #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it
| ^^^^^^^^^^
| ^^^^^^^
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:50:10

View file

@ -2,7 +2,7 @@ error[E0658]: The attribute `unknown` is currently unknown to the compiler and m
--> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:13:27
|
LL | #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown
| ^^^^^^^^
| ^^^^^^^
...
LL | foo!();
| ------- in this macro invocation

View file

@ -1,24 +1,24 @@
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/custom_attribute.rs:13:1
--> $DIR/custom_attribute.rs:13:3
|
LL | #[foo] //~ ERROR The attribute `foo`
| ^^^^^^
| ^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/custom_attribute.rs:15:5
--> $DIR/custom_attribute.rs:15:7
|
LL | #[foo] //~ ERROR The attribute `foo`
| ^^^^^^
| ^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/custom_attribute.rs:17:5
--> $DIR/custom_attribute.rs:17:7
|
LL | #[foo] //~ ERROR The attribute `foo`
| ^^^^^^
| ^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable

View file

@ -1,104 +1,104 @@
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:17:1
--> $DIR/feature-gate-custom_attribute.rs:17:3
|
LL | #[fake_attr] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:18:1
--> $DIR/feature-gate-custom_attribute.rs:18:3
|
LL | #[fake_attr(100)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:19:1
--> $DIR/feature-gate-custom_attribute.rs:19:3
|
LL | #[fake_attr(1, 2, 3)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:20:1
--> $DIR/feature-gate-custom_attribute.rs:20:3
|
LL | #[fake_attr("hello")] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:21:1
--> $DIR/feature-gate-custom_attribute.rs:21:3
|
LL | #[fake_attr(name = "hello")] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:22:1
--> $DIR/feature-gate-custom_attribute.rs:22:3
|
LL | #[fake_attr(1, "hi", key = 12, true, false)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:23:1
--> $DIR/feature-gate-custom_attribute.rs:23:3
|
LL | #[fake_attr(key = "hello", val = 10)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:24:1
--> $DIR/feature-gate-custom_attribute.rs:24:3
|
LL | #[fake_attr(key("hello"), val(10))] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:25:1
--> $DIR/feature-gate-custom_attribute.rs:25:3
|
LL | #[fake_attr(enabled = true, disabled = false)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:26:1
--> $DIR/feature-gate-custom_attribute.rs:26:3
|
LL | #[fake_attr(true)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:27:1
--> $DIR/feature-gate-custom_attribute.rs:27:3
|
LL | #[fake_attr(pi = 3.14159)] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:28:1
--> $DIR/feature-gate-custom_attribute.rs:28:3
|
LL | #[fake_attr(b"hi")] //~ ERROR attribute `fake_attr` is currently unknown
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:29:1
--> $DIR/feature-gate-custom_attribute.rs:29:3
|
LL | #[fake_doc(r"doc")] //~ ERROR attribute `fake_doc` is currently unknown
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable

View file

@ -1,8 +1,8 @@
error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644)
--> $DIR/feature-gate-custom_derive.rs:11:1
--> $DIR/feature-gate-custom_derive.rs:11:3
|
LL | #[derive_Clone]
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^
|
= help: add #![feature(custom_derive)] to the crate attributes to enable

View file

@ -1,8 +1,8 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
--> $DIR/feature-gate-rustc-attrs.rs:15:1
--> $DIR/feature-gate-rustc-attrs.rs:15:3
|
LL | #[rustc_foo]
| ^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(rustc_attrs)] to the crate attributes to enable

View file

@ -1,8 +1,8 @@
error[E0658]: tool attributes are unstable (see issue #44690)
--> $DIR/feature-gate-tool_attributes.rs:12:5
--> $DIR/feature-gate-tool_attributes.rs:12:7
|
LL | #[rustfmt::skip] //~ ERROR tool attributes are unstable
| ^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^
|
= help: add #![feature(tool_attributes)] to the crate attributes to enable

View file

@ -0,0 +1,21 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Ambiguity between a `macro_rules` macro and a non-existent import recovered as `Def::Err`
macro_rules! mac { () => () }
mod m {
use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
mac!(); //~ ERROR `mac` is ambiguous
}
fn main() {}

View file

@ -0,0 +1,27 @@
error[E0432]: unresolved import `nonexistent_module`
--> $DIR/issue-53269.rs:16:9
|
LL | use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
| ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate nonexistent_module;`?
error[E0659]: `mac` is ambiguous
--> $DIR/issue-53269.rs:18:5
|
LL | mac!(); //~ ERROR `mac` is ambiguous
| ^^^
|
note: `mac` could refer to the name defined here
--> $DIR/issue-53269.rs:13:1
|
LL | macro_rules! mac { () => () }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `mac` could also refer to the name imported here
--> $DIR/issue-53269.rs:16:9
|
LL | use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
| ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Some errors occurred: E0432, E0659.
For more information about an error, try `rustc --explain E0432`.

View file

@ -0,0 +1,17 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Macro from prelude is shadowed by non-existent import recovered as `Def::Err`.
use std::assert; //~ ERROR unresolved import `std::assert`
fn main() {
assert!(true);
}

View file

@ -0,0 +1,9 @@
error[E0432]: unresolved import `std::assert`
--> $DIR/issue-53512.rs:13:5
|
LL | use std::assert; //~ ERROR unresolved import `std::assert`
| ^^^^^^^^^^^ no `assert` in the root
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.

View file

@ -1,15 +1,15 @@
error: `m` is ambiguous
error[E0659]: `m` is ambiguous
--> $DIR/macros.rs:48:5
|
LL | m!(); //~ ERROR ambiguous
| ^
|
note: `m` could refer to the macro defined here
note: `m` could refer to the name defined here
--> $DIR/macros.rs:46:5
|
LL | macro_rules! m { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `m` could also refer to the macro imported here
note: `m` could also refer to the name imported here
--> $DIR/macros.rs:47:9
|
LL | use two_macros::m;

View file

@ -37,10 +37,10 @@ mod m4 {
mod m5 {
macro_rules! m { () => {
macro_rules! panic { () => {} } //~ ERROR `panic` is already in scope
macro_rules! panic { () => {} }
} }
m!();
panic!();
panic!(); //~ ERROR `panic` is ambiguous
}
#[macro_use(n)]

View file

@ -1,13 +1,19 @@
error: `panic` is already in scope
error[E0659]: `panic` is ambiguous
--> $DIR/shadow_builtin_macros.rs:43:5
|
LL | panic!(); //~ ERROR `panic` is ambiguous
| ^^^^^
|
note: `panic` could refer to the name defined here
--> $DIR/shadow_builtin_macros.rs:40:9
|
LL | macro_rules! panic { () => {} } //~ ERROR `panic` is already in scope
LL | macro_rules! panic { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | } }
LL | m!();
| ----- in this macro invocation
|
= note: macro-expanded `macro_rules!`s may not shadow existing macros (see RFC 1560)
= note: `panic` is also a builtin macro
= note: macro-expanded macros do not shadow
error[E0659]: `panic` is ambiguous
--> $DIR/shadow_builtin_macros.rs:25:14

View file

@ -1,8 +1,8 @@
error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644)
--> $DIR/issue-32655.rs:16:9
--> $DIR/issue-32655.rs:16:11
|
LL | #[derive_Clone] //~ ERROR attributes of the form
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^
...
LL | foo!();
| ------- in this macro invocation
@ -10,10 +10,10 @@ LL | foo!();
= help: add #![feature(custom_derive)] to the crate attributes to enable
error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644)
--> $DIR/issue-32655.rs:28:5
--> $DIR/issue-32655.rs:28:7
|
LL | #[derive_Clone] //~ ERROR attributes of the form
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^
|
= help: add #![feature(custom_derive)] to the crate attributes to enable

View file

@ -1,8 +1,8 @@
error[E0658]: The attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/issue-49074.rs:13:1
--> $DIR/issue-49074.rs:13:3
|
LL | #[marco_use] // typo
| ^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable

View file

@ -11,10 +11,10 @@ LL | #![feature(macro_reexport)] //~ ERROR feature has been removed
| ^^^^^^^^^^^^^^
error[E0658]: The attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/macro-reexport-removed.rs:15:1
--> $DIR/macro-reexport-removed.rs:15:3
|
LL | #[macro_reexport(macro_one)] //~ ERROR attribute `macro_reexport` is currently unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable

View file

@ -1,8 +1,8 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
--> $DIR/reserved-attr-on-macro.rs:11:1
--> $DIR/reserved-attr-on-macro.rs:11:3
|
LL | #[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(rustc_attrs)] to the crate attributes to enable

View file

@ -1,16 +1,16 @@
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/issue-36530.rs:11:1
--> $DIR/issue-36530.rs:11:3
|
LL | #[foo] //~ ERROR is currently unknown to the compiler
| ^^^^^^
| ^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/issue-36530.rs:13:5
--> $DIR/issue-36530.rs:13:8
|
LL | #![foo] //~ ERROR is currently unknown to the compiler
| ^^^^^^^
| ^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable