-
Notifications
You must be signed in to change notification settings - Fork 13.4k
handle ConstValue::ByRef in relate #71018
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
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,11 @@ | ||
#![feature(const_generics)] | ||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash | ||
|
||
struct Const<const V: [usize; 1]> {} | ||
|
||
fn main() { | ||
let mut x = Const::<{ [3] }> {}; | ||
x = Const::<{ [4] }> {}; | ||
//~^ ERROR mismatched types | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash | ||
--> $DIR/different_byref.rs:1:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/different_byref.rs:8:9 | ||
| | ||
LL | x = Const::<{ [4] }> {}; | ||
| ^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `4usize` | ||
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. Only mildly related to this PR @rust-lang/wg-const-eval we could consider collecting all spans that lead to a value during const eval and thus allow each byte in the final constant to have its own spans for diagnostics. Then we can report a sort of backtrace for values. Though I fear that will cause quite some overhead, even if we only need to do it in the current crate and not serialize it to metadata (so 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 would be more advanced than what we do for type aliases, heh. |
||
| | ||
= note: expected struct `Const<[3usize]>` | ||
found struct `Const<[4usize]>` | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// check-pass | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Const<const V: [usize; 0]> {} | ||
type MyConst = Const<{ [] }>; | ||
|
||
fn main() { | ||
let _x = Const::<{ [] }> {}; | ||
let _y = MyConst {}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// check-pass | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Foo<const V: [usize; 0] > {} | ||
|
||
type MyFoo = Foo<{ [] }>; | ||
|
||
fn main() { | ||
let _ = Foo::<{ [] }> {}; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.