@@ -7,14 +7,13 @@ use std::fmt::Write;
7
7
8
8
use crate :: query:: Providers ;
9
9
use rustc_data_structures:: fx:: FxIndexMap ;
10
- use rustc_errors:: { DiagnosticArgValue , IntoDiagnosticArg } ;
11
- use rustc_hir:: def_id:: { DefId , LocalDefId } ;
12
- use rustc_hir:: { self as hir, LangItem } ;
10
+ use rustc_hir as hir;
11
+ use rustc_hir:: def_id:: LocalDefId ;
13
12
use rustc_span:: def_id:: LocalDefIdMap ;
14
13
use rustc_span:: symbol:: Ident ;
15
14
use rustc_span:: { Span , Symbol } ;
16
15
17
- use super :: { Ty , TyCtxt } ;
16
+ use super :: TyCtxt ;
18
17
19
18
use self :: BorrowKind :: * ;
20
19
@@ -73,72 +72,6 @@ pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<hir::HirId, MinCaptureLis
73
72
/// Part of `MinCaptureInformationMap`; List of `CapturePlace`s.
74
73
pub type MinCaptureList < ' tcx > = Vec < CapturedPlace < ' tcx > > ;
75
74
76
- /// Represents the various closure traits in the language. This
77
- /// will determine the type of the environment (`self`, in the
78
- /// desugaring) argument that the closure expects.
79
- ///
80
- /// You can get the environment type of a closure using
81
- /// `tcx.closure_env_ty()`.
82
- #[ derive( Clone , Copy , PartialOrd , Ord , PartialEq , Eq , Hash , Debug , TyEncodable , TyDecodable ) ]
83
- #[ derive( HashStable ) ]
84
- pub enum ClosureKind {
85
- // Warning: Ordering is significant here! The ordering is chosen
86
- // because the trait Fn is a subtrait of FnMut and so in turn, and
87
- // hence we order it so that Fn < FnMut < FnOnce.
88
- Fn ,
89
- FnMut ,
90
- FnOnce ,
91
- }
92
-
93
- impl ClosureKind {
94
- /// This is the initial value used when doing upvar inference.
95
- pub const LATTICE_BOTTOM : ClosureKind = ClosureKind :: Fn ;
96
-
97
- pub const fn as_str ( self ) -> & ' static str {
98
- match self {
99
- ClosureKind :: Fn => "Fn" ,
100
- ClosureKind :: FnMut => "FnMut" ,
101
- ClosureKind :: FnOnce => "FnOnce" ,
102
- }
103
- }
104
-
105
- /// Returns `true` if a type that impls this closure kind
106
- /// must also implement `other`.
107
- pub fn extends ( self , other : ty:: ClosureKind ) -> bool {
108
- self <= other
109
- }
110
-
111
- /// Converts `self` to a [`DefId`] of the corresponding trait.
112
- ///
113
- /// Note: the inverse of this function is [`TyCtxt::fn_trait_kind_from_def_id`].
114
- pub fn to_def_id ( & self , tcx : TyCtxt < ' _ > ) -> DefId {
115
- tcx. require_lang_item (
116
- match self {
117
- ClosureKind :: Fn => LangItem :: Fn ,
118
- ClosureKind :: FnMut => LangItem :: FnMut ,
119
- ClosureKind :: FnOnce => LangItem :: FnOnce ,
120
- } ,
121
- None ,
122
- )
123
- }
124
-
125
- /// Returns the representative scalar type for this closure kind.
126
- /// See `Ty::to_opt_closure_kind` for more details.
127
- pub fn to_ty < ' tcx > ( self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
128
- match self {
129
- ClosureKind :: Fn => tcx. types . i8 ,
130
- ClosureKind :: FnMut => tcx. types . i16 ,
131
- ClosureKind :: FnOnce => tcx. types . i32 ,
132
- }
133
- }
134
- }
135
-
136
- impl IntoDiagnosticArg for ClosureKind {
137
- fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
138
- DiagnosticArgValue :: Str ( self . as_str ( ) . into ( ) )
139
- }
140
- }
141
-
142
75
/// A composite describing a `Place` that is captured by a closure.
143
76
#[ derive( PartialEq , Clone , Debug , TyEncodable , TyDecodable , HashStable ) ]
144
77
#[ derive( TypeFoldable , TypeVisitable ) ]
0 commit comments