1
Fork 0

Point out custom Fn-family trait impl

This commit is contained in:
Michael Goulet 2022-07-13 05:39:01 +00:00
parent ddb7003b79
commit d25abdc0c5
3 changed files with 114 additions and 53 deletions

View file

@ -128,6 +128,14 @@ impl<'tcx> ClosureKind {
None
}
}
pub fn to_def_id(&self, tcx: TyCtxt<'_>) -> DefId {
match self {
ClosureKind::Fn => tcx.lang_items().fn_once_trait().unwrap(),
ClosureKind::FnMut => tcx.lang_items().fn_mut_trait().unwrap(),
ClosureKind::FnOnce => tcx.lang_items().fn_trait().unwrap(),
}
}
}
/// A composite describing a `Place` that is captured by a closure.