summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_build/src/build
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_mir_build/src/build
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_mir_build/src/build')
-rw-r--r--compiler/rustc_mir_build/src/build/custom/mod.rs6
-rw-r--r--compiler/rustc_mir_build/src/build/custom/parse/instruction.rs4
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_constant.rs6
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_place.rs24
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_rvalue.rs19
-rw-r--r--compiler/rustc_mir_build/src/build/expr/category.rs5
-rw-r--r--compiler/rustc_mir_build/src/build/expr/into.rs13
-rw-r--r--compiler/rustc_mir_build/src/build/expr/stmt.rs7
-rw-r--r--compiler/rustc_mir_build/src/build/matches/mod.rs5
-rw-r--r--compiler/rustc_mir_build/src/build/matches/test.rs24
-rw-r--r--compiler/rustc_mir_build/src/build/mod.rs23
-rw-r--r--compiler/rustc_mir_build/src/build/scope.rs3
12 files changed, 86 insertions, 53 deletions
diff --git a/compiler/rustc_mir_build/src/build/custom/mod.rs b/compiler/rustc_mir_build/src/build/custom/mod.rs
index 32c618828..e5c2cc6c7 100644
--- a/compiler/rustc_mir_build/src/build/custom/mod.rs
+++ b/compiler/rustc_mir_build/src/build/custom/mod.rs
@@ -118,7 +118,11 @@ fn parse_attribute(attr: &Attribute) -> MirPhase {
phase = Some(value);
}
other => {
- panic!("Unexpected key {}", other);
+ span_bug!(
+ nested.span(),
+ "Unexpected key while parsing custom_mir attribute: '{}'",
+ other
+ );
}
}
}
diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs
index ebf830cb9..4cb9d7bab 100644
--- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs
+++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs
@@ -128,7 +128,9 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
destination,
target: Some(target),
unwind: UnwindAction::Continue,
- from_hir_call: *from_hir_call,
+ call_source: if *from_hir_call { CallSource::Normal } else {
+ CallSource::OverloadedOperator
+ },
fn_span: *fn_span,
})
},
diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs
index 4d99ab4b0..3fe751ae0 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs
@@ -52,7 +52,7 @@ pub fn as_constant_inner<'tcx>(
match lit_to_mir_constant(tcx, LitToConstInput { lit: &lit.node, ty, neg }) {
Ok(c) => c,
Err(LitToConstError::Reported(guar)) => {
- ConstantKind::Ty(tcx.const_error(ty, guar))
+ ConstantKind::Ty(ty::Const::new_error(tcx, guar, ty))
}
Err(LitToConstError::TypeError) => {
bug!("encountered type error in `lit_to_mir_constant`")
@@ -84,7 +84,7 @@ pub fn as_constant_inner<'tcx>(
Constant { user_ty, span, literal }
}
ExprKind::ConstParam { param, def_id: _ } => {
- let const_param = tcx.mk_const(ty::ConstKind::Param(param), expr.ty);
+ let const_param = ty::Const::new_param(tcx, param, expr.ty);
let literal = ConstantKind::Ty(const_param);
Constant { user_ty: None, span, literal }
@@ -106,7 +106,7 @@ pub fn as_constant_inner<'tcx>(
}
#[instrument(skip(tcx, lit_input))]
-pub(crate) fn lit_to_mir_constant<'tcx>(
+fn lit_to_mir_constant<'tcx>(
tcx: TyCtxt<'tcx>,
lit_input: LitToConstInput<'tcx>,
) -> Result<ConstantKind<'tcx>, LitToConstError> {
diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs
index 7ec57add6..60acd279f 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_place.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs
@@ -535,7 +535,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Cast { .. }
| ExprKind::Use { .. }
| ExprKind::NeverToAny { .. }
- | ExprKind::Pointer { .. }
+ | ExprKind::PointerCoercion { .. }
| ExprKind::Repeat { .. }
| ExprKind::Borrow { .. }
| ExprKind::AddressOf { .. }
@@ -549,6 +549,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Break { .. }
| ExprKind::Continue { .. }
| ExprKind::Return { .. }
+ | ExprKind::Become { .. }
| ExprKind::Literal { .. }
| ExprKind::NamedConst { .. }
| ExprKind::NonHirLiteral { .. }
@@ -677,21 +678,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// check that we just did stays valid. Since we can't assign to
// unsized values, we only need to ensure that none of the
// pointers in the base place are modified.
- for (idx, elem) in base_place.projection.iter().enumerate().rev() {
+ for (base_place, elem) in base_place.iter_projections().rev() {
match elem {
ProjectionElem::Deref => {
- let fake_borrow_deref_ty = Place::ty_from(
- base_place.local,
- &base_place.projection[..idx],
- &self.local_decls,
- tcx,
- )
- .ty;
+ let fake_borrow_deref_ty = base_place.ty(&self.local_decls, tcx).ty;
let fake_borrow_ty =
- tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
+ Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, fake_borrow_deref_ty);
let fake_borrow_temp =
self.local_decls.push(LocalDecl::new(fake_borrow_ty, expr_span));
- let projection = tcx.mk_place_elems(&base_place.projection[..idx]);
+ let projection = tcx.mk_place_elems(&base_place.projection);
self.cfg.push_assign(
block,
source_info,
@@ -705,12 +700,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fake_borrow_temps.push(fake_borrow_temp);
}
ProjectionElem::Index(_) => {
- let index_ty = Place::ty_from(
- base_place.local,
- &base_place.projection[..idx],
- &self.local_decls,
- tcx,
- );
+ let index_ty = base_place.ty(&self.local_decls, tcx);
match index_ty.ty.kind() {
// The previous index expression has already
// done any index expressions needed here.
diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
index 3742d640e..32ffb990b 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
@@ -162,7 +162,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
[],
expr_span,
);
- let storage = this.temp(tcx.mk_mut_ptr(tcx.types.u8), expr_span);
+ let storage = this.temp(Ty::new_mut_ptr(tcx, tcx.types.u8), expr_span);
let success = this.cfg.start_new_block();
this.cfg.terminate(
block,
@@ -173,7 +173,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
destination: storage,
target: Some(success),
unwind: UnwindAction::Continue,
- from_hir_call: false,
+ call_source: CallSource::Misc,
fn_span: expr_span,
},
);
@@ -300,7 +300,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let cast_kind = mir_cast_kind(ty, expr.ty);
block.and(Rvalue::Cast(cast_kind, source, expr.ty))
}
- ExprKind::Pointer { cast, source } => {
+ ExprKind::PointerCoercion { cast, source } => {
let source = unpack!(
block = this.as_operand(
block,
@@ -310,7 +310,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
NeedsTemporary::No
)
);
- block.and(Rvalue::Cast(CastKind::Pointer(cast), source, expr.ty))
+ block.and(Rvalue::Cast(CastKind::PointerCoercion(cast), source, expr.ty))
}
ExprKind::Array { ref fields } => {
// (*) We would (maybe) be closer to codegen if we
@@ -442,7 +442,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
match upvar.kind {
ExprKind::Borrow {
borrow_kind:
- BorrowKind::Mut { allow_two_phase_borrow: false },
+ BorrowKind::Mut { kind: MutBorrowKind::Default },
arg,
} => unpack!(
block = this.limit_capture_mutability(
@@ -532,6 +532,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Break { .. }
| ExprKind::Continue { .. }
| ExprKind::Return { .. }
+ | ExprKind::Become { .. }
| ExprKind::InlineAsm { .. }
| ExprKind::PlaceTypeAscription { .. }
| ExprKind::ValueTypeAscription { .. } => {
@@ -563,7 +564,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let bool_ty = self.tcx.types.bool;
let rvalue = match op {
BinOp::Add | BinOp::Sub | BinOp::Mul if self.check_overflow && ty.is_integral() => {
- let result_tup = self.tcx.mk_tup(&[ty, bool_ty]);
+ let result_tup = Ty::new_tup(self.tcx, &[ty, bool_ty]);
let result_value = self.temp(result_tup, span);
self.cfg.push_assign(
@@ -597,7 +598,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let (unsigned_rhs, unsigned_ty) = match rhs_ty.kind() {
ty::Uint(_) => (rhs.to_copy(), rhs_ty),
ty::Int(int_width) => {
- let uint_ty = self.tcx.mk_mach_uint(int_width.to_unsigned());
+ let uint_ty = Ty::new_uint(self.tcx, int_width.to_unsigned());
let rhs_temp = self.temp(uint_ty, span);
self.cfg.push_assign(
block,
@@ -795,8 +796,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
};
let borrow_kind = match mutability {
- Mutability::Not => BorrowKind::Unique,
- Mutability::Mut => BorrowKind::Mut { allow_two_phase_borrow: false },
+ Mutability::Not => BorrowKind::Mut { kind: MutBorrowKind::ClosureCapture },
+ Mutability::Mut => BorrowKind::Mut { kind: MutBorrowKind::Default },
};
let arg_place = arg_place_builder.to_place(this);
diff --git a/compiler/rustc_mir_build/src/build/expr/category.rs b/compiler/rustc_mir_build/src/build/expr/category.rs
index d9aa461c1..e07ba6b6e 100644
--- a/compiler/rustc_mir_build/src/build/expr/category.rs
+++ b/compiler/rustc_mir_build/src/build/expr/category.rs
@@ -63,7 +63,7 @@ impl Category {
| ExprKind::Binary { .. }
| ExprKind::Box { .. }
| ExprKind::Cast { .. }
- | ExprKind::Pointer { .. }
+ | ExprKind::PointerCoercion { .. }
| ExprKind::Repeat { .. }
| ExprKind::Assign { .. }
| ExprKind::AssignOp { .. }
@@ -82,7 +82,8 @@ impl Category {
| ExprKind::Block { .. }
| ExprKind::Break { .. }
| ExprKind::Continue { .. }
- | ExprKind::Return { .. } =>
+ | ExprKind::Return { .. }
+ | ExprKind::Become { .. } =>
// FIXME(#27840) these probably want their own
// category, like "nonterminating"
{
diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs
index 29ff916d2..e30fdcbbe 100644
--- a/compiler/rustc_mir_build/src/build/expr/into.rs
+++ b/compiler/rustc_mir_build/src/build/expr/into.rs
@@ -277,7 +277,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.ty
.is_inhabited_from(this.tcx, this.parent_module, this.param_env)
.then_some(success),
- from_hir_call,
+ call_source: if from_hir_call {
+ CallSource::Normal
+ } else {
+ CallSource::OverloadedOperator
+ },
fn_span,
},
);
@@ -489,7 +493,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block.unit()
}
- ExprKind::Continue { .. } | ExprKind::Break { .. } | ExprKind::Return { .. } => {
+ ExprKind::Continue { .. }
+ | ExprKind::Break { .. }
+ | ExprKind::Return { .. }
+ | ExprKind::Become { .. } => {
unpack!(block = this.stmt_expr(block, expr, None));
// No assign, as these have type `!`.
block.unit()
@@ -549,7 +556,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Binary { .. }
| ExprKind::Box { .. }
| ExprKind::Cast { .. }
- | ExprKind::Pointer { .. }
+ | ExprKind::PointerCoercion { .. }
| ExprKind::Repeat { .. }
| ExprKind::Array { .. }
| ExprKind::Tuple { .. }
diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs
index ea5aeb67d..396f82c27 100644
--- a/compiler/rustc_mir_build/src/build/expr/stmt.rs
+++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs
@@ -99,6 +99,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
BreakableTarget::Return,
source_info,
),
+ // FIXME(explicit_tail_calls): properly lower tail calls here
+ ExprKind::Become { value } => this.break_scope(
+ block,
+ Some(&this.thir[value]),
+ BreakableTarget::Return,
+ source_info,
+ ),
_ => {
assert!(
statement_scope.is_some(),
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index 6df06df5c..10770213c 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -1751,7 +1751,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
projection: tcx.mk_place_elems(matched_place_ref.projection),
};
let fake_borrow_deref_ty = matched_place.ty(&self.local_decls, tcx).ty;
- let fake_borrow_ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
+ let fake_borrow_ty =
+ Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, fake_borrow_deref_ty);
let mut fake_borrow_temp = LocalDecl::new(fake_borrow_ty, temp_span);
fake_borrow_temp.internal = self.local_decls[matched_place.local].internal;
fake_borrow_temp.local_info = ClearCrossCrate::Set(Box::new(LocalInfo::FakeBorrow));
@@ -2250,7 +2251,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// This variable isn't mutated but has a name, so has to be
// immutable to avoid the unused mut lint.
mutability: Mutability::Not,
- ty: tcx.mk_imm_ref(tcx.lifetimes.re_erased, var_ty),
+ ty: Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, var_ty),
user_ty: None,
source_info,
internal: false,
diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs
index dbdb5b4a9..e6806177d 100644
--- a/compiler/rustc_mir_build/src/build/matches/test.rs
+++ b/compiler/rustc_mir_build/src/build/matches/test.rs
@@ -16,7 +16,7 @@ use rustc_middle::mir::*;
use rustc_middle::thir::*;
use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::GenericArg;
-use rustc_middle::ty::{self, adjustment::PointerCast, Ty, TyCtxt};
+use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt};
use rustc_span::def_id::DefId;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
@@ -244,8 +244,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
bug!("matching on `String` went through without enabling string_deref_patterns");
}
let re_erased = tcx.lifetimes.re_erased;
- let ref_string = self.temp(tcx.mk_imm_ref(re_erased, ty), test.span);
- let ref_str_ty = tcx.mk_imm_ref(re_erased, tcx.types.str_);
+ let ref_string = self.temp(Ty::new_imm_ref(tcx,re_erased, ty), test.span);
+ let ref_str_ty = Ty::new_imm_ref(tcx,re_erased, tcx.types.str_);
let ref_str = self.temp(ref_str_ty, test.span);
let deref = tcx.require_lang_item(LangItem::Deref, None);
let method = trait_method(tcx, deref, sym::deref, [ty]);
@@ -264,7 +264,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
destination: ref_str,
target: Some(eq_block),
unwind: UnwindAction::Continue,
- from_hir_call: false,
+ call_source: CallSource::Misc,
fn_span: source_info.span
}
);
@@ -415,7 +415,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
(Some((region, elem_ty, _)), _) | (None, Some((region, elem_ty, _))) => {
let tcx = self.tcx;
// make both a slice
- ty = tcx.mk_imm_ref(*region, tcx.mk_slice(*elem_ty));
+ ty = Ty::new_imm_ref(tcx, *region, Ty::new_slice(tcx, *elem_ty));
if opt_ref_ty.is_some() {
let temp = self.temp(ty, source_info.span);
self.cfg.push_assign(
@@ -423,7 +423,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
source_info,
temp,
Rvalue::Cast(
- CastKind::Pointer(PointerCast::Unsize),
+ CastKind::PointerCoercion(PointerCoercion::Unsize),
Operand::Copy(val),
ty,
),
@@ -436,7 +436,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block,
source_info,
slice,
- Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), expect, ty),
+ Rvalue::Cast(
+ CastKind::PointerCoercion(PointerCoercion::Unsize),
+ expect,
+ ty,
+ ),
);
expect = Operand::Move(slice);
}
@@ -449,7 +453,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// non_scalar_compare called on non-reference type
let temp = self.temp(ty, source_info.span);
self.cfg.push_assign(block, source_info, temp, Rvalue::Use(expect));
- let ref_ty = self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, ty);
+ let ref_ty = Ty::new_imm_ref(self.tcx, self.tcx.lifetimes.re_erased, ty);
let ref_temp = self.temp(ref_ty, source_info.span);
self.cfg.push_assign(
@@ -496,7 +500,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
destination: eq_result,
target: Some(eq_block),
unwind: UnwindAction::Continue,
- from_hir_call: false,
+ call_source: CallSource::MatchCmp,
fn_span: source_info.span,
},
);
@@ -871,7 +875,7 @@ fn trait_method<'tcx>(
.find(|item| item.kind == ty::AssocKind::Fn)
.expect("trait method not found");
- let method_ty = tcx.mk_fn_def(item.def_id, substs);
+ let method_ty = Ty::new_fn_def(tcx, item.def_id, substs);
ConstantKind::zero_sized(method_ty)
}
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs
index 4e3e98b56..d828e71c7 100644
--- a/compiler/rustc_mir_build/src/build/mod.rs
+++ b/compiler/rustc_mir_build/src/build/mod.rs
@@ -1,4 +1,3 @@
-pub(crate) use crate::build::expr::as_constant::lit_to_mir_constant;
use crate::build::expr::as_place::PlaceBuilder;
use crate::build::scope::DropKind;
use rustc_apfloat::ieee::{Double, Single};
@@ -37,6 +36,22 @@ pub(crate) fn mir_built(
tcx.alloc_steal_mir(mir_build(tcx, def))
}
+pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
+ tcx: TyCtxt<'tcx>,
+ def_id: LocalDefId,
+) -> IndexVec<FieldIdx, Symbol> {
+ tcx.closure_captures(def_id)
+ .iter()
+ .map(|captured_place| {
+ let name = captured_place.to_symbol();
+ match captured_place.info.capture_kind {
+ ty::UpvarCapture::ByValue => name,
+ ty::UpvarCapture::ByRef(..) => Symbol::intern(&format!("_ref__{name}")),
+ }
+ })
+ .collect()
+}
+
/// Construct the MIR for a given `DefId`.
fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
// Ensure unsafeck and abstract const building is ran before we steal the THIR.
@@ -557,7 +572,7 @@ fn construct_const<'a, 'tcx>(
span,
..
}) => (*span, ty.span),
- Node::AnonConst(_) => {
+ Node::AnonConst(_) | Node::ConstBlock(_) => {
let span = tcx.def_span(def);
(span, span)
}
@@ -599,7 +614,7 @@ fn construct_error(tcx: TyCtxt<'_>, def: LocalDefId, err: ErrorGuaranteed) -> Bo
let generator_kind = tcx.generator_kind(def);
let body_owner_kind = tcx.hir().body_owner_kind(def);
- let ty = tcx.ty_error(err);
+ let ty = Ty::new_error(tcx, err);
let num_params = match body_owner_kind {
hir::BodyOwnerKind::Fn => tcx.fn_sig(def).skip_binder().inputs().skip_binder().len(),
hir::BodyOwnerKind::Closure => {
@@ -927,7 +942,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
match self.unit_temp {
Some(tmp) => tmp,
None => {
- let ty = self.tcx.mk_unit();
+ let ty = Ty::new_unit(self.tcx);
let fn_span = self.fn_span;
let tmp = self.temp(ty, fn_span);
self.unit_temp = Some(tmp);
diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs
index 7c0fbc6f8..72374102c 100644
--- a/compiler/rustc_mir_build/src/build/scope.rs
+++ b/compiler/rustc_mir_build/src/build/scope.rs
@@ -91,6 +91,7 @@ use rustc_middle::middle::region;
use rustc_middle::mir::*;
use rustc_middle::thir::{Expr, LintLevel};
+use rustc_middle::ty::Ty;
use rustc_span::{Span, DUMMY_SP};
#[derive(Debug)]
@@ -724,7 +725,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Add a dummy `Assign` statement to the CFG, with the span for the source code's `continue`
// statement.
fn add_dummy_assignment(&mut self, span: Span, block: BasicBlock, source_info: SourceInfo) {
- let local_decl = LocalDecl::new(self.tcx.mk_unit(), span).internal();
+ let local_decl = LocalDecl::new(Ty::new_unit(self.tcx), span).internal();
let temp_place = Place::from(self.local_decls.push(local_decl));
self.cfg.push_assign_unit(block, source_info, temp_place, self.tcx);
}