From 22b720a920612211d83f7176d7cf2f184c74d294 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 13 May 2015 12:23:43 +0530 Subject: [PATCH] address more review comments --- src/librustc/plugin/registry.rs | 2 +- src/librustc_lint/builtin.rs | 7 ++----- src/libsyntax/feature_gate.rs | 7 ++++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs index d532ad38d04e..8fc032572c3d 100644 --- a/src/librustc/plugin/registry.rs +++ b/src/librustc/plugin/registry.rs @@ -137,7 +137,7 @@ impl<'a> Registry<'a> { } - /// Register an attribute with an attribute type + /// Register an attribute with an attribute type. /// /// Registered attributes will bypass the `custom_attribute` feature gate. /// `Whitelisted` attributes will additionally not trigger the `unused_attribute` diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 27c702131517..8d8fbd5bf9a1 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -643,11 +643,8 @@ impl LintPass for UnusedAttributes { let plugin_attributes = cx.sess().plugin_attributes.borrow_mut(); for &(ref name, ty) in plugin_attributes.iter() { - match ty { - AttributeType::Whitelisted if attr.check_name(&*name) => { - break; - }, - _ => () + if ty == AttributeType::Whitelisted && attr.check_name(&*name) { + break; } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index abb4ce15996c..495f152d315c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -389,6 +389,8 @@ impl<'a> Context<'a> { for &(ref n, ref ty) in self.plugin_attributes.iter() { if &*n == name { // Plugins can't gate attributes, so we don't check for it + // unlike the code above; we only use this loop to + // short-circuit to avoid the checks below debug!("check_attribute: {:?} is registered by a plugin, {:?}", name, ty); return; } @@ -403,7 +405,10 @@ impl<'a> Context<'a> { "attributes of the form `#[derive_*]` are reserved \ for the compiler"); } else { - // Only do the custom attribute lint post-expansion + // Only run the custom attribute lint during regular + // feature gate checking. Macro gating runs + // before the plugin attributes are registered + // so we skip this then if !is_macro { self.gate_feature("custom_attribute", attr.span, &format!("The attribute `{}` is currently \