get_attrs: use tcx.map.attrs

This is more flexible and less error-prone. `get_attrs` can now be used
on many more types of items.
This commit is contained in:
Philip Munksgaard 2015-03-04 15:47:28 +01:00
parent 298d1578f0
commit caf6f17c0f

View file

@ -5592,8 +5592,7 @@ pub fn predicates<'tcx>(
pub fn get_attrs<'tcx>(tcx: &'tcx ctxt, did: DefId) pub fn get_attrs<'tcx>(tcx: &'tcx ctxt, did: DefId)
-> Cow<'tcx, [ast::Attribute]> { -> Cow<'tcx, [ast::Attribute]> {
if is_local(did) { if is_local(did) {
let item = tcx.map.expect_item(did.node); Cow::Borrowed(tcx.map.attrs(did.node))
Cow::Borrowed(&item.attrs)
} else { } else {
Cow::Owned(csearch::get_item_attrs(&tcx.sess.cstore, did)) Cow::Owned(csearch::get_item_attrs(&tcx.sess.cstore, did))
} }