@@ -15,7 +15,6 @@ use hir;
15
15
use infer:: error_reporting:: nice_region_error:: NiceRegionError ;
16
16
use ty:: { self , Region , Ty } ;
17
17
use hir:: def_id:: DefId ;
18
- use hir:: Node ;
19
18
use syntax_pos:: Span ;
20
19
21
20
// The struct contains the information about the anonymous region
@@ -35,18 +34,6 @@ pub(super) struct AnonymousArgInfo<'tcx> {
35
34
pub is_first : bool ,
36
35
}
37
36
38
- // This struct contains information regarding the
39
- // Refree((FreeRegion) corresponding to lifetime conflict
40
- #[ derive( Debug ) ]
41
- pub ( super ) struct FreeRegionInfo {
42
- // def id corresponding to FreeRegion
43
- pub def_id : DefId ,
44
- // the bound region corresponding to FreeRegion
45
- pub boundregion : ty:: BoundRegion ,
46
- // checks if bound region is in Impl Item
47
- pub is_impl_item : bool ,
48
- }
49
-
50
37
impl < ' a , ' gcx , ' tcx > NiceRegionError < ' a , ' gcx , ' tcx > {
51
38
// This method walks the Type of the function body arguments using
52
39
// `fold_regions()` function and returns the
@@ -122,36 +109,6 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
122
109
}
123
110
}
124
111
125
- // This method returns the DefId and the BoundRegion corresponding to the given region.
126
- pub ( super ) fn is_suitable_region ( & self , region : Region < ' tcx > ) -> Option < FreeRegionInfo > {
127
- let ( suitable_region_binding_scope, bound_region) = match * region {
128
- ty:: ReFree ( ref free_region) => ( free_region. scope , free_region. bound_region ) ,
129
- ty:: ReEarlyBound ( ref ebr) => (
130
- self . tcx . parent_def_id ( ebr. def_id ) . unwrap ( ) ,
131
- ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) ,
132
- ) ,
133
- _ => return None , // not a free region
134
- } ;
135
-
136
- let node_id = self . tcx
137
- . hir
138
- . as_local_node_id ( suitable_region_binding_scope)
139
- . unwrap ( ) ;
140
- let is_impl_item = match self . tcx . hir . find ( node_id) {
141
- Some ( Node :: Item ( ..) ) | Some ( Node :: TraitItem ( ..) ) => false ,
142
- Some ( Node :: ImplItem ( ..) ) => {
143
- self . is_bound_region_in_impl_item ( suitable_region_binding_scope)
144
- }
145
- _ => return None ,
146
- } ;
147
-
148
- return Some ( FreeRegionInfo {
149
- def_id : suitable_region_binding_scope,
150
- boundregion : bound_region,
151
- is_impl_item : is_impl_item,
152
- } ) ;
153
- }
154
-
155
112
// Here, we check for the case where the anonymous region
156
113
// is in the return type.
157
114
// FIXME(#42703) - Need to handle certain cases here.
@@ -176,22 +133,6 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
176
133
None
177
134
}
178
135
179
- pub ( super ) fn is_return_type_impl_trait (
180
- & self ,
181
- scope_def_id : DefId ,
182
- ) -> bool {
183
- let ret_ty = self . tcx . type_of ( scope_def_id) ;
184
- match ret_ty. sty {
185
- ty:: FnDef ( _, _) => {
186
- let sig = ret_ty. fn_sig ( self . tcx ) ;
187
- let output = self . tcx . erase_late_bound_regions ( & sig. output ( ) ) ;
188
- return output. is_impl_trait ( ) ;
189
- }
190
- _ => { }
191
- }
192
- false
193
- }
194
-
195
136
// Here we check for the case where anonymous region
196
137
// corresponds to self and if yes, we display E0312.
197
138
// FIXME(#42700) - Need to format self properly to
@@ -203,24 +144,4 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
203
144
. map ( |i| i. method_has_self_argument ) == Some ( true )
204
145
}
205
146
206
- // Here we check if the bound region is in Impl Item.
207
- pub ( super ) fn is_bound_region_in_impl_item (
208
- & self ,
209
- suitable_region_binding_scope : DefId ,
210
- ) -> bool {
211
- let container_id = self . tcx
212
- . associated_item ( suitable_region_binding_scope)
213
- . container
214
- . id ( ) ;
215
- if self . tcx . impl_trait_ref ( container_id) . is_some ( ) {
216
- // For now, we do not try to target impls of traits. This is
217
- // because this message is going to suggest that the user
218
- // change the fn signature, but they may not be free to do so,
219
- // since the signature must match the trait.
220
- //
221
- // FIXME(#42706) -- in some cases, we could do better here.
222
- return true ;
223
- }
224
- false
225
- }
226
147
}
0 commit comments