Don't ICE when encountering placeholders in layout computation
This commit is contained in:
parent
aba23fd500
commit
c80d9b8d67
4 changed files with 24 additions and 14 deletions
|
@ -611,7 +611,7 @@ fn layout_of_uncached<'tcx>(
|
|||
}
|
||||
|
||||
// Types with no meaningful known layout.
|
||||
ty::Param(_) => {
|
||||
ty::Param(_) | ty::Placeholder(..) => {
|
||||
return Err(error(cx, LayoutError::TooGeneric(ty)));
|
||||
}
|
||||
|
||||
|
@ -628,11 +628,7 @@ fn layout_of_uncached<'tcx>(
|
|||
return Err(error(cx, err));
|
||||
}
|
||||
|
||||
ty::Placeholder(..)
|
||||
| ty::Bound(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Error(_) => {
|
||||
ty::Bound(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => {
|
||||
// `ty::Error` is handled at the top of this function.
|
||||
bug!("layout_of: unexpected type `{ty}`")
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/too_generic_eval_ice.rs:7:13
|
||||
--> $DIR/too_generic_eval_ice.rs:11:13
|
||||
|
|
||||
LL | [5; Self::HOST_SIZE] == [6; 0]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
@ -7,7 +7,7 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
|
|||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/too_generic_eval_ice.rs:7:9
|
||||
--> $DIR/too_generic_eval_ice.rs:11:9
|
||||
|
|
||||
LL | [5; Self::HOST_SIZE] == [6; 0]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -15,7 +15,7 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
|
|||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/too_generic_eval_ice.rs:7:30
|
||||
--> $DIR/too_generic_eval_ice.rs:11:30
|
||||
|
|
||||
LL | [5; Self::HOST_SIZE] == [6; 0]
|
||||
| ^^
|
||||
|
@ -23,7 +23,7 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
|
|||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error[E0277]: can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]`
|
||||
--> $DIR/too_generic_eval_ice.rs:7:30
|
||||
--> $DIR/too_generic_eval_ice.rs:11:30
|
||||
|
|
||||
LL | [5; Self::HOST_SIZE] == [6; 0]
|
||||
| ^^ no implementation for `[{integer}; Self::HOST_SIZE] == [{integer}; 0]`
|
9
tests/ui/consts/too_generic_eval_ice.next.stderr
Normal file
9
tests/ui/consts/too_generic_eval_ice.next.stderr
Normal file
|
@ -0,0 +1,9 @@
|
|||
error[E0284]: type annotations needed: cannot satisfy `the constant `Self::HOST_SIZE` can be evaluated`
|
||||
--> $DIR/too_generic_eval_ice.rs:11:13
|
||||
|
|
||||
LL | [5; Self::HOST_SIZE] == [6; 0]
|
||||
| ^^^^^^^^^^^^^^^ cannot satisfy `the constant `Self::HOST_SIZE` can be evaluated`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0284`.
|
|
@ -1,3 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
pub struct Foo<A, B>(A, B);
|
||||
|
||||
impl<A, B> Foo<A, B> {
|
||||
|
@ -5,10 +9,11 @@ impl<A, B> Foo<A, B> {
|
|||
|
||||
pub fn crash() -> bool {
|
||||
[5; Self::HOST_SIZE] == [6; 0]
|
||||
//~^ ERROR constant expression depends on a generic parameter
|
||||
//~| ERROR constant expression depends on a generic parameter
|
||||
//~| ERROR constant expression depends on a generic parameter
|
||||
//~| ERROR can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]`
|
||||
//[current]~^ ERROR constant expression depends on a generic parameter
|
||||
//[current]~| ERROR constant expression depends on a generic parameter
|
||||
//[current]~| ERROR constant expression depends on a generic parameter
|
||||
//[current]~| ERROR can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]`
|
||||
//[next]~^^^^^ ERROR type annotations needed
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue