Skip to content

Commit 5f1643d

Browse files
committed
equate the user_ty of a constant with its declared ty
1 parent e23ad83 commit 5f1643d

File tree

1 file changed

+18
-3
lines changed
  • src/librustc_mir/borrow_check/nll/type_check

1 file changed

+18
-3
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use borrow_check::borrow_set::BorrowSet;
1515
use borrow_check::location::LocationTable;
1616
use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
1717
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};
1919
use borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest};
2020
use borrow_check::nll::type_check::free_region_relations::{CreateResult, UniversalRegionRelations};
2121
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> {
256256
self.super_constant(constant, location);
257257
self.sanitize_constant(constant, location);
258258
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+
}
259275
}
260276

261277
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
@@ -343,8 +359,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
343359

344360
debug!("sanitize_constant: expected_ty={:?}", constant.literal.ty);
345361

346-
if let Err(terr) = self
347-
.cx
362+
if let Err(terr) = self.cx
348363
.eq_types(constant.literal.ty, constant.ty, location.boring())
349364
{
350365
span_mirbug!(

0 commit comments

Comments
 (0)