-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Remove mir::CastKind::Misc
#102675
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
Remove mir::CastKind::Misc
#102675
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 |
---|---|---|
|
@@ -42,8 +42,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |
let res = self.pointer_from_exposed_address_cast(&src, cast_ty)?; | ||
self.write_immediate(res, dest)?; | ||
} | ||
|
||
Misc => { | ||
// FIXME: We shouldn't use `misc_cast` for these but handle them separately. | ||
IntToInt | FloatToInt | FloatToFloat | IntToFloat | FnPtrToPtr | PtrToPtr => { | ||
let src = self.read_immediate(src)?; | ||
let res = self.misc_cast(&src, cast_ty)?; | ||
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. Please add a FIXME here indicating that we shouldn't have a single 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. I can do that once this get's merged. 👍 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. Please add the FIXME now, even if you plan to fix it immediately in a follow-up. :) 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. But I already did :D 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. Ah good, I misunderstood your comment then. :) |
||
self.write_immediate(res, dest)?; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,7 +557,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { | |
} | ||
Rvalue::Cast(kind, operand, target_type) => { | ||
match kind { | ||
CastKind::Misc => { | ||
CastKind::DynStar => { | ||
// FIXME(dyn-star): make sure nothing needs to be done here. | ||
} | ||
// Nothing to check here | ||
CastKind::PointerFromExposedAddress | ||
| CastKind::PointerExposeAddress | ||
| CastKind::Pointer(_) => {} | ||
_ => { | ||
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. We should check that the types are as expected here (leaving out 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. I am not sure what to check 😅 , with new function 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. Yes, because MIR validation doesn't just run after MIR is built, but also after transformations that modify it 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. I think I modified those too, but it's better to be safe than sorry will add the checks in the next PR. |
||
let op_ty = operand.ty(self.body, self.tcx); | ||
if op_ty.is_enum() { | ||
self.fail( | ||
|
@@ -568,13 +575,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { | |
); | ||
} | ||
} | ||
CastKind::DynStar => { | ||
// FIXME(dyn-star): make sure nothing needs to be done here. | ||
} | ||
// Nothing to check here | ||
CastKind::PointerFromExposedAddress | ||
| CastKind::PointerExposeAddress | ||
| CastKind::Pointer(_) => {} | ||
} | ||
} | ||
Rvalue::Repeat(_, _) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1149,8 +1149,12 @@ pub enum CastKind { | |
Pointer(PointerCast), | ||
/// Cast into a dyn* object. | ||
DynStar, | ||
/// Remaining unclassified casts. | ||
Misc, | ||
IntToInt, | ||
FloatToInt, | ||
FloatToFloat, | ||
IntToFloat, | ||
PtrToPtr, | ||
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. Non-blocking request from the peanut gallery: It's not obvious to me how 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. "FIXME: 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. I haven't investigated the behavior of (_, _) => CastKind::Misc, |
||
FnPtrToPtr, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] | ||
|
Uh oh!
There was an error while loading. Please reload this page.