Skip to content
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

miri: layout should not affect CTFE checks (outside of validation) #55142

Merged
merged 1 commit into from
Oct 18, 2018

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Oct 17, 2018

Either the enum has no valid discriminant, then the code later will catch that; or it does, then we shouldn't error out so early (absent enforcing validity).

Interestingly, the miri test suite still passes; my guess is we don't even get here for uninhabited types?

r? @oli-obk

@RalfJung RalfJung changed the title layout should not affect CTFE checks (outside of validation) miri: layout should not affect CTFE checks (outside of validation) Oct 17, 2018
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 17, 2018
@@ -688,9 +688,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
rval: OpTy<'tcx, M::PointerTag>,
) -> EvalResult<'tcx, (u128, usize)> {
trace!("read_discriminant_value {:#?}", rval.layout);
if rval.layout.abi.is_uninhabited() {
return err!(Unreachable);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is unreachable (pun intended), can you change this into an assert?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is unreachable. But I am sure that the behavior we want is to treat such enums like all the others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/subject/unreachable-discriminant/near/135957117

gist: the code is unreachable right now, but probably not in the future. Also empty enums aren't special and we'll fail on attempting to read their discriminant, so everything is good.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 17, 2018

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 17, 2018

📌 Commit c31819b has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Oct 18, 2018
…li-obk

miri: layout should not affect CTFE checks (outside of validation)

Either the enum has no valid discriminant, then the code later will catch that; or it does, then we shouldn't error out so early (absent enforcing validity).

Interestingly, the miri test suite still passes; my guess is we don't even get here for uninhabited types?

r? @oli-obk
bors added a commit that referenced this pull request Oct 18, 2018
Rollup of 18 pull requests

Successful merges:

 - #54646 (improve documentation on std::thread::sleep)
 - #54933 (Cleanup the rest of codegen_llvm)
 - #54964 (Run both lldb and gdb tests)
 - #55016 (Deduplicate some code and compile-time values around vtables)
 - #55031 (Improve verify_llvm_ir config option)
 - #55050 (doc std::fmt: the Python inspiration is already mentioned in precedin…)
 - #55077 (rustdoc: Use dyn keyword when rendering dynamic traits)
 - #55080 (Detect if access to localStorage is forbidden by the user's browser)
 - #55090 (regression test for move out of borrow via pattern)
 - #55102 (resolve: Do not skip extern prelude during speculative resolution)
 - #55104 (Add test for #34229)
 - #55111 ([Rustc Book] Explain --cfg's arguments)
 - #55122 (Cleanup mir/borrowck)
 - #55127 (Remove HybridBitSet::dummy)
 - #55128 (Fix LLVMRustInlineAsmVerify return type mismatch)
 - #55142 (miri: layout should not affect CTFE checks (outside of validation))
 - #55151 (Cleanup nll)
 - #55161 ([librustdoc] Disable spellcheck for search field)
@bors bors merged commit c31819b into rust-lang:master Oct 18, 2018
@RalfJung RalfJung deleted the miri-uninhabited-enum branch November 9, 2018 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants