-
Notifications
You must be signed in to change notification settings - Fork 358
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
add test for unused ill-formed constant #1504
Conversation
evaluate required_consts when pushing stack frame in Miri engine [Just like codegen](https://github.com/rust-lang/rust/pull/70820/files#diff-32c57af5c8e23eb048f55d1e955e5cd5R194), Miri needs to make sure all `required_consts` evaluate successfully, to catch post-monomorphization errors. While at it I also moved the const_eval error reporting logic into rustc_mir::const_eval::error; there is no reason it should be in `rustc_middle`. I kept this in a separate commit for easier reviewing. Helps with rust-lang/miri#1382. I will add a test on the Miri side (done now: rust-lang/miri#1504). r? @oli-obk
ff136bd
to
54a6865
Compare
@oli-obk there are some strange things going on here... first of all, this is the error Miri shows:
Note the completely ridiculous span for "referenced constant has errors", it points at the
|
0f8e843
to
7fed183
Compare
The span happens because we do this right after pushing the stack frame, when the current MIR statement to be executed is the first statement in the first block. But of course we don't want to point at that statement, we want to point at the required const that we evaluated. |
But how would we know this in I think this is similar to why ConstProp has to explicitly pass a span to |
I tried to follow our spans in For example, Also, even after lots of digging I could not figure out how we ever have more than one "primary span" in the Lucky enough none of this matters for Miri error reporting^^ but still, it's quite the chaos. |
where it is used. This is the span that should be used for linting about failed evaluation of a constant |
7fed183
to
05ac0f3
Compare
also use better span in TopFrameInfo
05ac0f3
to
925d607
Compare
@bors r+ |
📌 Commit 925d607 has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
Once rust-lang/rust#75339 lands, this test should pass.
Fixes #1382.