@@ -357,12 +357,20 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
357357 . add_element ( live_region_vid, location) ;
358358 } ) ;
359359
360+ // HACK(compiler-errors): Constants that are gathered into Body.required_consts
361+ // have their locations erased...
362+ let locations = if location != Location :: START {
363+ location. to_locations ( )
364+ } else {
365+ Locations :: All ( constant. span )
366+ } ;
367+
360368 if let Some ( annotation_index) = constant. user_ty {
361369 if let Err ( terr) = self . cx . relate_type_and_user_type (
362370 constant. literal . ty ( ) ,
363371 ty:: Variance :: Invariant ,
364372 & UserTypeProjection { base : annotation_index, projs : vec ! [ ] } ,
365- location . to_locations ( ) ,
373+ locations ,
366374 ConstraintCategory :: Boring ,
367375 ) {
368376 let annotation = & self . cx . user_type_annotations [ annotation_index] ;
@@ -390,12 +398,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
390398 promoted : & Body < ' tcx > ,
391399 ty,
392400 san_ty| {
393- if let Err ( terr) = verifier. cx . eq_types (
394- ty,
395- san_ty,
396- location. to_locations ( ) ,
397- ConstraintCategory :: Boring ,
398- ) {
401+ if let Err ( terr) =
402+ verifier. cx . eq_types ( ty, san_ty, locations, ConstraintCategory :: Boring )
403+ {
399404 span_mirbug ! (
400405 verifier,
401406 promoted,
@@ -416,7 +421,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
416421 }
417422 } else {
418423 if let Err ( terr) = self . cx . fully_perform_op (
419- location . to_locations ( ) ,
424+ locations ,
420425 ConstraintCategory :: Boring ,
421426 self . cx . param_env . and ( type_op:: ascribe_user_type:: AscribeUserType :: new (
422427 constant. literal . ty ( ) ,
@@ -435,7 +440,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
435440 }
436441 } else if let Some ( static_def_id) = constant. check_static_ptr ( tcx) {
437442 let unnormalized_ty = tcx. type_of ( static_def_id) ;
438- let locations = location. to_locations ( ) ;
439443 let normalized_ty = self . cx . normalize ( unnormalized_ty, locations) ;
440444 let literal_ty = constant. literal . ty ( ) . builtin_deref ( true ) . unwrap ( ) . ty ;
441445
@@ -454,7 +458,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
454458 self . cx . normalize_and_prove_instantiated_predicates (
455459 def_id,
456460 instantiated_predicates,
457- location . to_locations ( ) ,
461+ locations ,
458462 ) ;
459463 }
460464 }
0 commit comments