File tree 2 files changed +12
-13
lines changed
compiler/rustc_middle/src/ty
2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -100,19 +100,9 @@ impl<'tcx> ClosureKind {
100
100
self <= other
101
101
}
102
102
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
-
113
103
/// Converts `self` to a [`DefId`] of the corresponding trait.
114
104
///
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`].
116
106
pub fn to_def_id ( & self , tcx : TyCtxt < ' _ > ) -> DefId {
117
107
tcx. require_lang_item (
118
108
match self {
@@ -123,6 +113,16 @@ impl<'tcx> ClosureKind {
123
113
None ,
124
114
)
125
115
}
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
+ }
126
126
}
127
127
128
128
/// 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> {
2114
2114
/// parameter. This is kind of a phantom type, except that the
2115
2115
/// most convenient thing for us to are the integral types. This
2116
2116
/// 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)`.
2119
2118
///
2120
2119
/// Note that during type checking, we use an inference variable
2121
2120
/// to represent the closure kind, because it has not yet been
You can’t perform that action at this time.
0 commit comments