1
Fork 0

micro doc fixes

This commit is contained in:
Maybe Waffle 2022-11-22 18:52:07 +00:00
parent fa89f53352
commit ea447924ce
2 changed files with 12 additions and 13 deletions

View file

@ -100,19 +100,9 @@ impl<'tcx> ClosureKind {
self <= other self <= other
} }
/// Returns the representative scalar type for this closure kind.
/// See `Ty::to_opt_closure_kind` for more details.
pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match self {
ClosureKind::Fn => tcx.types.i8,
ClosureKind::FnMut => tcx.types.i16,
ClosureKind::FnOnce => tcx.types.i32,
}
}
/// Converts `self` to a [`DefId`] of the corresponding trait. /// Converts `self` to a [`DefId`] of the corresponding trait.
/// ///
/// Note: the inverse of this function is [`TyCtxt::fn_trait_kind_from_def_id`] /// Note: the inverse of this function is [`TyCtxt::fn_trait_kind_from_def_id`].
pub fn to_def_id(&self, tcx: TyCtxt<'_>) -> DefId { pub fn to_def_id(&self, tcx: TyCtxt<'_>) -> DefId {
tcx.require_lang_item( tcx.require_lang_item(
match self { match self {
@ -123,6 +113,16 @@ impl<'tcx> ClosureKind {
None, None,
) )
} }
/// Returns the representative scalar type for this closure kind.
/// See `Ty::to_opt_closure_kind` for more details.
pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match self {
ClosureKind::Fn => tcx.types.i8,
ClosureKind::FnMut => tcx.types.i16,
ClosureKind::FnOnce => tcx.types.i32,
}
}
} }
/// A composite describing a `Place` that is captured by a closure. /// A composite describing a `Place` that is captured by a closure.

View file

@ -2114,8 +2114,7 @@ impl<'tcx> Ty<'tcx> {
/// parameter. This is kind of a phantom type, except that the /// parameter. This is kind of a phantom type, except that the
/// most convenient thing for us to are the integral types. This /// most convenient thing for us to are the integral types. This
/// function converts such a special type into the closure /// function converts such a special type into the closure
/// kind. To go the other way, use /// kind. To go the other way, use `closure_kind.to_ty(tcx)`.
/// `tcx.closure_kind_ty(closure_kind)`.
/// ///
/// Note that during type checking, we use an inference variable /// Note that during type checking, we use an inference variable
/// to represent the closure kind, because it has not yet been /// to represent the closure kind, because it has not yet been