expand/resolve: Turn #[derive] into a regular macro attribute
This commit is contained in:
parent
ae00b62ceb
commit
dbdbd30bf2
58 changed files with 1499 additions and 1258 deletions
|
|
@ -96,8 +96,8 @@ pub struct Deprecation {
|
|||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Visibility {
|
||||
Public,
|
||||
/// For the most part items are private by default. The exceptions are associated items of
|
||||
|
|
@ -112,8 +112,8 @@ pub enum Visibility {
|
|||
},
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GenericArgs {
|
||||
/// <'a, 32, B: Copy, C = u32>
|
||||
AngleBracketed { args: Vec<GenericArg>, bindings: Vec<TypeBinding> },
|
||||
|
|
@ -121,8 +121,8 @@ pub enum GenericArgs {
|
|||
Parenthesized { inputs: Vec<Type>, output: Option<Type> },
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GenericArg {
|
||||
Lifetime(String),
|
||||
Type(Type),
|
||||
|
|
@ -144,8 +144,8 @@ pub struct TypeBinding {
|
|||
pub binding: TypeBindingKind,
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TypeBindingKind {
|
||||
Equality(Type),
|
||||
Constraint(Vec<GenericBound>),
|
||||
|
|
@ -154,8 +154,8 @@ pub enum TypeBindingKind {
|
|||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Id(pub String);
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ItemKind {
|
||||
Module,
|
||||
ExternCrate,
|
||||
|
|
@ -184,8 +184,8 @@ pub enum ItemKind {
|
|||
Keyword,
|
||||
}
|
||||
|
||||
#[serde(untagged)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub enum ItemEnum {
|
||||
ModuleItem(Module),
|
||||
ExternCrateItem {
|
||||
|
|
@ -264,17 +264,17 @@ pub struct Enum {
|
|||
pub impls: Vec<Id>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(tag = "variant_kind", content = "variant_inner")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub enum Variant {
|
||||
Plain,
|
||||
Tuple(Vec<Type>),
|
||||
Struct(Vec<Id>),
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum StructType {
|
||||
Plain,
|
||||
Tuple,
|
||||
|
|
@ -310,24 +310,24 @@ pub struct GenericParamDef {
|
|||
pub kind: GenericParamDefKind,
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GenericParamDefKind {
|
||||
Lifetime,
|
||||
Type { bounds: Vec<GenericBound>, default: Option<Type> },
|
||||
Const(Type),
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum WherePredicate {
|
||||
BoundPredicate { ty: Type, bounds: Vec<GenericBound> },
|
||||
RegionPredicate { lifetime: String, bounds: Vec<GenericBound> },
|
||||
EqPredicate { lhs: Type, rhs: Type },
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GenericBound {
|
||||
TraitBound {
|
||||
#[serde(rename = "trait")]
|
||||
|
|
@ -339,17 +339,17 @@ pub enum GenericBound {
|
|||
Outlives(String),
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TraitBoundModifier {
|
||||
None,
|
||||
Maybe,
|
||||
MaybeConst,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(tag = "kind", content = "inner")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub enum Type {
|
||||
/// Structs, enums, and traits
|
||||
ResolvedPath {
|
||||
|
|
@ -448,8 +448,8 @@ pub struct Impl {
|
|||
pub blanket_impl: Option<Type>,
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct Import {
|
||||
/// The full path being imported.
|
||||
pub span: String,
|
||||
|
|
@ -468,8 +468,8 @@ pub struct ProcMacro {
|
|||
pub helpers: Vec<String>,
|
||||
}
|
||||
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MacroKind {
|
||||
/// A bang macro `foo!()`.
|
||||
Bang,
|
||||
|
|
|
|||
|
|
@ -75,3 +75,8 @@ auto trait Freeze {}
|
|||
macro_rules! Copy {
|
||||
() => {};
|
||||
}
|
||||
#[macro_export]
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! derive {
|
||||
() => {};
|
||||
}
|
||||
|
|
|
|||
6
src/test/ui/derives/derive-deadlock.rs
Normal file
6
src/test/ui/derives/derive-deadlock.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
use std as derive;
|
||||
|
||||
#[derive(Default)] //~ ERROR cannot determine resolution for the attribute macro `derive`
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/derives/derive-deadlock.stderr
Normal file
10
src/test/ui/derives/derive-deadlock.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: cannot determine resolution for the attribute macro `derive`
|
||||
--> $DIR/derive-deadlock.rs:3:3
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
10
src/test/ui/derives/derive-multiple-with-packed.rs
Normal file
10
src/test/ui/derives/derive-multiple-with-packed.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// check-pass
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Debug)] // OK, even if `Copy` is in the different `#[derive]`
|
||||
#[repr(packed)]
|
||||
struct CacheRecordHeader {
|
||||
field: u64,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
#![deny(unused)]
|
||||
|
||||
#[derive()] //~ ERROR unused attribute
|
||||
#[derive()] // OK
|
||||
struct _Bar;
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
error: unused attribute
|
||||
--> $DIR/deriving-meta-empty-trait-list.rs:3:1
|
||||
|
|
||||
LL | #[derive()]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/deriving-meta-empty-trait-list.rs:1:9
|
||||
|
|
||||
LL | #![deny(unused)]
|
||||
| ^^^^^^
|
||||
= note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
#![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions
|
||||
//~| ERROR cannot determine resolution for the derive macro `Copy`
|
||||
#![derive(Copy)] //~ ERROR cannot determine resolution for the attribute macro `derive`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-36617.rs:1:1
|
||||
error: cannot determine resolution for the attribute macro `derive`
|
||||
--> $DIR/issue-36617.rs:1:4
|
||||
|
|
||||
LL | #![derive(Copy)]
|
||||
| ^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Copy)]`
|
||||
|
||||
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
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0774`.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
mod derive {
|
||||
mod inner { #![derive(Debug)] }
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
//~| ERROR inner macro attributes are unstable
|
||||
|
||||
#[derive(Debug)]
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
|
|
|
|||
|
|
@ -4,30 +4,40 @@ error[E0774]: `derive` may only be applied to structs, enums and unions
|
|||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0658]: inner macro attributes are unstable
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:7:20
|
||||
|
|
||||
LL | mod inner { #![derive(Debug)] }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
|
||||
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:7:17
|
||||
|
|
||||
LL | mod inner { #![derive(Debug)] }
|
||||
| ^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug)]`
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:10:5
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:11:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:23:5
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:24:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:27:5
|
||||
--> $DIR/issue-43106-gating-of-derive.rs:28:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0774`.
|
||||
Some errors have detailed explanations: E0658, E0774.
|
||||
For more information about an error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
fn foo<#[derive(Debug)] T>() {
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
fn foo<#[derive(Debug)] T>() { //~ ERROR expected non-macro attribute, found attribute macro
|
||||
match 0 {
|
||||
#[derive(Debug)]
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
#[derive(Debug)] //~ ERROR expected non-macro attribute, found attribute macro
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934-errors.rs:1:8
|
||||
error: expected non-macro attribute, found attribute macro `derive`
|
||||
--> $DIR/issue-49934-errors.rs:1:10
|
||||
|
|
||||
LL | fn foo<#[derive(Debug)] T>() {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^ not a non-macro attribute
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934-errors.rs:4:9
|
||||
error: expected non-macro attribute, found attribute macro `derive`
|
||||
--> $DIR/issue-49934-errors.rs:3:11
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^ not a non-macro attribute
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0774`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![warn(unused_attributes)] //~ NOTE the lint level is defined here
|
||||
|
||||
fn main() {
|
||||
// fold_stmt (Item)
|
||||
|
|
@ -10,26 +7,24 @@ fn main() {
|
|||
struct Foo;
|
||||
|
||||
// fold_stmt (Mac)
|
||||
#[derive(Debug)]
|
||||
//~^ WARN `#[derive]` does nothing on macro invocations
|
||||
//~| NOTE this may become a hard error in a future release
|
||||
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
|
||||
println!("Hello, world!");
|
||||
|
||||
// fold_stmt (Semi)
|
||||
#[derive(Debug)] //~ WARN unused attribute
|
||||
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
|
||||
"Hello, world!";
|
||||
|
||||
// fold_stmt (Local)
|
||||
#[derive(Debug)] //~ WARN unused attribute
|
||||
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
|
||||
let _ = "Hello, world!";
|
||||
|
||||
// visit_expr
|
||||
let _ = #[derive(Debug)] "Hello, world!";
|
||||
//~^ WARN unused attribute
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
|
||||
let _ = [
|
||||
// filter_map_expr
|
||||
#[derive(Debug)] //~ WARN unused attribute
|
||||
"Hello, world!"
|
||||
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
|
||||
"Hello, world!",
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,33 @@
|
|||
warning: `#[derive]` does nothing on macro invocations
|
||||
--> $DIR/issue-49934.rs:13:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this may become a hard error in a future release
|
||||
|
||||
warning: unused attribute
|
||||
--> $DIR/issue-49934.rs:19:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-49934.rs:4:9
|
||||
|
|
||||
LL | #![warn(unused_attributes)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused attribute
|
||||
--> $DIR/issue-49934.rs:23:5
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934.rs:10:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused attribute
|
||||
--> $DIR/issue-49934.rs:27:13
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934.rs:14:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934.rs:18:5
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934.rs:22:13
|
||||
|
|
||||
LL | let _ = #[derive(Debug)] "Hello, world!";
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused attribute
|
||||
--> $DIR/issue-49934.rs:32:9
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-49934.rs:27:9
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 5 warnings emitted
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0774`.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `core`
|
||||
--> $DIR/builtin-std-paths-fail.rs:2:11
|
||||
|
|
||||
LL | core::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `core`
|
||||
--> $DIR/builtin-std-paths-fail.rs:4:11
|
||||
|
|
||||
LL | core::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `bench` in `core`
|
||||
--> $DIR/builtin-std-paths-fail.rs:7:9
|
||||
|
|
||||
|
|
@ -22,18 +34,6 @@ error[E0433]: failed to resolve: could not find `test` in `core`
|
|||
LL | #[core::test]
|
||||
| ^^^^ could not find `test` in `core`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `core`
|
||||
--> $DIR/builtin-std-paths-fail.rs:2:11
|
||||
|
|
||||
LL | core::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `core`
|
||||
--> $DIR/builtin-std-paths-fail.rs:4:11
|
||||
|
|
||||
LL | core::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `core`
|
||||
--> $DIR/builtin-std-paths-fail.rs:4:11
|
||||
|
|
||||
|
|
@ -46,6 +46,18 @@ error[E0433]: failed to resolve: could not find `RustcDecodable` in `core`
|
|||
LL | core::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `std`
|
||||
--> $DIR/builtin-std-paths-fail.rs:14:10
|
||||
|
|
||||
LL | std::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `std`
|
||||
--> $DIR/builtin-std-paths-fail.rs:16:10
|
||||
|
|
||||
LL | std::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `bench` in `std`
|
||||
--> $DIR/builtin-std-paths-fail.rs:19:8
|
||||
|
|
||||
|
|
@ -70,18 +82,6 @@ error[E0433]: failed to resolve: could not find `test` in `std`
|
|||
LL | #[std::test]
|
||||
| ^^^^ could not find `test` in `std`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `std`
|
||||
--> $DIR/builtin-std-paths-fail.rs:14:10
|
||||
|
|
||||
LL | std::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `std`
|
||||
--> $DIR/builtin-std-paths-fail.rs:16:10
|
||||
|
|
||||
LL | std::RustcDecodable,
|
||||
| ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `RustcDecodable` in `std`
|
||||
--> $DIR/builtin-std-paths-fail.rs:16:10
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
fn main() {}
|
||||
|
||||
struct CLI {
|
||||
#[derive(parse())]
|
||||
//~^ ERROR traits in `#[derive(...)]` don't accept arguments
|
||||
//~| ERROR cannot find derive macro `parse` in this scope
|
||||
#[derive(parse())] //~ ERROR expected non-macro attribute, found attribute macro
|
||||
path: (),
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,8 @@
|
|||
error: traits in `#[derive(...)]` don't accept arguments
|
||||
--> $DIR/issue-69341-malformed-derive-inert.rs:4:19
|
||||
error: expected non-macro attribute, found attribute macro `derive`
|
||||
--> $DIR/issue-69341-malformed-derive-inert.rs:4:7
|
||||
|
|
||||
LL | #[derive(parse())]
|
||||
| ^^ help: remove the arguments
|
||||
| ^^^^^^ not a non-macro attribute
|
||||
|
||||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-69341-malformed-derive-inert.rs:7:5
|
||||
|
|
||||
LL | path: (),
|
||||
| ^^^^^^^^
|
||||
error: aborting due to previous error
|
||||
|
||||
error: cannot find derive macro `parse` in this scope
|
||||
--> $DIR/issue-69341-malformed-derive-inert.rs:4:14
|
||||
|
|
||||
LL | #[derive(parse())]
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0774`.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ error: malformed `derive` attribute input
|
|||
--> $DIR/malformed-derive-entry.rs:11:1
|
||||
|
|
||||
LL | #[derive]
|
||||
| ^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]`
|
||||
| ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
|
||||
|
||||
error[E0277]: the trait bound `Test1: Clone` is not satisfied
|
||||
--> $DIR/malformed-derive-entry.rs:1:10
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ error: malformed `derive` attribute input
|
|||
--> $DIR/malformed-special-attrs.rs:7:1
|
||||
|
|
||||
LL | #[derive]
|
||||
| ^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]`
|
||||
| ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
|
||||
|
||||
error: malformed `derive` attribute input
|
||||
--> $DIR/malformed-special-attrs.rs:10:1
|
||||
|
|
||||
LL | #[derive = ""]
|
||||
| ^^^^^^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]`
|
||||
| ^^^^^^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
28
src/test/ui/proc-macro/attribute-after-derive.rs
Normal file
28
src/test/ui/proc-macro/attribute-after-derive.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Macro attributes are allowed after `#[derive]` and
|
||||
// `#[derive]` fully configures the item for following attributes.
|
||||
|
||||
// check-pass
|
||||
// compile-flags: -Z span-debug
|
||||
// aux-build: test-macros.rs
|
||||
|
||||
#![no_std] // Don't load unnecessary hygiene information from std
|
||||
extern crate std;
|
||||
|
||||
#[macro_use]
|
||||
extern crate test_macros;
|
||||
|
||||
#[print_attr]
|
||||
#[derive(Print)]
|
||||
struct AttributeDerive {
|
||||
#[cfg(FALSE)]
|
||||
field: u8,
|
||||
}
|
||||
|
||||
#[derive(Print)]
|
||||
#[print_attr]
|
||||
struct DeriveAttribute {
|
||||
#[cfg(FALSE)]
|
||||
field: u8,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
148
src/test/ui/proc-macro/attribute-after-derive.stdout
Normal file
148
src/test/ui/proc-macro/attribute-after-derive.stdout
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
PRINT-ATTR INPUT (DISPLAY): #[derive(Print)] struct AttributeDerive { #[cfg(FALSE)] field : u8, }
|
||||
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/attribute-after-derive.rs:15:1: 15:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "derive",
|
||||
span: $DIR/attribute-after-derive.rs:15:3: 15:9 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Parenthesis,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "Print",
|
||||
span: $DIR/attribute-after-derive.rs:15:10: 15:15 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/attribute-after-derive.rs:15:9: 15:16 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/attribute-after-derive.rs:15:2: 15:17 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "struct",
|
||||
span: $DIR/attribute-after-derive.rs:16:1: 16:7 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "AttributeDerive",
|
||||
span: $DIR/attribute-after-derive.rs:16:8: 16:23 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Brace,
|
||||
stream: TokenStream [
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/attribute-after-derive.rs:17:5: 17:6 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "cfg",
|
||||
span: $DIR/attribute-after-derive.rs:17:7: 17:10 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Parenthesis,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "FALSE",
|
||||
span: $DIR/attribute-after-derive.rs:17:11: 17:16 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/attribute-after-derive.rs:17:10: 17:17 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/attribute-after-derive.rs:17:6: 17:18 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "field",
|
||||
span: $DIR/attribute-after-derive.rs:18:5: 18:10 (#0),
|
||||
},
|
||||
Punct {
|
||||
ch: ':',
|
||||
spacing: Alone,
|
||||
span: $DIR/attribute-after-derive.rs:18:10: 18:11 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "u8",
|
||||
span: $DIR/attribute-after-derive.rs:18:12: 18:14 (#0),
|
||||
},
|
||||
Punct {
|
||||
ch: ',',
|
||||
spacing: Alone,
|
||||
span: $DIR/attribute-after-derive.rs:18:14: 18:15 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/attribute-after-derive.rs:16:24: 19:2 (#0),
|
||||
},
|
||||
]
|
||||
PRINT-DERIVE INPUT (DISPLAY): struct AttributeDerive { }
|
||||
PRINT-DERIVE INPUT (DEBUG): TokenStream [
|
||||
Ident {
|
||||
ident: "struct",
|
||||
span: $DIR/attribute-after-derive.rs:16:1: 19:2 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "AttributeDerive",
|
||||
span: $DIR/attribute-after-derive.rs:16:1: 19:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Brace,
|
||||
stream: TokenStream [],
|
||||
span: $DIR/attribute-after-derive.rs:16:1: 19:2 (#0),
|
||||
},
|
||||
]
|
||||
PRINT-ATTR INPUT (DISPLAY): struct DeriveAttribute { }
|
||||
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||
Ident {
|
||||
ident: "struct",
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "DeriveAttribute",
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Brace,
|
||||
stream: TokenStream [],
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
]
|
||||
PRINT-DERIVE INPUT (DISPLAY): #[print_attr] struct DeriveAttribute { }
|
||||
PRINT-DERIVE INPUT (DEBUG): TokenStream [
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "print_attr",
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "struct",
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "DeriveAttribute",
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Brace,
|
||||
stream: TokenStream [],
|
||||
span: $DIR/attribute-after-derive.rs:23:1: 26:2 (#0),
|
||||
},
|
||||
]
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// aux-build:test-macros.rs
|
||||
|
||||
#[macro_use]
|
||||
extern crate test_macros;
|
||||
|
||||
#[identity_attr] // OK
|
||||
#[derive(Clone)]
|
||||
struct Before;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[identity_attr] //~ ERROR macro attributes must be placed before `#[derive]`
|
||||
struct After;
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
error: macro attributes must be placed before `#[derive]`
|
||||
--> $DIR/attribute-order-restricted.rs:11:1
|
||||
|
|
||||
LL | #[identity_attr]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -17,6 +17,8 @@ macro_rules! gen_helper_use {
|
|||
}
|
||||
|
||||
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
|
||||
//~| WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[derive(Empty)]
|
||||
struct S {
|
||||
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
error: cannot use a derive helper attribute through an import
|
||||
--> $DIR/derive-helper-shadowing.rs:40:15
|
||||
--> $DIR/derive-helper-shadowing.rs:42:15
|
||||
|
|
||||
LL | #[renamed]
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: the derive helper attribute imported here
|
||||
--> $DIR/derive-helper-shadowing.rs:39:17
|
||||
--> $DIR/derive-helper-shadowing.rs:41:17
|
||||
|
|
||||
LL | use empty_helper as renamed;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find attribute `empty_helper` in this scope
|
||||
--> $DIR/derive-helper-shadowing.rs:36:22
|
||||
--> $DIR/derive-helper-shadowing.rs:38:22
|
||||
|
|
||||
LL | #[derive(GenHelperUse)]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -30,13 +30,13 @@ LL | gen_helper_use!();
|
|||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0659]: `empty_helper` is ambiguous (name vs any other name during import resolution)
|
||||
--> $DIR/derive-helper-shadowing.rs:24:13
|
||||
--> $DIR/derive-helper-shadowing.rs:26:13
|
||||
|
|
||||
LL | use empty_helper;
|
||||
| ^^^^^^^^^^^^ ambiguous name
|
||||
|
|
||||
note: `empty_helper` could refer to the derive helper attribute defined here
|
||||
--> $DIR/derive-helper-shadowing.rs:20:10
|
||||
--> $DIR/derive-helper-shadowing.rs:22:10
|
||||
|
|
||||
LL | #[derive(Empty)]
|
||||
| ^^^^^
|
||||
|
|
@ -54,7 +54,7 @@ LL | #[empty_helper]
|
|||
| ^^^^^^^^^^^^ ambiguous name
|
||||
|
|
||||
note: `empty_helper` could refer to the derive helper attribute defined here
|
||||
--> $DIR/derive-helper-shadowing.rs:20:10
|
||||
--> $DIR/derive-helper-shadowing.rs:22:10
|
||||
|
|
||||
LL | #[derive(Empty)]
|
||||
| ^^^^^
|
||||
|
|
@ -65,6 +65,19 @@ 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 5 previous errors
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/derive-helper-shadowing.rs:19:3
|
||||
|
|
||||
LL | #[empty_helper]
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | #[derive(Empty)]
|
||||
| ----- the attribute is introduced here
|
||||
|
|
||||
= note: `#[warn(legacy_derive_helpers)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
error: aborting due to 5 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
|
|||
12
src/test/ui/proc-macro/derive-helper-vs-legacy.rs
Normal file
12
src/test/ui/proc-macro/derive-helper-vs-legacy.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// check-pass
|
||||
// aux-build:test-macros.rs
|
||||
|
||||
#[macro_use]
|
||||
extern crate test_macros;
|
||||
|
||||
#[derive(Empty)]
|
||||
#[empty_helper] // OK, this is both derive helper and legacy derive helper
|
||||
#[derive(Empty)]
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
11
src/test/ui/proc-macro/derive-multiple-with-packed.rs
Normal file
11
src/test/ui/proc-macro/derive-multiple-with-packed.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// check-pass
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Debug)] // OK, even if `Copy` is in the different `#[derive]`
|
||||
#[derive(PartialEq)] // OK too
|
||||
#[repr(packed)]
|
||||
struct CacheRecordHeader {
|
||||
field: u64,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -4,8 +4,10 @@
|
|||
extern crate test_macros;
|
||||
use test_macros::empty_attr as empty_helper;
|
||||
|
||||
#[derive(Empty)]
|
||||
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
|
||||
//~| WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[derive(Empty)]
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:8:3
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3
|
||||
|
|
||||
LL | #[empty_helper]
|
||||
| ^^^^^^^^^^^^ ambiguous name
|
||||
|
|
||||
note: `empty_helper` could refer to the derive helper attribute defined here
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:10
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:10:10
|
||||
|
|
||||
LL | #[derive(Empty)]
|
||||
| ^^^^^
|
||||
|
|
@ -16,6 +16,19 @@ 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 previous error
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3
|
||||
|
|
||||
LL | #[empty_helper]
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | #[derive(Empty)]
|
||||
| ----- the attribute is introduced here
|
||||
|
|
||||
= note: `#[warn(legacy_derive_helpers)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
#[macro_use]
|
||||
extern crate test_macros;
|
||||
|
||||
#[print_helper(a)]
|
||||
#[print_helper(a)] //~ WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[cfg_attr(not(FALSE), allow(dead_code))]
|
||||
#[print_attr]
|
||||
#[derive(Print)]
|
||||
|
|
|
|||
15
src/test/ui/proc-macro/issue-75930-derive-cfg.stderr
Normal file
15
src/test/ui/proc-macro/issue-75930-derive-cfg.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/issue-75930-derive-cfg.rs:16:3
|
||||
|
|
||||
LL | #[print_helper(a)]
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | #[derive(Print)]
|
||||
| ----- the attribute is introduced here
|
||||
|
|
||||
= note: `#[warn(legacy_derive_helpers)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -4,10 +4,18 @@
|
|||
extern crate derive_b;
|
||||
|
||||
#[B] //~ ERROR `B` is ambiguous
|
||||
//~| WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[C] //~ ERROR cannot find attribute `C` in this scope
|
||||
#[B(D)] //~ ERROR `B` is ambiguous
|
||||
//~| WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[B(E = "foo")] //~ ERROR `B` is ambiguous
|
||||
//~| WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
|
||||
//~| WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[derive(B)]
|
||||
struct B;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: cannot find attribute `C` in this scope
|
||||
--> $DIR/proc-macro-attributes.rs:7:3
|
||||
--> $DIR/proc-macro-attributes.rs:9:3
|
||||
|
|
||||
LL | #[C]
|
||||
| ^ help: a derive helper attribute with a similar name exists: `B`
|
||||
|
|
@ -11,41 +11,7 @@ LL | #[B]
|
|||
| ^ ambiguous name
|
||||
|
|
||||
note: `B` could refer to the derive helper attribute defined here
|
||||
--> $DIR/proc-macro-attributes.rs:11:10
|
||||
|
|
||||
LL | #[derive(B)]
|
||||
| ^
|
||||
note: `B` could also refer to the derive macro imported here
|
||||
--> $DIR/proc-macro-attributes.rs:3:1
|
||||
|
|
||||
LL | #[macro_use]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0659]: `B` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/proc-macro-attributes.rs:8:3
|
||||
|
|
||||
LL | #[B(D)]
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `B` could refer to the derive helper attribute defined here
|
||||
--> $DIR/proc-macro-attributes.rs:11:10
|
||||
|
|
||||
LL | #[derive(B)]
|
||||
| ^
|
||||
note: `B` could also refer to the derive macro imported here
|
||||
--> $DIR/proc-macro-attributes.rs:3:1
|
||||
|
|
||||
LL | #[macro_use]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0659]: `B` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/proc-macro-attributes.rs:9:3
|
||||
|
|
||||
LL | #[B(E = "foo")]
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `B` could refer to the derive helper attribute defined here
|
||||
--> $DIR/proc-macro-attributes.rs:11:10
|
||||
--> $DIR/proc-macro-attributes.rs:19:10
|
||||
|
|
||||
LL | #[derive(B)]
|
||||
| ^
|
||||
|
|
@ -58,11 +24,11 @@ LL | #[macro_use]
|
|||
error[E0659]: `B` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/proc-macro-attributes.rs:10:3
|
||||
|
|
||||
LL | #[B(arbitrary tokens)]
|
||||
LL | #[B(D)]
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `B` could refer to the derive helper attribute defined here
|
||||
--> $DIR/proc-macro-attributes.rs:11:10
|
||||
--> $DIR/proc-macro-attributes.rs:19:10
|
||||
|
|
||||
LL | #[derive(B)]
|
||||
| ^
|
||||
|
|
@ -72,6 +38,89 @@ note: `B` could also refer to the derive macro imported here
|
|||
LL | #[macro_use]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error[E0659]: `B` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/proc-macro-attributes.rs:13:3
|
||||
|
|
||||
LL | #[B(E = "foo")]
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `B` could refer to the derive helper attribute defined here
|
||||
--> $DIR/proc-macro-attributes.rs:19:10
|
||||
|
|
||||
LL | #[derive(B)]
|
||||
| ^
|
||||
note: `B` could also refer to the derive macro imported here
|
||||
--> $DIR/proc-macro-attributes.rs:3:1
|
||||
|
|
||||
LL | #[macro_use]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0659]: `B` is ambiguous (derive helper attribute vs any other name)
|
||||
--> $DIR/proc-macro-attributes.rs:16:3
|
||||
|
|
||||
LL | #[B(arbitrary tokens)]
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `B` could refer to the derive helper attribute defined here
|
||||
--> $DIR/proc-macro-attributes.rs:19:10
|
||||
|
|
||||
LL | #[derive(B)]
|
||||
| ^
|
||||
note: `B` could also refer to the derive macro imported here
|
||||
--> $DIR/proc-macro-attributes.rs:3:1
|
||||
|
|
||||
LL | #[macro_use]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/proc-macro-attributes.rs:6:3
|
||||
|
|
||||
LL | #[B]
|
||||
| ^
|
||||
...
|
||||
LL | #[derive(B)]
|
||||
| - the attribute is introduced here
|
||||
|
|
||||
= note: `#[warn(legacy_derive_helpers)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/proc-macro-attributes.rs:10:3
|
||||
|
|
||||
LL | #[B(D)]
|
||||
| ^
|
||||
...
|
||||
LL | #[derive(B)]
|
||||
| - the attribute is introduced here
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/proc-macro-attributes.rs:13:3
|
||||
|
|
||||
LL | #[B(E = "foo")]
|
||||
| ^
|
||||
...
|
||||
LL | #[derive(B)]
|
||||
| - the attribute is introduced here
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
--> $DIR/proc-macro-attributes.rs:16:3
|
||||
|
|
||||
LL | #[B(arbitrary tokens)]
|
||||
| ^
|
||||
...
|
||||
LL | #[derive(B)]
|
||||
| - the attribute is introduced here
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
error: aborting due to 5 previous errors; 4 warnings emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
|
|||
|
|
@ -17,9 +17,3 @@ pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream {
|
|||
//~^ ERROR name `cfg_attr` is reserved in attribute namespace
|
||||
input
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||
//~^ ERROR name `derive` is reserved in attribute namespace
|
||||
input
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,5 @@ error: name `cfg_attr` is reserved in attribute namespace
|
|||
LL | pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: name `derive` is reserved in attribute namespace
|
||||
--> $DIR/reserved-macro-names.rs:22:8
|
||||
|
|
||||
LL | pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
#![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
|
||||
//~^ ERROR `derive` may only be applied to structs, enums and unions
|
||||
//~| ERROR cannot determine resolution for the derive macro `Debug`
|
||||
//~| ERROR cannot determine resolution for the derive macro `PartialEq`
|
||||
//~| ERROR cannot determine resolution for the derive macro `Eq`
|
||||
//~^ ERROR cannot determine resolution for the attribute macro `derive`
|
||||
struct DerivedOn;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,10 @@
|
|||
error[E0774]: `derive` may only be applied to structs, enums and unions
|
||||
--> $DIR/issue-43927-non-ADT-derive.rs:3:1
|
||||
error: cannot determine resolution for the attribute macro `derive`
|
||||
--> $DIR/issue-43927-non-ADT-derive.rs:1:4
|
||||
|
|
||||
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug, PartialEq, Eq)]`
|
||||
|
||||
error: cannot determine resolution for the derive macro `Debug`
|
||||
--> $DIR/issue-43927-non-ADT-derive.rs:3:11
|
||||
|
|
||||
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
|
||||
| ^^^^^
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
error: cannot determine resolution for the derive macro `PartialEq`
|
||||
--> $DIR/issue-43927-non-ADT-derive.rs:3:18
|
||||
|
|
||||
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
error: aborting due to previous error
|
||||
|
||||
error: cannot determine resolution for the derive macro `Eq`
|
||||
--> $DIR/issue-43927-non-ADT-derive.rs:3:29
|
||||
|
|
||||
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
|
||||
| ^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0774`.
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ macro_rules! foo { () => () }
|
|||
fn main() {
|
||||
foo::<T>!(); //~ ERROR generic arguments in macro path
|
||||
foo::<>!(); //~ ERROR generic arguments in macro path
|
||||
m!(Default<>); //~ ERROR generic arguments in macro path
|
||||
m!(Default<>); //~ ERROR unexpected generic arguments in path
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ error: generic arguments in macro path
|
|||
LL | foo::<>!();
|
||||
| ^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
error: unexpected generic arguments in path
|
||||
--> $DIR/macro-ty-params.rs:12:15
|
||||
|
|
||||
LL | m!(Default<>);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue