Skip to content

Commit 374173c

Browse files
TypeWellFormedInEnv
1 parent fbdef58 commit 374173c

File tree

26 files changed

+75
-74
lines changed

26 files changed

+75
-74
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
965965
ty::ClauseKind::RegionOutlives(_)
966966
| ty::ClauseKind::ConstArgHasType(..)
967967
| ty::ClauseKind::WellFormed(_)
968-
| ty::ClauseKind::ConstEvaluatable(_) => {
968+
| ty::ClauseKind::ConstEvaluatable(_)
969+
| ty::ClauseKind::TypeWellFormedFromEnv(_) => {
969970
bug!()
970971
}
971972
}

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,6 @@ fn trait_predicate_kind<'tcx>(
554554
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
555555
| ty::PredicateKind::ConstEquate(..)
556556
| ty::PredicateKind::Ambiguous
557-
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
557+
| ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => None,
558558
}
559559
}

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5353
| ty::ClauseKind::Projection(_)
5454
| ty::ClauseKind::ConstArgHasType(_, _)
5555
| ty::ClauseKind::WellFormed(_)
56-
| ty::ClauseKind::ConstEvaluatable(_) => {}
56+
| ty::ClauseKind::ConstEvaluatable(_)
57+
| ty::ClauseKind::TypeWellFormedFromEnv(_) => {}
5758
}
5859
}
5960

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
683683
// inference variable.
684684
| ty::PredicateKind::ClosureKind(..)
685685
| ty::PredicateKind::Ambiguous
686-
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
686+
| ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => None,
687687
},
688688
)
689689
}

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
847847
| ty::ClauseKind::Projection(_)
848848
| ty::ClauseKind::ConstArgHasType(_, _)
849849
| ty::ClauseKind::WellFormed(_)
850-
| ty::ClauseKind::ConstEvaluatable(_) => None,
850+
| ty::ClauseKind::ConstEvaluatable(_)
851+
| ty::ClauseKind::TypeWellFormedFromEnv(_) => None,
851852
}
852853
});
853854

compiler/rustc_infer/src/infer/outlives/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ pub fn explicit_outlives_bounds<'tcx>(
3131
| ty::ClauseKind::Projection(_)
3232
| ty::ClauseKind::ConstArgHasType(_, _)
3333
| ty::ClauseKind::WellFormed(_)
34-
| ty::ClauseKind::ConstEvaluatable(_) => None,
34+
| ty::ClauseKind::ConstEvaluatable(_)
35+
| ty::ClauseKind::TypeWellFormedFromEnv(_) => None,
3536
})
3637
}
3738

compiler/rustc_infer/src/traits/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
368368
.map(|predicate| elaboratable.child(predicate)),
369369
);
370370
}
371-
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
371+
ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
372372
// Nothing to elaborate
373373
}
374374
ty::PredicateKind::Ambiguous => {}

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,8 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
16101610
// Ignore bounds that a user can't type
16111611
| ClauseKind::WellFormed(..)
16121612
// FIXME(generic_const_exprs): `ConstEvaluatable` can be written
1613-
| ClauseKind::ConstEvaluatable(..) => continue,
1613+
| ClauseKind::ConstEvaluatable(..)
1614+
| ClauseKind::TypeWellFormedFromEnv(_) => continue,
16141615
};
16151616
if predicate.is_global() {
16161617
cx.emit_spanned_lint(

compiler/rustc_middle/src/ty/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl FlagComputation {
287287
self.add_const(expected);
288288
self.add_const(found);
289289
}
290-
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
290+
ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(ty)) => {
291291
self.add_ty(ty);
292292
}
293293
ty::PredicateKind::Ambiguous => {}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl<'tcx> Predicate<'tcx> {
555555
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
556556
| PredicateKind::ConstEquate(_, _)
557557
| PredicateKind::Ambiguous
558-
| PredicateKind::TypeWellFormedFromEnv(_) => true,
558+
| PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(_)) => true,
559559
}
560560
}
561561
}
@@ -661,6 +661,11 @@ pub enum ClauseKind<'tcx> {
661661

662662
/// Constant initializer must evaluate successfully.
663663
ConstEvaluatable(ty::Const<'tcx>),
664+
665+
/// Represents a type found in the environment that we can use for implied bounds.
666+
///
667+
/// Only used for Chalk.
668+
TypeWellFormedFromEnv(Ty<'tcx>),
664669
}
665670

666671
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
@@ -697,11 +702,6 @@ pub enum PredicateKind<'tcx> {
697702
/// Constants must be equal. The first component is the const that is expected.
698703
ConstEquate(Const<'tcx>, Const<'tcx>),
699704

700-
/// Represents a type found in the environment that we can use for implied bounds.
701-
///
702-
/// Only used for Chalk.
703-
TypeWellFormedFromEnv(Ty<'tcx>),
704-
705705
/// A marker predicate that is always ambiguous.
706706
/// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
707707
Ambiguous,
@@ -1425,7 +1425,7 @@ impl<'tcx> Predicate<'tcx> {
14251425
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
14261426
| PredicateKind::ConstEquate(..)
14271427
| PredicateKind::Ambiguous
1428-
| PredicateKind::TypeWellFormedFromEnv(..) => None,
1428+
| PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None,
14291429
}
14301430
}
14311431

@@ -1446,7 +1446,7 @@ impl<'tcx> Predicate<'tcx> {
14461446
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
14471447
| PredicateKind::ConstEquate(..)
14481448
| PredicateKind::Ambiguous
1449-
| PredicateKind::TypeWellFormedFromEnv(..) => None,
1449+
| PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None,
14501450
}
14511451
}
14521452

@@ -1467,7 +1467,7 @@ impl<'tcx> Predicate<'tcx> {
14671467
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
14681468
| PredicateKind::ConstEquate(..)
14691469
| PredicateKind::Ambiguous
1470-
| PredicateKind::TypeWellFormedFromEnv(..) => None,
1470+
| PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None,
14711471
}
14721472
}
14731473

@@ -1483,7 +1483,7 @@ impl<'tcx> Predicate<'tcx> {
14831483
pub fn expect_clause(self) -> Clause<'tcx> {
14841484
match self.kind().skip_binder() {
14851485
PredicateKind::Clause(..) => Clause(self.0),
1486-
_ => bug!(),
1486+
_ => bug!("{self} is not a clause"),
14871487
}
14881488
}
14891489
}

0 commit comments

Comments
 (0)