Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ fn const_evaluatable_predicates_of<'tcx>(
return;
}

// Skip type consts as mGCA doesn't support evaluatable clauses.
if self.tcx.is_type_const(uv.def) {
return;
}

let span = self.tcx.def_span(uv.def);
self.preds.insert((ty::ClauseKind::ConstEvaluatable(c).upcast(self.tcx), span));
}
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_trait_selection/src/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,17 +1016,20 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
match c.kind() {
ty::ConstKind::Unevaluated(uv) => {
if !c.has_escaping_bound_vars() {
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(
ty::ClauseKind::ConstEvaluatable(c),
));
let cause = self.cause(ObligationCauseCode::WellFormed(None));
self.out.push(traits::Obligation::with_depth(
tcx,
cause,
self.recursion_depth,
self.param_env,
predicate,
));
// Skip type consts as mGCA doesn't support evaluatable clauses
if !tcx.is_type_const(uv.def) {
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(
ty::ClauseKind::ConstEvaluatable(c),
));
let cause = self.cause(ObligationCauseCode::WellFormed(None));
self.out.push(traits::Obligation::with_depth(
tcx,
cause,
self.recursion_depth,
self.param_env,
predicate,
));
}

if matches!(tcx.def_kind(uv.def), DefKind::AssocConst { .. })
&& tcx.def_kind(tcx.parent(uv.def)) == (DefKind::Impl { of_trait: false })
Expand Down
18 changes: 18 additions & 0 deletions tests/ui/const-generics/type-const-ice-issue-151631.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// issue: <https://github.com/rust-lang/rust/issues/151631>
//@ compile-flags: -Znext-solver
#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

trait SuperTrait {}
trait Trait: SuperTrait {
type const K: u32;
}
impl Trait for () { //~ ERROR: the trait bound `(): SuperTrait` is not satisfied
type const K: u32 = const { 1 };
}

fn check(_: impl Trait<K = 0>) {}

fn main() {
check(()); //~ ERROR: the trait bound `(): SuperTrait` is not satisfied
}
37 changes: 37 additions & 0 deletions tests/ui/const-generics/type-const-ice-issue-151631.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
error[E0277]: the trait bound `(): SuperTrait` is not satisfied
--> $DIR/type-const-ice-issue-151631.rs:10:16
|
LL | impl Trait for () {
| ^^ the trait `SuperTrait` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/type-const-ice-issue-151631.rs:6:1
|
LL | trait SuperTrait {}
| ^^^^^^^^^^^^^^^^
note: required by a bound in `Trait`
--> $DIR/type-const-ice-issue-151631.rs:7:14
|
LL | trait Trait: SuperTrait {
| ^^^^^^^^^^ required by this bound in `Trait`

error[E0277]: the trait bound `(): SuperTrait` is not satisfied
--> $DIR/type-const-ice-issue-151631.rs:17:5
|
LL | check(());
| ^^^^^^^^^ the trait `SuperTrait` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/type-const-ice-issue-151631.rs:6:1
|
LL | trait SuperTrait {}
| ^^^^^^^^^^^^^^^^
note: required by a bound in `Trait`
--> $DIR/type-const-ice-issue-151631.rs:7:14
|
LL | trait Trait: SuperTrait {
| ^^^^^^^^^^ required by this bound in `Trait`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
Loading