Avoid ICE when handling const auto traits in the next-gen solver
This commit is contained in:
parent
3326fbd1f4
commit
ae699c8e78
3 changed files with 27 additions and 4 deletions
|
|
@ -189,10 +189,11 @@ where
|
|||
}
|
||||
|
||||
fn consider_auto_trait_candidate(
|
||||
_ecx: &mut EvalCtxt<'_, D>,
|
||||
ecx: &mut EvalCtxt<'_, D>,
|
||||
_goal: Goal<I, Self>,
|
||||
) -> Result<Candidate<I>, NoSolution> {
|
||||
unreachable!("auto traits are never const")
|
||||
ecx.cx().delay_bug("auto traits are never const");
|
||||
Err(NoSolution)
|
||||
}
|
||||
|
||||
fn consider_trait_alias_candidate(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,15 @@
|
|||
//@ compile-flags: -Znext-solver
|
||||
// See rust-lang/rust#149285 for this test
|
||||
|
||||
#![feature(auto_traits, const_trait_impl)]
|
||||
|
||||
const auto trait Marker {}
|
||||
//~^ ERROR: auto traits cannot be const
|
||||
|
||||
fn scope() {
|
||||
fn check<T: const Marker>() {}
|
||||
check::<()>();
|
||||
//~^ ERROR: the trait bound `(): const Marker` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,23 @@
|
|||
error: auto traits cannot be const
|
||||
--> $DIR/const-auto-trait.rs:3:1
|
||||
--> $DIR/const-auto-trait.rs:6:1
|
||||
|
|
||||
LL | const auto trait Marker {}
|
||||
| ^^^^^
|
||||
|
|
||||
= help: remove the `const` keyword
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0277]: the trait bound `(): const Marker` is not satisfied
|
||||
--> $DIR/const-auto-trait.rs:11:13
|
||||
|
|
||||
LL | check::<()>();
|
||||
| ^^
|
||||
|
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/const-auto-trait.rs:10:17
|
||||
|
|
||||
LL | fn check<T: const Marker>() {}
|
||||
| ^^^^^^^^^^^^ required by this bound in `check`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue