1
Fork 0

Add TyCtxt::is_lang_item

This commit is contained in:
Michael Goulet 2024-06-14 14:18:56 -04:00
parent f8e5660532
commit d5c48ebc71
6 changed files with 42 additions and 40 deletions

View file

@ -23,6 +23,10 @@ impl<'tcx> TyCtxt<'tcx> {
})
}
pub fn is_lang_item(self, def_id: DefId, lang_item: LangItem) -> bool {
self.lang_items().get(lang_item) == Some(def_id)
}
/// Given a [`DefId`] of one of the [`Fn`], [`FnMut`] or [`FnOnce`] traits,
/// returns a corresponding [`ty::ClosureKind`].
/// For any other [`DefId`] return `None`.