Skip to content

Commit 22b720a

Browse files
committed
address more review comments
1 parent 96e1cf3 commit 22b720a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-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

+6-1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ 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; we only use this loop to
393+
// short-circuit to avoid the checks below
392394
debug!("check_attribute: {:?} is registered by a plugin, {:?}", name, ty);
393395
return;
394396
}
@@ -403,7 +405,10 @@ impl<'a> Context<'a> {
403405
"attributes of the form `#[derive_*]` are reserved \
404406
for the compiler");
405407
} else {
406-
// Only do the custom attribute lint post-expansion
408+
// Only run the custom attribute lint during regular
409+
// feature gate checking. Macro gating runs
410+
// before the plugin attributes are registered
411+
// so we skip this then
407412
if !is_macro {
408413
self.gate_feature("custom_attribute", attr.span,
409414
&format!("The attribute `{}` is currently \

0 commit comments

Comments
 (0)