resolve: Block expansion of a derive container until all its derives are resolved
Also mark derive helpers as known as a part of the derive container's expansion instead of expansion of the derives themselves which may happen too late.
This commit is contained in:
parent
9b91b9c10e
commit
ec45b87957
15 changed files with 206 additions and 164 deletions
|
|
@ -1,15 +1,3 @@
|
|||
error: cannot find derive macro `Send` in this scope
|
||||
--> $DIR/deriving-bounds.rs:1:10
|
||||
|
|
||||
LL | #[derive(Send)]
|
||||
| ^^^^
|
||||
|
|
||||
note: unsafe traits like `Send` should be implemented explicitly
|
||||
--> $DIR/deriving-bounds.rs:1:10
|
||||
|
|
||||
LL | #[derive(Send)]
|
||||
| ^^^^
|
||||
|
||||
error: cannot find derive macro `Sync` in this scope
|
||||
--> $DIR/deriving-bounds.rs:5:10
|
||||
|
|
||||
|
|
@ -22,5 +10,17 @@ note: unsafe traits like `Sync` should be implemented explicitly
|
|||
LL | #[derive(Sync)]
|
||||
| ^^^^
|
||||
|
||||
error: cannot find derive macro `Send` in this scope
|
||||
--> $DIR/deriving-bounds.rs:1:10
|
||||
|
|
||||
LL | #[derive(Send)]
|
||||
| ^^^^
|
||||
|
|
||||
note: unsafe traits like `Send` should be implemented explicitly
|
||||
--> $DIR/deriving-bounds.rs:1:10
|
||||
|
|
||||
LL | #[derive(Send)]
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: cannot find derive macro `x3300` in this scope
|
||||
--> $DIR/issue-43106-gating-of-derive-2.rs:4:14
|
||||
--> $DIR/issue-43106-gating-of-derive-2.rs:12:14
|
||||
|
|
||||
LL | #[derive(x3300)]
|
||||
| ^^^^^
|
||||
|
|
@ -11,7 +11,7 @@ LL | #[derive(x3300)]
|
|||
| ^^^^^
|
||||
|
||||
error: cannot find derive macro `x3300` in this scope
|
||||
--> $DIR/issue-43106-gating-of-derive-2.rs:12:14
|
||||
--> $DIR/issue-43106-gating-of-derive-2.rs:4:14
|
||||
|
|
||||
LL | #[derive(x3300)]
|
||||
| ^^^^^
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
// `#![derive]` raises errors when it occurs at contexts other than ADT
|
||||
// definitions.
|
||||
|
||||
#![derive(Debug)]
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
|
||||
#[derive(Debug)]
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
mod derive {
|
||||
|
|
|
|||
|
|
@ -1,38 +1,32 @@
|
|||
error: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:4:1
|
||||
|
|
||||
LL | #![derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug)]`
|
||||
|
||||
error: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:7:1
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:10:17
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:7:17
|
||||
|
|
||||
LL | mod inner { #![derive(Debug)] }
|
||||
| ^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug)]`
|
||||
|
||||
error: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:13:5
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:10:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:26:5
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:23:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:30:5
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:27:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions
|
||||
//~| ERROR cannot determine resolution for the derive macro `Copy`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,13 @@ error: `derive` may only be applied to structs, enums and unions
|
|||
LL | #![derive(Copy)]
|
||||
| ^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Copy)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: cannot determine resolution for the derive macro `Copy`
|
||||
--> $DIR/issue-36617.rs:1:11
|
||||
|
|
||||
LL | #![derive(Copy)]
|
||||
| ^^^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
18
src/test/ui/proc-macro/derive-helper-configured.rs
Normal file
18
src/test/ui/proc-macro/derive-helper-configured.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Derive helpers are resolved successfully inside `cfg_attr`.
|
||||
|
||||
// check-pass
|
||||
// compile-flats:--cfg TRUE
|
||||
// aux-build:test-macros.rs
|
||||
|
||||
#[macro_use]
|
||||
extern crate test_macros;
|
||||
|
||||
#[cfg_attr(TRUE, empty_helper)]
|
||||
#[derive(Empty)]
|
||||
#[cfg_attr(TRUE, empty_helper)]
|
||||
struct S {
|
||||
#[cfg_attr(TRUE, empty_helper)]
|
||||
field: u8,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -19,7 +19,8 @@ struct S {
|
|||
struct U;
|
||||
|
||||
mod inner {
|
||||
#[empty_helper] //~ ERROR cannot find attribute macro `empty_helper` in this scope
|
||||
// FIXME No ambiguity, attributes in non-macro positions are not resolved properly
|
||||
#[empty_helper]
|
||||
struct V;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
error: cannot find attribute macro `empty_helper` in this scope
|
||||
--> $DIR/derive-helper-shadowing.rs:22:15
|
||||
|
|
||||
LL | #[empty_helper]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/derive-helper-shadowing.rs:8:3
|
||||
|
|
||||
|
|
@ -22,6 +16,6 @@ LL | use test_macros::empty_attr as empty_helper;
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
|
|||
|
|
@ -1,50 +1,8 @@
|
|||
error: cannot find derive macro `FooWithLongNan` in this scope
|
||||
--> $DIR/resolve-error.rs:22:10
|
||||
error: cannot find macro `bang_proc_macrp!` in this scope
|
||||
--> $DIR/resolve-error.rs:56:5
|
||||
|
|
||||
LL | #[derive(FooWithLongNan)]
|
||||
| ^^^^^^^^^^^^^^ help: a derive macro with a similar name exists: `FooWithLongName`
|
||||
|
||||
error: cannot find attribute macro `attr_proc_macra` in this scope
|
||||
--> $DIR/resolve-error.rs:27:3
|
||||
|
|
||||
LL | #[attr_proc_macra]
|
||||
| ^^^^^^^^^^^^^^^ help: an attribute macro with a similar name exists: `attr_proc_macro`
|
||||
|
||||
error: cannot find attribute macro `FooWithLongNan` in this scope
|
||||
--> $DIR/resolve-error.rs:31:3
|
||||
|
|
||||
LL | #[FooWithLongNan]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find derive macro `Dlone` in this scope
|
||||
--> $DIR/resolve-error.rs:34:10
|
||||
|
|
||||
LL | #[derive(Dlone)]
|
||||
| ^^^^^ help: a derive macro with a similar name exists: `Clone`
|
||||
|
||||
error: cannot find derive macro `Dlona` in this scope
|
||||
--> $DIR/resolve-error.rs:38:10
|
||||
|
|
||||
LL | #[derive(Dlona)]
|
||||
| ^^^^^ help: a derive macro with a similar name exists: `Clona`
|
||||
|
||||
error: cannot find derive macro `attr_proc_macra` in this scope
|
||||
--> $DIR/resolve-error.rs:42:10
|
||||
|
|
||||
LL | #[derive(attr_proc_macra)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find macro `FooWithLongNama!` in this scope
|
||||
--> $DIR/resolve-error.rs:47:5
|
||||
|
|
||||
LL | FooWithLongNama!();
|
||||
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam`
|
||||
|
||||
error: cannot find macro `attr_proc_macra!` in this scope
|
||||
--> $DIR/resolve-error.rs:50:5
|
||||
|
|
||||
LL | attr_proc_macra!();
|
||||
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac`
|
||||
LL | bang_proc_macrp!();
|
||||
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `bang_proc_macro`
|
||||
|
||||
error: cannot find macro `Dlona!` in this scope
|
||||
--> $DIR/resolve-error.rs:53:5
|
||||
|
|
@ -52,11 +10,53 @@ error: cannot find macro `Dlona!` in this scope
|
|||
LL | Dlona!();
|
||||
| ^^^^^
|
||||
|
||||
error: cannot find macro `bang_proc_macrp!` in this scope
|
||||
--> $DIR/resolve-error.rs:56:5
|
||||
error: cannot find macro `attr_proc_macra!` in this scope
|
||||
--> $DIR/resolve-error.rs:50:5
|
||||
|
|
||||
LL | bang_proc_macrp!();
|
||||
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `bang_proc_macro`
|
||||
LL | attr_proc_macra!();
|
||||
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac`
|
||||
|
||||
error: cannot find macro `FooWithLongNama!` in this scope
|
||||
--> $DIR/resolve-error.rs:47:5
|
||||
|
|
||||
LL | FooWithLongNama!();
|
||||
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam`
|
||||
|
||||
error: cannot find derive macro `attr_proc_macra` in this scope
|
||||
--> $DIR/resolve-error.rs:42:10
|
||||
|
|
||||
LL | #[derive(attr_proc_macra)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find derive macro `Dlona` in this scope
|
||||
--> $DIR/resolve-error.rs:38:10
|
||||
|
|
||||
LL | #[derive(Dlona)]
|
||||
| ^^^^^ help: a derive macro with a similar name exists: `Clona`
|
||||
|
||||
error: cannot find derive macro `Dlone` in this scope
|
||||
--> $DIR/resolve-error.rs:34:10
|
||||
|
|
||||
LL | #[derive(Dlone)]
|
||||
| ^^^^^ help: a derive macro with a similar name exists: `Clone`
|
||||
|
||||
error: cannot find attribute macro `FooWithLongNan` in this scope
|
||||
--> $DIR/resolve-error.rs:31:3
|
||||
|
|
||||
LL | #[FooWithLongNan]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find attribute macro `attr_proc_macra` in this scope
|
||||
--> $DIR/resolve-error.rs:27:3
|
||||
|
|
||||
LL | #[attr_proc_macra]
|
||||
| ^^^^^^^^^^^^^^^ help: an attribute macro with a similar name exists: `attr_proc_macro`
|
||||
|
||||
error: cannot find derive macro `FooWithLongNan` in this scope
|
||||
--> $DIR/resolve-error.rs:22:10
|
||||
|
|
||||
LL | #[derive(FooWithLongNan)]
|
||||
| ^^^^^^^^^^^^^^ help: a derive macro with a similar name exists: `FooWithLongName`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue