Skip to content

Commit c80ab42

Browse files
committed
Avoid ICE when handling const auto traits in the next-gen solver
1 parent 3326fbd commit c80ab42

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

compiler/rustc_next_trait_solver/src/solve/effect_goals.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ where
189189
}
190190

191191
fn consider_auto_trait_candidate(
192-
_ecx: &mut EvalCtxt<'_, D>,
192+
ecx: &mut EvalCtxt<'_, D>,
193193
_goal: Goal<I, Self>,
194194
) -> Result<Candidate<I>, NoSolution> {
195-
unreachable!("auto traits are never const")
195+
ecx.cx().delay_bug("auto traits are never const");
196+
Err(NoSolution)
196197
}
197198

198199
fn consider_trait_alias_candidate(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
//@ compile-flags: -Znext-solver
12
#![feature(auto_traits, const_trait_impl)]
23

34
const auto trait Marker {}
45
//~^ ERROR: auto traits cannot be const
56

7+
fn scope() {
8+
fn check<T: const Marker>() {}
9+
check::<()>();
10+
//~^ ERROR: the trait bound `(): const Marker` is not satisfied
11+
}
12+
613
fn main() {}
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
error: auto traits cannot be const
2-
--> $DIR/const-auto-trait.rs:3:1
2+
--> $DIR/const-auto-trait.rs:4:1
33
|
44
LL | const auto trait Marker {}
55
| ^^^^^
66
|
77
= help: remove the `const` keyword
88

9-
error: aborting due to 1 previous error
9+
error[E0277]: the trait bound `(): const Marker` is not satisfied
10+
--> $DIR/const-auto-trait.rs:9:13
11+
|
12+
LL | check::<()>();
13+
| ^^
14+
|
15+
note: required by a bound in `check`
16+
--> $DIR/const-auto-trait.rs:8:17
17+
|
18+
LL | fn check<T: const Marker>() {}
19+
| ^^^^^^^^^^^^ required by this bound in `check`
20+
21+
error: aborting due to 2 previous errors
1022

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

0 commit comments

Comments
 (0)