Skip to content

Commit db1c576

Browse files
Make some assertions in solver into debug assertions
1 parent 52bf0cf commit db1c576

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

compiler/rustc_next_trait_solver/src/canonicalizer.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
8080
};
8181

8282
let value = value.fold_with(&mut canonicalizer);
83-
assert!(!value.has_infer(), "unexpected infer in {value:?}");
84-
assert!(!value.has_placeholders(), "unexpected placeholders in {value:?}");
83+
debug_assert!(!value.has_infer(), "unexpected infer in {value:?}");
84+
debug_assert!(!value.has_placeholders(), "unexpected placeholders in {value:?}");
8585
let (max_universe, variables) = canonicalizer.finalize();
8686
Canonical { max_universe, variables, value }
8787
}
@@ -140,8 +140,8 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
140140
input.predefined_opaques_in_body.fold_with(&mut rest_canonicalizer);
141141
let value = QueryInput { goal, predefined_opaques_in_body };
142142

143-
assert!(!value.has_infer(), "unexpected infer in {value:?}");
144-
assert!(!value.has_placeholders(), "unexpected placeholders in {value:?}");
143+
debug_assert!(!value.has_infer(), "unexpected infer in {value:?}");
144+
debug_assert!(!value.has_placeholders(), "unexpected placeholders in {value:?}");
145145
let (max_universe, variables) = rest_canonicalizer.finalize();
146146
Canonical { max_universe, variables, value }
147147
}
@@ -304,7 +304,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
304304
first_region = false;
305305
curr_compressed_uv = curr_compressed_uv.next_universe();
306306
}
307-
assert!(var.is_existential());
307+
debug_assert!(var.is_existential());
308308
*var = var.with_updated_universe(curr_compressed_uv);
309309
}
310310
}
@@ -317,7 +317,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
317317
let kind = match t.kind() {
318318
ty::Infer(i) => match i {
319319
ty::TyVar(vid) => {
320-
assert_eq!(
320+
debug_assert_eq!(
321321
self.delegate.opportunistic_resolve_ty_var(vid),
322322
t,
323323
"ty vid should have been resolved fully before canonicalization"
@@ -330,15 +330,15 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
330330
))
331331
}
332332
ty::IntVar(vid) => {
333-
assert_eq!(
333+
debug_assert_eq!(
334334
self.delegate.opportunistic_resolve_int_var(vid),
335335
t,
336336
"ty vid should have been resolved fully before canonicalization"
337337
);
338338
CanonicalVarKind::Ty(CanonicalTyVarKind::Int)
339339
}
340340
ty::FloatVar(vid) => {
341-
assert_eq!(
341+
debug_assert_eq!(
342342
self.delegate.opportunistic_resolve_float_var(vid),
343343
t,
344344
"ty vid should have been resolved fully before canonicalization"
@@ -459,7 +459,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for Canonicaliz
459459
},
460460

461461
ty::ReVar(vid) => {
462-
assert_eq!(
462+
debug_assert_eq!(
463463
self.delegate.opportunistic_resolve_lt_var(vid),
464464
r,
465465
"region vid should have been resolved fully before canonicalization"
@@ -485,7 +485,8 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for Canonicaliz
485485
ty
486486
} else {
487487
let res = self.cached_fold_ty(t);
488-
assert!(self.cache.insert((self.binder_index, t), res).is_none());
488+
let old = self.cache.insert((self.binder_index, t), res);
489+
assert_eq!(old, None);
489490
res
490491
}
491492
}
@@ -494,7 +495,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for Canonicaliz
494495
let kind = match c.kind() {
495496
ty::ConstKind::Infer(i) => match i {
496497
ty::InferConst::Var(vid) => {
497-
assert_eq!(
498+
debug_assert_eq!(
498499
self.delegate.opportunistic_resolve_ct_var(vid),
499500
c,
500501
"const vid should have been resolved fully before canonicalization"

0 commit comments

Comments
 (0)