Auto merge of #52589 - petrochenkov:derlint, r=alexcrichton

Attach deprecation lint `proc_macro_derive_resolution_fallback` to a specific node id

So it can be `allow`-ed from inside the derive.

cc https://github.com/rust-lang/rust/pull/51952
This commit is contained in:
bors 2018-07-23 11:39:50 +00:00
commit 970102f24c
3 changed files with 49 additions and 17 deletions

View file

@ -52,3 +52,16 @@ pub fn check_derive(_: TokenStream) -> TokenStream {
}
".parse().unwrap()
}
#[proc_macro_derive(CheckDeriveLint)]
pub fn check_derive_lint(_: TokenStream) -> TokenStream {
"
type AliasDeriveLint = FromOutside; // OK
struct OuterDeriveLint;
#[allow(proc_macro_derive_resolution_fallback)]
mod inner_derive_lint {
type Alias = FromOutside; // `FromOutside` shouldn't be available from here
type Inner = OuterDeriveLint; // `OuterDeriveLint` shouldn't be available from here
}
".parse().unwrap()
}

View file

@ -31,4 +31,7 @@ struct S;
//~| WARN this was previously accepted
struct Z;
#[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
struct W;
fn main() {}