Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrc
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
This commit is contained in:
commit
9c15de4fd5
56 changed files with 892 additions and 548 deletions
12
src/test/compile-fail/macro-attribute.rs
Normal file
12
src/test/compile-fail/macro-attribute.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
#[doc = $not_there] //~ error: unexpected token: `$`
|
||||
fn main() { }
|
||||
|
|
@ -14,4 +14,5 @@ fn main() {
|
|||
globnar::brotz!(); //~ ERROR non-ident macro paths are experimental
|
||||
::foo!(); //~ ERROR non-ident macro paths are experimental
|
||||
foo::<T>!(); //~ ERROR type parameters are not allowed on macros
|
||||
#[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
#[derive(Copy(Bad))]
|
||||
//~^ ERROR malformed `derive` entry
|
||||
//~^ ERROR expected one of `)`, `,`, or `::`, found `(`
|
||||
struct Test1;
|
||||
|
||||
#[derive(Copy="bad")]
|
||||
//~^ ERROR malformed `derive` entry
|
||||
//~^ ERROR expected one of `)`, `,`, or `::`, found `=`
|
||||
struct Test2;
|
||||
|
||||
#[derive()]
|
||||
|
|
|
|||
25
src/test/compile-fail/suffixed-literal-meta.rs
Normal file
25
src/test/compile-fail/suffixed-literal-meta.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2012 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.
|
||||
|
||||
#![feature(attr_literals)]
|
||||
|
||||
#[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
#[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
|
||||
fn main() { }
|
||||
Loading…
Add table
Add a link
Reference in a new issue