-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix the miri tool #49933
Fix the miri tool #49933
Conversation
let discr_val = self.read_discriminant_value(place, ty)?; | ||
let layout = self.layout_of(ty)?; | ||
match layout.variants { | ||
ty::layout::Variants::Single { index } => Ok(index), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this early-return index
, without going through read_discriminant_value
?
@@ -837,13 +817,39 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M | |||
} | |||
} | |||
|
|||
/// obtains the discriminant from `ByVal` or `ByValPair` and forwards to | |||
/// read_discriminant_value for `ByRef` | |||
pub fn read_discriminant_value_as_variant_index( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the comment is correct. Also, read_discriminant_as_variant_index
seems slightly better as a name?
layout::Variants::Tagged { .. } => { | ||
if discr.ty.is_signed() { | ||
let i = raw_discr.to_bytes()? as i128; | ||
// going from layout discriminant type to typeck discriminant type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call the layout/codegen/memory counterpart "tag" not "discriminant".
let discr_ty = layout::Integer::from_attr(self.tcx.tcx, discr_ty); | ||
let amt = 128 - discr_ty.size().bits(); | ||
let truncatee = sexted as u128; | ||
(truncatee << amt) >> amt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there no helpers in miri to do "integer casts" (zext/sext/trunc) without repeating these bitops all over the place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope ^^ I'll take my own advice and open an easy issue
let discr_val = dest_ty.ty_adt_def().unwrap() | ||
.discriminant_for_variant(*self.tcx, variant_index) | ||
.val; | ||
|
||
// raw discriminants for enums are isize or bigger during | ||
// their computation, but later shrunk to the smallest possible | ||
// representation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also use "discriminant" vs "tag" terminology. Also, I wish the discr
field in Variants::Tagged
was called tag
.
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I created a long lived branch in the miri repo which we're going to merge, not rebase or force-push in any other way. |
☔ The latest upstream changes (presumably #49949) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #50056) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r+ |
📌 Commit 3084c06 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
Tested on commit rust-lang/rust@f5203d1. Direct link to PR: <rust-lang/rust#49933> 🎉 miri on windows: build-fail → test-fail. 🎉 miri on linux: build-fail → test-fail.
r? @eddyb
cc @bjorn3
fixes #49777