@@ -384,7 +384,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
384
384
code : traits:: ObligationCauseCode < ' tcx > ,
385
385
def_id : DefId ,
386
386
) {
387
- self . register_bound ( ty, def_id, traits :: ObligationCause :: new ( span , self . body_id , code) ) ;
387
+ self . register_bound ( ty, def_id, self . cause ( span , code) ) ;
388
388
}
389
389
390
390
pub ( crate ) fn require_type_is_sized (
@@ -410,12 +410,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
410
410
}
411
411
}
412
412
413
- pub ( crate ) fn require_type_has_static_alignment (
414
- & self ,
415
- ty : Ty < ' tcx > ,
416
- span : Span ,
417
- code : traits:: ObligationCauseCode < ' tcx > ,
418
- ) {
413
+ pub ( crate ) fn require_type_has_static_alignment ( & self , ty : Ty < ' tcx > , span : Span ) {
419
414
if !ty. references_error ( ) {
420
415
let tail = self . tcx . struct_tail_raw (
421
416
ty,
@@ -434,7 +429,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
434
429
} else {
435
430
// We can't be sure, let's required full `Sized`.
436
431
let lang_item = self . tcx . require_lang_item ( LangItem :: Sized , None ) ;
437
- self . require_type_meets ( ty, span, code , lang_item) ;
432
+ self . require_type_meets ( ty, span, ObligationCauseCode :: Misc , lang_item) ;
438
433
}
439
434
}
440
435
}
@@ -572,7 +567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
572
567
code : traits:: ObligationCauseCode < ' tcx > ,
573
568
) {
574
569
// WF obligations never themselves fail, so no real need to give a detailed cause:
575
- let cause = traits :: ObligationCause :: new ( span , self . body_id , code) ;
570
+ let cause = self . cause ( span , code) ;
576
571
self . register_predicate ( traits:: Obligation :: new (
577
572
self . tcx ,
578
573
cause,
@@ -1426,9 +1421,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1426
1421
let bounds = self . instantiate_bounds ( span, def_id, args) ;
1427
1422
1428
1423
for obligation in traits:: predicates_for_generics (
1429
- |idx, predicate_span| {
1430
- traits:: ObligationCause :: new ( span, self . body_id , code ( idx, predicate_span) )
1431
- } ,
1424
+ |idx, predicate_span| self . cause ( span, code ( idx, predicate_span) ) ,
1432
1425
param_env,
1433
1426
bounds,
1434
1427
) {
@@ -1561,7 +1554,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1561
1554
query_result : & Canonical < ' tcx , QueryResponse < ' tcx , Ty < ' tcx > > > ,
1562
1555
) -> InferResult < ' tcx , Ty < ' tcx > > {
1563
1556
self . instantiate_query_response_and_region_obligations (
1564
- & traits :: ObligationCause :: misc ( span, self . body_id ) ,
1557
+ & self . misc ( span) ,
1565
1558
self . param_env ,
1566
1559
original_values,
1567
1560
query_result,
0 commit comments