@@ -28,15 +28,13 @@ use rustc::hir;
28
28
29
29
pub struct CheckTypeWellFormedVisitor < ' a , ' tcx : ' a > {
30
30
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
31
- code : ObligationCauseCode < ' tcx > ,
32
31
}
33
32
34
33
/// Helper type of a temporary returned by .for_item(...).
35
34
/// Necessary because we can't write the following bound:
36
35
/// F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(FnCtxt<'b, 'gcx, 'tcx>).
37
36
struct CheckWfFcxBuilder < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
38
37
inherited : super :: InheritedBuilder < ' a , ' gcx , ' tcx > ,
39
- code : ObligationCauseCode < ' gcx > ,
40
38
id : ast:: NodeId ,
41
39
span : Span ,
42
40
param_env : ty:: ParamEnv < ' tcx > ,
@@ -47,15 +45,13 @@ impl<'a, 'gcx, 'tcx> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
47
45
F : for < ' b > FnOnce ( & FnCtxt < ' b , ' gcx , ' tcx > ,
48
46
& mut CheckTypeWellFormedVisitor < ' b , ' gcx > ) -> Vec < Ty < ' tcx > >
49
47
{
50
- let code = self . code . clone ( ) ;
51
48
let id = self . id ;
52
49
let span = self . span ;
53
50
let param_env = self . param_env ;
54
51
self . inherited . enter ( |inh| {
55
52
let fcx = FnCtxt :: new ( & inh, param_env, id) ;
56
53
let wf_tys = f ( & fcx, & mut CheckTypeWellFormedVisitor {
57
54
tcx : fcx. tcx . global_tcx ( ) ,
58
- code,
59
55
} ) ;
60
56
fcx. select_all_obligations_or_error ( ) ;
61
57
fcx. regionck_item ( id, span, & wf_tys) ;
@@ -68,7 +64,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
68
64
-> CheckTypeWellFormedVisitor < ' a , ' gcx > {
69
65
CheckTypeWellFormedVisitor {
70
66
tcx,
71
- code : ObligationCauseCode :: MiscObligation
72
67
}
73
68
}
74
69
@@ -165,7 +160,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
165
160
item_id : ast:: NodeId ,
166
161
span : Span ,
167
162
sig_if_method : Option < & hir:: MethodSig > ) {
168
- let code = self . code . clone ( ) ;
163
+ let code = ObligationCauseCode :: MiscObligation ;
169
164
self . for_id ( item_id, span) . with_fcx ( |fcx, this| {
170
165
let item = fcx. tcx . associated_item ( fcx. tcx . hir . local_def_id ( item_id) ) ;
171
166
@@ -213,7 +208,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
213
208
let def_id = self . tcx . hir . local_def_id ( id) ;
214
209
CheckWfFcxBuilder {
215
210
inherited : Inherited :: build ( self . tcx , def_id) ,
216
- code : self . code . clone ( ) ,
217
211
id,
218
212
span,
219
213
param_env : self . tcx . param_env ( def_id) ,
@@ -265,7 +259,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
265
259
266
260
// All field types must be well-formed.
267
261
for field in & variant. fields {
268
- fcx. register_wf_obligation ( field. ty , field. span , this . code . clone ( ) )
262
+ fcx. register_wf_obligation ( field. ty , field. span , ObligationCauseCode :: MiscObligation )
269
263
}
270
264
}
271
265
@@ -300,11 +294,11 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
300
294
{
301
295
debug ! ( "check_item_type: {:?}" , item) ;
302
296
303
- self . for_item ( item) . with_fcx ( |fcx, this | {
297
+ self . for_item ( item) . with_fcx ( |fcx, _this | {
304
298
let ty = fcx. tcx . type_of ( fcx. tcx . hir . local_def_id ( item. id ) ) ;
305
299
let item_ty = fcx. normalize_associated_types_in ( item. span , & ty) ;
306
300
307
- fcx. register_wf_obligation ( item_ty, item. span , this . code . clone ( ) ) ;
301
+ fcx. register_wf_obligation ( item_ty, item. span , ObligationCauseCode :: MiscObligation ) ;
308
302
309
303
vec ! [ ] // no implied bounds in a const etc
310
304
} ) ;
@@ -339,7 +333,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
339
333
None => {
340
334
let self_ty = fcx. tcx . type_of ( item_def_id) ;
341
335
let self_ty = fcx. normalize_associated_types_in ( item. span , & self_ty) ;
342
- fcx. register_wf_obligation ( self_ty, ast_self_ty. span , this . code . clone ( ) ) ;
336
+ fcx. register_wf_obligation ( self_ty, ast_self_ty. span , ObligationCauseCode :: MiscObligation ) ;
343
337
}
344
338
}
345
339
@@ -374,7 +368,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
374
368
// parameter includes another (e.g., <T, U = T>). In those cases, we can't
375
369
// be sure if it will error or not as user might always specify the other.
376
370
if !ty. needs_subst ( ) {
377
- fcx. register_wf_obligation ( ty, fcx. tcx . def_span ( d) , self . code . clone ( ) ) ;
371
+ fcx. register_wf_obligation ( ty, fcx. tcx . def_span ( d) , ObligationCauseCode :: MiscObligation ) ;
378
372
}
379
373
}
380
374
@@ -458,11 +452,11 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
458
452
let sig = fcx. tcx . liberate_late_bound_regions ( def_id, & sig) ;
459
453
460
454
for input_ty in sig. inputs ( ) {
461
- fcx. register_wf_obligation ( & input_ty, span, self . code . clone ( ) ) ;
455
+ fcx. register_wf_obligation ( & input_ty, span, ObligationCauseCode :: MiscObligation ) ;
462
456
}
463
457
implied_bounds. extend ( sig. inputs ( ) ) ;
464
458
465
- fcx. register_wf_obligation ( sig. output ( ) , span, self . code . clone ( ) ) ;
459
+ fcx. register_wf_obligation ( sig. output ( ) , span, ObligationCauseCode :: MiscObligation ) ;
466
460
467
461
// FIXME(#25759) return types should not be implied bounds
468
462
implied_bounds. push ( sig. output ( ) ) ;
0 commit comments