Skip to content

Commit 10e57cb

Browse files
committed
address more review comments
1 parent 96e1cf3 commit 10e57cb

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/librustc/plugin/registry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'a> Registry<'a> {
137137
}
138138

139139

140-
/// Register an attribute with an attribute type
140+
/// Register an attribute with an attribute type.
141141
///
142142
/// Registered attributes will bypass the `custom_attribute` feature gate.
143143
/// `Whitelisted` attributes will additionally not trigger the `unused_attribute`

src/librustc_lint/builtin.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,8 @@ impl LintPass for UnusedAttributes {
643643

644644
let plugin_attributes = cx.sess().plugin_attributes.borrow_mut();
645645
for &(ref name, ty) in plugin_attributes.iter() {
646-
match ty {
647-
AttributeType::Whitelisted if attr.check_name(&*name) => {
648-
break;
649-
},
650-
_ => ()
646+
if ty == AttributeType::Whitelisted && attr.check_name(&*name) {
647+
break;
651648
}
652649
}
653650

src/libsyntax/feature_gate.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ impl<'a> Context<'a> {
389389
for &(ref n, ref ty) in self.plugin_attributes.iter() {
390390
if &*n == name {
391391
// Plugins can't gate attributes, so we don't check for it
392+
// unlike the code above
392393
debug!("check_attribute: {:?} is registered by a plugin, {:?}", name, ty);
393394
return;
394395
}
@@ -403,7 +404,10 @@ impl<'a> Context<'a> {
403404
"attributes of the form `#[derive_*]` are reserved \
404405
for the compiler");
405406
} else {
406-
// Only do the custom attribute lint post-expansion
407+
// Only run the custom attribute lint during regular
408+
// feature gate checking. Macro gating runs
409+
// before the plugin attributes are registered
410+
// so we skip this then
407411
if !is_macro {
408412
self.gate_feature("custom_attribute", attr.span,
409413
&format!("The attribute `{}` is currently \

0 commit comments

Comments
 (0)