8000 clarify const_prop ICE protection comment by RalfJung · Pull Request #65592 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

clarify const_prop ICE protection comment #65592

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

Merged
merged 2 commits into from
Oct 21, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
skip all refs-to-uninit-local, not just arguments
  • Loading branch information
RalfJung committed Oct 20, 2019
commit f907fbe1a6676a26cfc893b78f0fffb4285f1e6c
11 changes: 6 additions & 5 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,19 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// local. There's nothing it can do here: taking a reference needs an allocation
// which needs to know the size. Normally that's okay as during execution
// (e.g. for CTFE) it can never happen. But here in const_prop
// we leave function arguments uninitialized, so if one of these is unsized
// unknown data is uninitialized, so if e.g. a function argument is unsized
// and has a reference taken, we get an ICE.
Rvalue::Ref(_, _, Place { base: PlaceBase::Local(local), projection: box [] }) => {
trace!("checking Ref({:?})", place);
let alive =
if let LocalValue::Live(_) = self.ecx.frame().locals[*local].value {
true
} else { false };
} else {
false
};

// local 0 is the return place; locals 1..=arg_count are the arguments.
if local.as_usize() <= self.ecx.frame().body.arg_count && !alive {
trace!("skipping Ref({:?})", place);
if !alive {
trace!("skipping Ref({:?}) to uninitialized local", place);
return None;
}
}
Expand Down
0