@@ -15,7 +15,7 @@ use borrow_check::borrow_set::BorrowSet;
15
15
use borrow_check:: location:: LocationTable ;
16
16
use borrow_check:: nll:: constraints:: { ConstraintSet , OutlivesConstraint } ;
17
17
use borrow_check:: nll:: facts:: AllFacts ;
18
- use borrow_check:: nll:: region_infer:: values:: { RegionValueElements , LivenessValues } ;
18
+ use borrow_check:: nll:: region_infer:: values:: { LivenessValues , RegionValueElements } ;
19
19
use borrow_check:: nll:: region_infer:: { ClosureRegionRequirementsExt , TypeTest } ;
20
20
use borrow_check:: nll:: type_check:: free_region_relations:: { CreateResult , UniversalRegionRelations } ;
21
21
use borrow_check:: nll:: type_check:: liveness:: liveness_map:: NllLivenessMap ;
@@ -256,6 +256,22 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
256
256
self . super_constant ( constant, location) ;
257
257
self . sanitize_constant ( constant, location) ;
258
258
self . sanitize_type ( constant, constant. ty ) ;
259
+
260
+ if let Some ( user_ty) = constant. user_ty {
261
+ if let Err ( terr) =
262
+ self . cx
263
+ . eq_canonical_type_and_type ( user_ty, constant. ty , location. boring ( ) )
264
+ {
265
+ span_mirbug ! (
266
+ self ,
267
+ constant,
268
+ "bad constant user type {:?} vs {:?}: {:?}" ,
269
+ user_ty,
270
+ constant. ty,
271
+ terr,
272
+ ) ;
273
+ }
274
+ }
259
275
}
260
276
261
277
fn visit_rvalue ( & mut self , rvalue : & Rvalue < ' tcx > , location : Location ) {
@@ -343,8 +359,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
343
359
344
360
debug ! ( "sanitize_constant: expected_ty={:?}" , constant. literal. ty) ;
345
361
346
- if let Err ( terr) = self
347
- . cx
362
+ if let Err ( terr) = self . cx
348
363
. eq_types ( constant. literal . ty , constant. ty , location. boring ( ) )
349
364
{
350
365
span_mirbug ! (
0 commit comments