This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -100,19 +100,9 @@ impl<'tcx> ClosureKind {
100100 self <= other
101101 }
102102
103- /// Returns the representative scalar type for this closure kind.
104- /// See `Ty::to_opt_closure_kind` for more details.
105- pub fn to_ty ( self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
106- match self {
107- ClosureKind :: Fn => tcx. types . i8 ,
108- ClosureKind :: FnMut => tcx. types . i16 ,
109- ClosureKind :: FnOnce => tcx. types . i32 ,
110- }
111- }
112-
113103 /// Converts `self` to a [`DefId`] of the corresponding trait.
114104 ///
115- /// Note: the inverse of this function is [`TyCtxt::fn_trait_kind_from_def_id`]
105+ /// Note: the inverse of this function is [`TyCtxt::fn_trait_kind_from_def_id`].
116106 pub fn to_def_id ( & self , tcx : TyCtxt < ' _ > ) -> DefId {
117107 tcx. require_lang_item (
118108 match self {
@@ -123,6 +113,16 @@ impl<'tcx> ClosureKind {
123113 None ,
124114 )
125115 }
116+
117+ /// Returns the representative scalar type for this closure kind.
118+ /// See `Ty::to_opt_closure_kind` for more details.
119+ pub fn to_ty ( self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
120+ match self {
121+ ClosureKind :: Fn => tcx. types . i8 ,
122+ ClosureKind :: FnMut => tcx. types . i16 ,
123+ ClosureKind :: FnOnce => tcx. types . i32 ,
124+ }
125+ }
126126}
127127
128128/// A composite describing a `Place` that is captured by a closure.
Original file line number Diff line number Diff line change @@ -2114,8 +2114,7 @@ impl<'tcx> Ty<'tcx> {
21142114 /// parameter. This is kind of a phantom type, except that the
21152115 /// most convenient thing for us to are the integral types. This
21162116 /// function converts such a special type into the closure
2117- /// kind. To go the other way, use
2118- /// `tcx.closure_kind_ty(closure_kind)`.
2117+ /// kind. To go the other way, use `closure_kind.to_ty(tcx)`.
21192118 ///
21202119 /// Note that during type checking, we use an inference variable
21212120 /// to represent the closure kind, because it has not yet been
You can’t perform that action at this time.
0 commit comments