Skip to content

Commit c6112e1

Browse files
Normalize before computing ConstArgHasType goal
1 parent 9c4ff56 commit c6112e1

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

compiler/rustc_next_trait_solver/src/solve/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ where
191191
goal: Goal<I, (I::Const, I::Ty)>,
192192
) -> QueryResult<I> {
193193
let (ct, ty) = goal.predicate;
194+
let ct = self.structurally_normalize_const(goal.param_env, ct)?;
194195

195196
let ct_ty = match ct.kind() {
196197
ty::ConstKind::Infer(_) => {

tests/crashes/139905.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trait A<const B: bool> {}
2+
impl A<{}> for () {}
3+
// ^^ Let's call this "UNEVALUATED".
4+
5+
// During overlap check, we end up trying to prove `(): A<?0c>`. Inference guides
6+
// `?0c = UNEVALUATED` (which is the `{}` const in the erroneous impl). We then
7+
// fail to prove `ConstArgHasType<UNEVALUATED, u8>` since `UNEVALUATED` has the
8+
// type `bool` from the type_of query. We then deeply normalize the predicate for
9+
// error reporting, which ends up normalizing `UNEVALUATED` to a ConstKind::Error.
10+
// This ended up ICEing when trying to report an error for the `ConstArgHasType`
11+
// predicate, since we don't expect `ConstArgHasType(ERROR, Ty)` to ever fail.
12+
13+
trait C<const D: u8> {}
14+
impl<const D: u8> C<D> for () where (): A<D> {}
15+
impl<const D: u8> C<D> for () {}
16+
17+
fn main() {}

0 commit comments

Comments
 (0)