@@ -384,7 +384,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
384384 code : traits:: ObligationCauseCode < ' tcx > ,
385385 def_id : DefId ,
386386 ) {
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) ) ;
388388 }
389389
390390 pub ( crate ) fn require_type_is_sized (
@@ -410,12 +410,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
410410 }
411411 }
412412
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 ) {
419414 if !ty. references_error ( ) {
420415 let tail = self . tcx . struct_tail_raw (
421416 ty,
@@ -434,7 +429,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
434429 } else {
435430 // We can't be sure, let's required full `Sized`.
436431 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) ;
438433 }
439434 }
440435 }
@@ -572,7 +567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
572567 code : traits:: ObligationCauseCode < ' tcx > ,
573568 ) {
574569 // 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) ;
576571 self . register_predicate ( traits:: Obligation :: new (
577572 self . tcx ,
578573 cause,
@@ -1426,9 +1421,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14261421 let bounds = self . instantiate_bounds ( span, def_id, args) ;
14271422
14281423 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) ) ,
14321425 param_env,
14331426 bounds,
14341427 ) {
@@ -1561,7 +1554,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15611554 query_result : & Canonical < ' tcx , QueryResponse < ' tcx , Ty < ' tcx > > > ,
15621555 ) -> InferResult < ' tcx , Ty < ' tcx > > {
15631556 self . instantiate_query_response_and_region_obligations (
1564- & traits :: ObligationCause :: misc ( span, self . body_id ) ,
1557+ & self . misc ( span) ,
15651558 self . param_env ,
15661559 original_values,
15671560 query_result,
0 commit comments