diff options
| author | Jakob Degen <jakob.e.degen@gmail.com> | 2022-04-16 09:27:54 -0400 |
|---|---|---|
| committer | Jakob Degen <jakob.e.degen@gmail.com> | 2022-05-23 17:49:04 -0400 |
| commit | 09b0936db2bb3be67451c6f8948e90987e764f81 (patch) | |
| tree | 33c3a24a12791982173c389fabd5d317223beb9a /compiler/rustc_const_eval/src/transform | |
| parent | 222c5724ecc922fe67815f428c19f82c129d9386 (diff) | |
| download | rust-09b0936db2bb3be67451c6f8948e90987e764f81.tar.gz rust-09b0936db2bb3be67451c6f8948e90987e764f81.zip | |
Refactor call terminator to always hold a destination place
Diffstat (limited to 'compiler/rustc_const_eval/src/transform')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/promote_consts.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 8 |
2 files changed, 9 insertions, 12 deletions
diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs index f88538f61ec..fc6b8a1a723 100644 --- a/compiler/rustc_const_eval/src/transform/promote_consts.rs +++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs @@ -788,7 +788,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { } else { let terminator = self.source[loc.block].terminator_mut(); let target = match terminator.kind { - TerminatorKind::Call { destination: Some((_, target)), .. } => target, + TerminatorKind::Call { target: Some(target), .. } => target, ref kind => { span_bug!(terminator.source_info.span, "{:?} not promotable", kind); } @@ -814,7 +814,8 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { func, args, cleanup: None, - destination: Some((Place::from(new_temp), new_target)), + destination: Place::from(new_temp), + target: Some(new_target), from_hir_call, fn_span, }, @@ -1054,11 +1055,9 @@ pub fn is_const_fn_in_array_repeat_expression<'tcx>( { if let Operand::Constant(box Constant { literal, .. }) = func { if let ty::FnDef(def_id, _) = *literal.ty().kind() { - if let Some((destination_place, _)) = destination { - if destination_place == place { - if ccx.tcx.is_const_fn(def_id) { - return true; - } + if destination == place { + if ccx.tcx.is_const_fn(def_id) { + return true; } } } diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 3ce33d547c5..54c2daf9ac2 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -673,7 +673,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { self.check_edge(location, *unwind, EdgeKind::Unwind); } } - TerminatorKind::Call { func, args, destination, cleanup, .. } => { + TerminatorKind::Call { func, args, destination, target, cleanup, .. } => { let func_ty = func.ty(&self.body.local_decls, self.tcx); match func_ty.kind() { ty::FnPtr(..) | ty::FnDef(..) => {} @@ -682,7 +682,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { format!("encountered non-callable type {} in `Call` terminator", func_ty), ), } - if let Some((_, target)) = destination { + if let Some(target) = target { self.check_edge(location, *target, EdgeKind::Normal); } if let Some(cleanup) = cleanup { @@ -693,9 +693,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { // passed by a reference to the callee. Consequently they must be non-overlapping. // Currently this simply checks for duplicate places. self.place_cache.clear(); - if let Some((destination, _)) = destination { - self.place_cache.push(destination.as_ref()); - } + self.place_cache.push(destination.as_ref()); for arg in args { if let Operand::Move(place) = arg { self.place_cache.push(place.as_ref()); |
