Skip to content

Commit

Permalink
Auto merge of rust-lang#96098 - JakobDegen:always-return-place, r=oli…
Browse files Browse the repository at this point in the history
…-obk

Refactor call terminator to always include destination place

In rust-lang#71117 people seemed to agree that call terminators should always have a destination place, even if the call was guaranteed to diverge. This implements that. Unsurprisingly, the diff touches a lot of code, but thankfully I had to do almost nothing interesting. The only interesting thing came up in const prop, where the stack frame having no return place was also used to indicate that the layout could not be computed (or similar). I replaced this with a ZST allocation, which should continue to do the right things.

cc `@RalfJung` `@eddyb` who were involved in the original conversation

r? rust-lang/mir-opt
  • Loading branch information
bors committed May 24, 2022
2 parents 1f3116f + 0684d62 commit 286b717
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn is_call_with_ref_arg<'tcx>(
if let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].ty(&*mir, cx.tcx));
if !is_copy(cx, inner_ty);
then {
Some((def_id, *local, inner_ty, destination.as_ref().map(|(dest, _)| dest)?.as_local()?))
Some((def_id, *local, inner_ty, destination.as_local()?))
} else {
None
}
Expand Down Expand Up @@ -584,7 +584,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Location) {
if let mir::TerminatorKind::Call {
args,
destination: Some((mir::Place { local: dest, .. }, _)),
destination: mir::Place { local: dest, .. },
..
} = &terminator.kind
{
Expand Down
1 change: 1 addition & 0 deletions clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ fn check_terminator<'a, 'tcx>(
args,
from_hir_call: _,
destination: _,
target: _,
cleanup: _,
fn_span: _,
} => {
Expand Down

0 comments on commit 286b717

Please sign in to comment.