diff options
| author | Steven Fackler <sfackler@gmail.com> | 2014-05-20 22:07:42 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2014-05-24 16:08:36 -0700 |
| commit | 50181add04279eaac2b078d36823035933844226 (patch) | |
| tree | 7d97577a6252865f38aaaf69898ef555a702e667 /src/libsyntax | |
| parent | c305473d3c60d5b4590ef8c715468f718a7aad8f (diff) | |
First sketch of lint pass
Enough attributes are marked to cleanly compile an empty library.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 83ac2c08efb..ac5792febbb 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -35,9 +35,9 @@ pub fn is_used(attr: &Attribute) -> bool { } pub trait AttrMetaMethods { - // This could be changed to `fn check_name(&self, name: InternedString) -> - // bool` which would facilitate a side table recording which - // attributes/meta items are used/unused. + fn check_name(&self, name: &str) -> bool { + name == self.name().get() + } /// Retrieve the name of the meta item, e.g. foo in #[foo], /// #[foo="bar"] and #[foo(bar)] @@ -59,6 +59,14 @@ pub trait AttrMetaMethods { } impl AttrMetaMethods for Attribute { + fn check_name(&self, name: &str) -> bool { + if name == self.name().get() { + mark_used(self); + true + } else { + false + } + } fn name(&self) -> InternedString { self.meta().name() } fn value_str(&self) -> Option<InternedString> { self.meta().value_str() diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 83118df5e65..64b7e1c28c1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -474,7 +474,7 @@ pub fn expand_view_item(vi: &ast::ViewItem, match vi.node { ast::ViewItemExternCrate(..) => { let should_load = vi.attrs.iter().any(|attr| { - attr.name().get() == "phase" && + attr.check_name("phase") && attr.meta_item_list().map_or(false, |phases| { attr::contains_name(phases, "syntax") }) |
