From 3f1c7e1660c8f6d8d51ac70d39c7aa53f88542d1 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Thu, 23 Jul 2015 13:26:49 -0400 Subject: [PATCH] add `#[allow(unused_qualifications)]` to derived impls closes #19102 --- src/libsyntax/ext/deriving/generic/mod.rs | 8 +++++++- src/test/run-pass/issue-19102.rs | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/issue-19102.rs diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index e7d242ab703..4f67fdd5ba4 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -606,7 +606,13 @@ impl<'a> TraitDef<'a> { attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); let ident = ast_util::impl_pretty_name(&opt_trait_ref, Some(&*self_type)); - let mut a = vec![attr]; + let unused_qual = cx.attribute( + self.span, + cx.meta_list(self.span, + InternedString::new("allow"), + vec![cx.meta_word(self.span, + InternedString::new("unused_qualifications"))])); + let mut a = vec![attr, unused_qual]; a.extend(self.attributes.iter().cloned()); cx.item( self.span, diff --git a/src/test/run-pass/issue-19102.rs b/src/test/run-pass/issue-19102.rs new file mode 100644 index 00000000000..da2af779217 --- /dev/null +++ b/src/test/run-pass/issue-19102.rs @@ -0,0 +1,20 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_qualifications)] + +use self::A::B; + +#[derive(PartialEq)] +pub enum A { + B, +} + +fn main() {}