Skip to content

Commit b187c42

Browse files
committed
Consider changing assert! to debug_assert! when it calls visit_with
1 parent f6d43ed commit b187c42

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/librustc/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
146146
debug!("normalize_projection_type(projection_ty={:?})",
147147
projection_ty);
148148

149-
assert!(!projection_ty.has_escaping_regions());
149+
debug_assert!(!projection_ty.has_escaping_regions());
150150

151151
// FIXME(#20304) -- cache
152152

src/librustc/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>(
11421142
if !is_default {
11431143
true
11441144
} else if obligation.param_env.reveal == Reveal::All {
1145-
assert!(!poly_trait_ref.needs_infer());
1145+
debug_assert!(!poly_trait_ref.needs_infer());
11461146
if !poly_trait_ref.needs_subst() {
11471147
true
11481148
} else {

src/librustc/traits/select.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
563563
pub fn select(&mut self, obligation: &TraitObligation<'tcx>)
564564
-> SelectionResult<'tcx, Selection<'tcx>> {
565565
debug!("select({:?})", obligation);
566-
assert!(!obligation.predicate.has_escaping_regions());
566+
debug_assert!(!obligation.predicate.has_escaping_regions());
567567

568568
let stack = self.push_stack(TraitObligationStackList::empty(), obligation);
569569

@@ -662,7 +662,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
662662

663663
match obligation.predicate {
664664
ty::Predicate::Trait(ref t) => {
665-
assert!(!t.has_escaping_regions());
665+
debug_assert!(!t.has_escaping_regions());
666666
let obligation = obligation.with(t.clone());
667667
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
668668
}
@@ -1076,7 +1076,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
10761076
debug!("candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})",
10771077
cache_fresh_trait_pred,
10781078
stack);
1079-
assert!(!stack.obligation.predicate.has_escaping_regions());
1079+
debug_assert!(!stack.obligation.predicate.has_escaping_regions());
10801080

10811081
if let Some(c) = self.check_candidate_cache(stack.obligation.param_env,
10821082
&cache_fresh_trait_pred) {
@@ -1586,7 +1586,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
15861586
snapshot: &infer::CombinedSnapshot<'cx, 'tcx>)
15871587
-> bool
15881588
{
1589-
assert!(!skol_trait_ref.has_escaping_regions());
1589+
debug_assert!(!skol_trait_ref.has_escaping_regions());
15901590
if self.infcx.at(&obligation.cause, obligation.param_env)
15911591
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() {
15921592
return false;

src/librustc/ty/layout.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
466466
let univariant = |fields: &[TyLayout], repr: &ReprOptions, kind| {
467467
Ok(tcx.intern_layout(univariant_uninterned(fields, repr, kind)?))
468468
};
469-
assert!(!ty.has_infer_types());
469+
debug_assert!(!ty.has_infer_types());
470470

471471
Ok(match ty.sty {
472472
// Basic scalars.
@@ -1283,7 +1283,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
12831283
tcx: TyCtxt<'a, 'tcx, 'tcx>,
12841284
param_env: ty::ParamEnv<'tcx>)
12851285
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
1286-
assert!(!ty.has_infer_types());
1286+
debug_assert!(!ty.has_infer_types());
12871287

12881288
// First try computing a static layout.
12891289
let err = match tcx.layout_of(param_env.and(ty)) {
@@ -1300,7 +1300,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
13001300
let tail = tcx.struct_tail(pointee);
13011301
match tail.sty {
13021302
ty::TyParam(_) | ty::TyProjection(_) => {
1303-
assert!(tail.has_param_types() || tail.has_self_ty());
1303+
debug_assert!(tail.has_param_types() || tail.has_self_ty());
13041304
Ok(SizeSkeleton::Pointer {
13051305
non_zero,
13061306
tail: tcx.erase_regions(&tail)

src/librustc/ty/sty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ impl<'a, 'gcx, 'tcx> ExistentialTraitRef<'tcx> {
708708
pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>)
709709
-> ty::TraitRef<'tcx> {
710710
// otherwise the escaping regions would be captured by the binder
711-
assert!(!self_ty.has_escaping_regions());
711+
debug_assert!(!self_ty.has_escaping_regions());
712712

713713
ty::TraitRef {
714714
def_id: self.def_id,
@@ -753,7 +753,7 @@ impl<T> Binder<T> {
753753
pub fn dummy<'tcx>(value: T) -> Binder<T>
754754
where T: TypeFoldable<'tcx>
755755
{
756-
assert!(!value.has_escaping_regions());
756+
debug_assert!(!value.has_escaping_regions());
757757
Binder(value)
758758
}
759759

@@ -1247,7 +1247,7 @@ impl<'a, 'tcx, 'gcx> ExistentialProjection<'tcx> {
12471247
-> ty::ProjectionPredicate<'tcx>
12481248
{
12491249
// otherwise the escaping regions would be captured by the binders
1250-
assert!(!self_ty.has_escaping_regions());
1250+
debug_assert!(!self_ty.has_escaping_regions());
12511251

12521252
ty::ProjectionPredicate {
12531253
projection_ty: ty::ProjectionTy {

0 commit comments

Comments
 (0)