diff options
| author | Samrat Man Singh <samratmansingh@gmail.com> | 2020-05-07 10:53:44 +0530 |
|---|---|---|
| committer | Michael Holloway <mdh@mdholloway.org> | 2022-07-18 22:28:17 -0400 |
| commit | 8374ab6d65e887b1458d1de517dbf59b8c542ea4 (patch) | |
| tree | 7d09800a0396549fd80757bb10455e88cb2e4174 /src | |
| parent | ed9173276a176126150b4c684a4262a135ce51ef (diff) | |
| download | rust-8374ab6d65e887b1458d1de517dbf59b8c542ea4.tar.gz rust-8374ab6d65e887b1458d1de517dbf59b8c542ea4.zip | |
Don't add attribute to allow unused-qualifications to derive impl's
Currently `#![forbid(unused_qualifications)]` is incompatible with all derive's because we add `#[allow(unused_qualifications)]` in all generated impl's.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/lint/auxiliary/add-impl.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/lint/unused-qualification-in-derive-expansion.rs | 16 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/lint/auxiliary/add-impl.rs b/src/test/ui/lint/auxiliary/add-impl.rs new file mode 100644 index 00000000000..9d0e3068aed --- /dev/null +++ b/src/test/ui/lint/auxiliary/add-impl.rs @@ -0,0 +1,22 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(AddImpl)] +// Unnecessary qualification `bar::foo` +// https://github.com/rust-lang/rust/issues/71898 +pub fn derive(input: TokenStream) -> TokenStream { + "impl B { + fn foo(&self) { use bar::foo; bar::foo() } + } + + fn foo() {} + + mod bar { pub fn foo() {} } + ".parse().unwrap() +} diff --git a/src/test/ui/lint/unused-qualification-in-derive-expansion.rs b/src/test/ui/lint/unused-qualification-in-derive-expansion.rs new file mode 100644 index 00000000000..c2efbf507fe --- /dev/null +++ b/src/test/ui/lint/unused-qualification-in-derive-expansion.rs @@ -0,0 +1,16 @@ +// run-pass +// aux-build:add-impl.rs + +#![forbid(unused_qualifications)] + +#[macro_use] +extern crate add_impl; + +#[derive(AddImpl)] +struct B; + +fn main() { + B.foo(); + foo(); + bar::foo(); +} |
