Also add an API to check if an instance has body
This is much cheaper than building a body just for the purpose of checking if the body exists.
This commit is contained in:
parent
1bcd162465
commit
4a75d1893e
2 changed files with 14 additions and 3 deletions
|
@ -39,6 +39,14 @@ impl Instance {
|
|||
with(|context| context.instance_body(self.def))
|
||||
}
|
||||
|
||||
/// Check whether this instance has a body available.
|
||||
///
|
||||
/// This call is much cheaper than `instance.body().is_some()`, since it doesn't try to build
|
||||
/// the StableMIR body.
|
||||
pub fn has_body(&self) -> bool {
|
||||
with(|cx| cx.has_body(self.def.def_id()))
|
||||
}
|
||||
|
||||
pub fn is_foreign_item(&self) -> bool {
|
||||
with(|cx| cx.is_foreign_item(self.def.def_id()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue