mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
ConstProp: Remove const when rvalue check fails.
This commit is contained in:
parent
b1a6cf4a0e
commit
9121a41450
@ -439,6 +439,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
|
||||
// FIXME we need to revisit this for #67176
|
||||
if rvalue.has_param() {
|
||||
trace!("skipping, has param");
|
||||
return None;
|
||||
}
|
||||
if !rvalue
|
||||
@ -707,7 +708,11 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||
fn visit_assign(&mut self, place: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) {
|
||||
self.super_assign(place, rvalue, location);
|
||||
|
||||
let Some(()) = self.check_rvalue(rvalue) else { return };
|
||||
let Some(()) = self.check_rvalue(rvalue) else {
|
||||
trace!("rvalue check failed, removing const");
|
||||
Self::remove_const(&mut self.ecx, place.local);
|
||||
return;
|
||||
};
|
||||
|
||||
match self.ecx.machine.can_const_prop[place.local] {
|
||||
// Do nothing if the place is indirect.
|
||||
|
@ -12,8 +12,7 @@
|
||||
StorageLive(_1);
|
||||
_1 = const 0_usize;
|
||||
_1 = const _;
|
||||
- _0 = _1;
|
||||
+ _0 = const 0_usize;
|
||||
_0 = _1;
|
||||
StorageDead(_1);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user