Skip to content

Commit 23426ab

Browse files
committed
---
yaml --- r: 208863 b: refs/heads/snap-stage3 c: 96e1cf3 h: refs/heads/master i: 208861: a5c63d6 208859: 7597a26 208855: 9f9e4c5 208847: 60f4d36 208831: ff0c884 v: v3
1 parent 04e812f commit 23426ab

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d46eef9cf3bf2f1a4ca5448c7f02e3c749e73bd9
4+
refs/heads/snap-stage3: 96e1cf3b0693e5724797abd566bd4913be4f6d79
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc/plugin/registry.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,14 @@ impl<'a> Registry<'a> {
139139

140140
/// Register an attribute with an attribute type
141141
///
142-
/// Registered attributes will bypass the `custom_attribute` feature gate
143-
///
142+
/// Registered attributes will bypass the `custom_attribute` feature gate.
144143
/// `Whitelisted` attributes will additionally not trigger the `unused_attribute`
145-
/// lint
146-
///
147-
/// `CrateLevel` attributes will not be allowed on anything other than a crate
144+
/// lint. `CrateLevel` attributes will not be allowed on anything other than a crate.
148145
pub fn register_attribute(&mut self, name: String, ty: AttributeType) {
149146
if let AttributeType::Gated(..) = ty {
150-
self.sess.err("plugin tried to register a gated attribute. \
151-
Only `Normal`, `Whitelisted`, and `CrateLevel` \
152-
attributes are allowed");
147+
self.sess.span_err(self.krate_span, "plugin tried to register a gated \
148+
attribute. Only `Normal`, `Whitelisted`, \
149+
and `CrateLevel` attributes are allowed");
153150
}
154151
self.attributes.push((name, ty));
155152
}

branches/snap-stage3/src/librustc_lint/builtin.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,17 @@ impl LintPass for UnusedAttributes {
653653

654654
if !attr::is_used(attr) {
655655
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
656-
if KNOWN_ATTRIBUTES.contains(&(&attr.name(), AttributeType::CrateLevel)) ||
657-
plugin_attributes.iter()
658-
.find(|&&(ref x, t)| &*attr.name() == &*x &&
659-
AttributeType::CrateLevel == t)
660-
.is_some() {
656+
// Is it a builtin attribute that must be used at the crate level?
657+
let known_crate = KNOWN_ATTRIBUTES.contains(&(&attr.name(),
658+
AttributeType::CrateLevel));
659+
// Has a plugin registered this attribute as one which must be used at
660+
// the crate level?
661+
let plugin_crate = plugin_attributes.iter()
662+
.find(|&&(ref x, t)| {
663+
&*attr.name() == &*x &&
664+
AttributeType::CrateLevel == t
665+
}).is_some();
666+
if known_crate || plugin_crate {
661667
let msg = match attr.node.style {
662668
ast::AttrOuter => "crate-level attribute should be an inner \
663669
attribute: add an exclamation mark: #![foo]",

0 commit comments

Comments
 (0)