1
Fork 0

Introduce a no-op PlaceMention statement for let _ =.

This commit is contained in:
Camille GILLOT 2022-09-06 18:41:01 +02:00
parent be758ef5ab
commit 4462bb54e3
44 changed files with 139 additions and 20 deletions

View file

@ -90,6 +90,17 @@ impl<'tcx> CFG<'tcx> {
self.push(block, stmt);
}
pub(crate) fn push_place_mention(
&mut self,
block: BasicBlock,
source_info: SourceInfo,
place: Place<'tcx>,
) {
let kind = StatementKind::PlaceMention(Box::new(place));
let stmt = Statement { source_info, kind };
self.push(block, stmt);
}
pub(crate) fn terminate(
&mut self,
block: BasicBlock,

View file

@ -556,6 +556,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
_ => {
let place_builder = unpack!(block = self.as_place_builder(block, initializer));
if let Some(place) = place_builder.try_to_place(self) {
let source_info = self.source_info(initializer.span);
self.cfg.push_place_mention(block, source_info, place);
}
self.place_into_pattern(block, &irrefutable_pat, place_builder, true)
}
}
@ -576,6 +582,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
false,
&mut [&mut candidate],
);
// For matches and function arguments, the place that is being matched
// can be set when creating the variables. But the place for
// let PATTERN = ... might not even exist until we do the assignment.