Skip to content

Commit

Permalink
Rollup merge of #99485 - mdholloway:unused-qualifications-in-derive, …
Browse files Browse the repository at this point in the history
…r=oli-obk

Stop injecting `#[allow(unused_qualifications)]` in generated `derive` implementations

Currently, the `#[derive]` attribute always injects an `#[allow(unused_qualifications)]` attribute in the generated implementation. This results in an error when a derive is used in combination with `#![forbid(unused_qualifications)]`, because the `forbid` rule by definition cannot be overridden by `allow`.

It appears that the original issue that prompted the inclusion of `#[allow(unused_qualifications)]` (#19102) is no longer present in the current stable release, and the associated [test case](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-19102.rs) still passes, so the `allow` is simply removed here.

Fixes #71898.
  • Loading branch information
Dylan-DPC authored Jul 20, 2022
2 parents d9a71c1 + 05bb878 commit 3257c34
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 108 deletions.
10 changes: 1 addition & 9 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,16 +727,8 @@ impl<'a> TraitDef<'a> {

let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
let opt_trait_ref = Some(trait_ref);
let unused_qual = {
let word = rustc_ast::attr::mk_nested_word_item(Ident::new(
sym::unused_qualifications,
self.span,
));
let list = rustc_ast::attr::mk_list_item(Ident::new(sym::allow, self.span), vec![word]);
cx.attribute(list)
};

let mut a = vec![attr, unused_qual];
let mut a = vec![attr];
a.extend(self.attributes.iter().cloned());

cx.item(
Expand Down
Loading

0 comments on commit 3257c34

Please sign in to comment.