Skip to content

Commit 5c3a0e9

Browse files
committed
Auto merge of #116427 - cjgillot:no-internal, r=oli-obk
Remove mir::LocalDecl::internal. It does not serve any purpose, as we don't have typeck-based generator witnesses any more.
2 parents e293927 + e63d19c commit 5c3a0e9

File tree

38 files changed

+106
-57
lines changed

38 files changed

+106
-57
lines changed

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
237237
if self.const_kind() == hir::ConstContext::ConstFn {
238238
for (idx, local) in body.local_decls.iter_enumerated() {
239239
// Handle the return place below.
240-
if idx == RETURN_PLACE || local.internal {
240+
if idx == RETURN_PLACE {
241241
continue;
242242
}
243243

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -830,22 +830,6 @@ pub struct LocalDecl<'tcx> {
830830
// FIXME(matthewjasper) Don't store in this in `Body`
831831
pub local_info: ClearCrossCrate<Box<LocalInfo<'tcx>>>,
832832

833-
/// `true` if this is an internal local.
834-
///
835-
/// These locals are not based on types in the source code and are only used
836-
/// for a few desugarings at the moment.
837-
///
838-
/// The generator transformation will sanity check the locals which are live
839-
/// across a suspension point against the type components of the generator
840-
/// which type checking knows are live across a suspension point. We need to
841-
/// flag drop flags to avoid triggering this check as they are introduced
842-
/// outside of type inference.
843-
///
844-
/// This should be sound because the drop flags are fully algebraic, and
845-
/// therefore don't affect the auto-trait or outlives properties of the
846-
/// generator.
847-
pub internal: bool,
848-
849833
/// The type of this local.
850834
pub ty: Ty<'tcx>,
851835

@@ -1058,7 +1042,7 @@ impl<'tcx> LocalDecl<'tcx> {
10581042
self.source_info.span.desugaring_kind().is_some()
10591043
}
10601044

1061-
/// Creates a new `LocalDecl` for a temporary: mutable, non-internal.
1045+
/// Creates a new `LocalDecl` for a temporary, mutable.
10621046
#[inline]
10631047
pub fn new(ty: Ty<'tcx>, span: Span) -> Self {
10641048
Self::with_source_info(ty, SourceInfo::outermost(span))
@@ -1070,20 +1054,12 @@ impl<'tcx> LocalDecl<'tcx> {
10701054
LocalDecl {
10711055
mutability: Mutability::Mut,
10721056
local_info: ClearCrossCrate::Set(Box::new(LocalInfo::Boring)),
1073-
internal: false,
10741057
ty,
10751058
user_ty: None,
10761059
source_info,
10771060
}
10781061
}
10791062

1080-
/// Converts `self` into same `LocalDecl` except tagged as internal.
1081-
#[inline]
1082-
pub fn internal(mut self) -> Self {
1083-
self.internal = true;
1084-
self
1085-
}
1086-
10871063
/// Converts `self` into same `LocalDecl` except tagged as immutable.
10881064
#[inline]
10891065
pub fn immutable(mut self) -> Self {

compiler/rustc_middle/src/mir/patch.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ impl<'tcx> MirPatch<'tcx> {
127127
Location { block: bb, statement_index: offset }
128128
}
129129

130-
pub fn new_internal_with_info(
130+
pub fn new_local_with_info(
131131
&mut self,
132132
ty: Ty<'tcx>,
133133
span: Span,
134134
local_info: LocalInfo<'tcx>,
135135
) -> Local {
136136
let index = self.next_local;
137137
self.next_local += 1;
138-
let mut new_decl = LocalDecl::new(ty, span).internal();
138+
let mut new_decl = LocalDecl::new(ty, span);
139139
**new_decl.local_info.as_mut().assert_crate_local() = local_info;
140140
self.new_locals.push(new_decl);
141141
Local::new(index)
@@ -148,13 +148,6 @@ impl<'tcx> MirPatch<'tcx> {
148148
Local::new(index)
149149
}
150150

151-
pub fn new_internal(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
152-
let index = self.next_local;
153-
self.next_local += 1;
154-
self.new_locals.push(LocalDecl::new(ty, span).internal());
155-
Local::new(index)
156-
}
157-
158151
pub fn new_block(&mut self, data: BasicBlockData<'tcx>) -> BasicBlock {
159152
let block = BasicBlock::new(self.patch_map.len());
160153
debug!("MirPatch: new_block: {:?}: {:?}", block, data);

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@ macro_rules! make_mir_visitor {
815815
ty,
816816
user_ty,
817817
source_info,
818-
internal: _,
819818
local_info: _,
820819
} = local_decl;
821820

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
183183
// The `Box<T>` temporary created here is not a part of the HIR,
184184
// and therefore is not considered during generator auto-trait
185185
// determination. See the comment about `box` at `yield_in_scope`.
186-
let result = this.local_decls.push(LocalDecl::new(expr.ty, expr_span).internal());
186+
let result = this.local_decls.push(LocalDecl::new(expr.ty, expr_span));
187187
this.cfg.push(
188188
block,
189189
Statement { source_info, kind: StatementKind::StorageLive(result) },

compiler/rustc_mir_build/src/build/expr/as_temp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5252
let local_info = match expr.kind {
5353
ExprKind::StaticRef { def_id, .. } => {
5454
assert!(!this.tcx.is_thread_local_static(def_id));
55-
local_decl.internal = true;
5655
LocalInfo::StaticRef { def_id, is_thread_local: false }
5756
}
5857
ExprKind::ThreadLocalRef(def_id) => {
5958
assert!(this.tcx.is_thread_local_static(def_id));
60-
local_decl.internal = true;
6159
LocalInfo::StaticRef { def_id, is_thread_local: true }
6260
}
6361
ExprKind::NamedConst { def_id, .. } | ExprKind::ConstParam { def_id, .. } => {

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17981798
let fake_borrow_ty =
17991799
Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, fake_borrow_deref_ty);
18001800
let mut fake_borrow_temp = LocalDecl::new(fake_borrow_ty, temp_span);
1801-
fake_borrow_temp.internal = self.local_decls[matched_place.local].internal;
18021801
fake_borrow_temp.local_info = ClearCrossCrate::Set(Box::new(LocalInfo::FakeBorrow));
18031802
let fake_borrow_temp = self.local_decls.push(fake_borrow_temp);
18041803

@@ -2268,7 +2267,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22682267
ty: var_ty,
22692268
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
22702269
source_info,
2271-
internal: false,
22722270
local_info: ClearCrossCrate::Set(Box::new(LocalInfo::User(BindingForm::Var(
22732271
VarBindingForm {
22742272
binding_mode,
@@ -2298,7 +2296,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22982296
ty: Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, var_ty),
22992297
user_ty: None,
23002298
source_info,
2301-
internal: false,
23022299
local_info: ClearCrossCrate::Set(Box::new(LocalInfo::User(
23032300
BindingForm::RefForGuard,
23042301
))),

compiler/rustc_mir_build/src/build/misc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1515
/// N.B., **No cleanup is scheduled for this temporary.** You should
1616
/// call `schedule_drop` once the temporary is initialized.
1717
pub(crate) fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
18-
// Mark this local as internal to avoid temporaries with types not present in the
19-
// user's code resulting in ICEs from the generator transform.
20-
let temp = self.local_decls.push(LocalDecl::new(ty, span).internal());
18+
let temp = self.local_decls.push(LocalDecl::new(ty, span));
2119
let place = Place::from(temp);
2220
debug!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty);
2321
place

compiler/rustc_mir_build/src/build/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
725725
// Add a dummy `Assign` statement to the CFG, with the span for the source code's `continue`
726726
// statement.
727727
fn add_dummy_assignment(&mut self, span: Span, block: BasicBlock, source_info: SourceInfo) {
728-
let local_decl = LocalDecl::new(Ty::new_unit(self.tcx), span).internal();
728+
let local_decl = LocalDecl::new(Ty::new_unit(self.tcx), span);
729729
let temp_place = Place::from(self.local_decls.push(local_decl));
730730
self.cfg.push_assign_unit(block, source_info, temp_place, self.tcx);
731731
}

compiler/rustc_mir_transform/src/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
179179
// Check the base local: it might be an unsafe-to-access static. We only check derefs of the
180180
// temporary holding the static pointer to avoid duplicate errors
181181
// <https://github.com/rust-lang/rust/pull/78068#issuecomment-731753506>.
182-
if decl.internal && place.projection.first() == Some(&ProjectionElem::Deref) {
182+
if place.projection.first() == Some(&ProjectionElem::Deref) {
183183
// If the projection root is an artificial local that we introduced when
184184
// desugaring `static`, give a more specific error message
185185
// (avoid the general "raw pointer" clause below, that would only be confusing).

0 commit comments

Comments
 (0)