mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 09:23:05 +00:00
add helper to get DefId from MonoItem
This commit is contained in:
parent
fbf8b937b4
commit
74f4da44a5
@ -200,6 +200,15 @@ impl<'tcx> MonoItem<'tcx> {
|
||||
MonoItem::GlobalAsm(..) => LOCAL_CRATE,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the item's `DefId`
|
||||
pub fn def_id(&self) -> DefId {
|
||||
match *self {
|
||||
MonoItem::Fn(Instance { def, .. }) => def.def_id(),
|
||||
MonoItem::Static(def_id) => def_id,
|
||||
MonoItem::GlobalAsm(item_id) => item_id.owner_id.to_def_id(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Display for MonoItem<'tcx> {
|
||||
|
Loading…
Reference in New Issue
Block a user