-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rustc_mir: fix miri substitution/"universe" discipline. #63497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d4196a7
b4f217e
ada6f1c
0919f7c
4149964
ceabe0d
7d9af83
f4aa00b
cb66500
96fc989
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// run-pass | ||
|
||
#![feature(const_generics)] | ||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash | ||
|
||
fn promote<const N: i32>() { | ||
// works: | ||
// | ||
// let n = N; | ||
// &n; | ||
|
||
&N; | ||
} | ||
|
||
fn main() { | ||
promote::<0>(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash | ||
--> $DIR/issue-61432.rs:3:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub struct Foo<A, B>(A, B); | ||
|
||
impl<A, B> Foo<A, B> { | ||
const HOST_SIZE: usize = std::mem::size_of::<B>(); | ||
|
||
pub fn crash() -> bool { | ||
[5; Self::HOST_SIZE] == [6; 0] //~ ERROR no associated item named `HOST_SIZE` | ||
//~^ the size for values of type `A` cannot be known | ||
//~| the size for values of type `B` cannot be known | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
error[E0599]: no associated item named `HOST_SIZE` found for type `Foo<A, B>` in the current scope | ||
--> $DIR/too_generic_eval_ice.rs:7:19 | ||
| | ||
LL | pub struct Foo<A, B>(A, B); | ||
| --------------------------- associated item `HOST_SIZE` not found for this | ||
... | ||
LL | [5; Self::HOST_SIZE] == [6; 0] | ||
| ^^^^^^^^^ associated item not found in `Foo<A, B>` | ||
| | ||
= note: the method `HOST_SIZE` exists but the following trait bounds were not satisfied: | ||
`A : std::marker::Sized` | ||
`B : std::marker::Sized` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those trait bounds are implicit when not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a different bug. This regression test is to prevent the ICE from recurring. The fact that what's done in the test is unsupported by rustc is likely lazy normalization (allowing array length constants to refer to generics of the surrounding scope) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (And it should stay unsupported on stable without T-Lang approval.) |
||
|
||
error[E0277]: the size for values of type `A` cannot be known at compilation time | ||
--> $DIR/too_generic_eval_ice.rs:7:13 | ||
| | ||
LL | [5; Self::HOST_SIZE] == [6; 0] | ||
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `std::marker::Sized` is not implemented for `A` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= help: consider adding a `where A: std::marker::Sized` bound | ||
note: required by `Foo` | ||
--> $DIR/too_generic_eval_ice.rs:1:1 | ||
| | ||
LL | pub struct Foo<A, B>(A, B); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `B` cannot be known at compilation time | ||
--> $DIR/too_generic_eval_ice.rs:7:13 | ||
| | ||
LL | [5; Self::HOST_SIZE] == [6; 0] | ||
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `std::marker::Sized` is not implemented for `B` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= help: consider adding a `where B: std::marker::Sized` bound | ||
note: required by `Foo` | ||
--> $DIR/too_generic_eval_ice.rs:1:1 | ||
| | ||
LL | pub struct Foo<A, B>(A, B); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0599. | ||
For more information about an error, try `rustc --explain E0277`. |
Uh oh!
There was an error while loading. Please reload this page.