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:
parent
298d1578f0
commit
caf6f17c0f
1 changed files with 1 additions and 2 deletions
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue