Skip to content

Commit

Permalink
Restore APIs used by clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Mar 17, 2019
1 parent cdd934e commit f8b17c5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/libsyntax/attr/mod.rs
Expand Up @@ -832,3 +832,31 @@ pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -

krate
}

// APIs used by clippy and resurrected for beta
impl Attribute {
pub fn name(&self) -> Name {
self.path.segments.last().expect("empty path in attribute").ident.name
}
}
impl MetaItem {
pub fn name(&self) -> Name {
self.ident.segments.last().expect("empty path in attribute").ident.name
}
pub fn is_scoped(&self) -> Option<Ident> {
if self.ident.segments.len() > 1 {
Some(self.ident.segments[0].ident)
} else {
None
}
}
}
impl NestedMetaItem {
pub fn word(&self) -> Option<&MetaItem> {
self.meta_item().and_then(|meta_item| if meta_item.is_word() {
Some(meta_item)
} else {
None
})
}
}

0 comments on commit f8b17c5

Please sign in to comment.