Skip to content

Commit b16985a

Browse files
committed
Remove mir::StatementKind::EndRegion
Since lexical MIR borrow check is gone, and validation no longer uses these, they can be removed.
1 parent f37247f commit b16985a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+33
-1283
lines changed

src/librustc/ich/impls_mir.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,6 @@ for mir::StatementKind<'gcx> {
217217
mir::StatementKind::StorageDead(ref place) => {
218218
place.hash_stable(hcx, hasher);
219219
}
220-
mir::StatementKind::EndRegion(ref region_scope) => {
221-
region_scope.hash_stable(hcx, hasher);
222-
}
223220
mir::StatementKind::EscapeToRaw(ref place) => {
224221
place.hash_stable(hcx, hasher);
225222
}

src/librustc/mir/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use hir::def::CtorKind;
1616
use hir::def_id::DefId;
1717
use hir::{self, HirId, InlineAsm};
18-
use middle::region;
1918
use mir::interpret::{ConstValue, EvalErrorKind, Scalar};
2019
use mir::visit::MirVisitable;
2120
use rustc_apfloat::ieee::{Double, Single};
@@ -1789,10 +1788,6 @@ pub enum StatementKind<'tcx> {
17891788
/// for more details.
17901789
EscapeToRaw(Operand<'tcx>),
17911790

1792-
/// Mark one terminating point of a region scope (i.e. static region).
1793-
/// (The starting point(s) arise implicitly from borrows.)
1794-
EndRegion(region::Scope),
1795-
17961791
/// Encodes a user's type ascription. These need to be preserved
17971792
/// intact so that NLL can respect them. For example:
17981793
///
@@ -1846,8 +1841,6 @@ impl<'tcx> Debug for Statement<'tcx> {
18461841
match self.kind {
18471842
Assign(ref place, ref rv) => write!(fmt, "{:?} = {:?}", place, rv),
18481843
FakeRead(ref cause, ref place) => write!(fmt, "FakeRead({:?}, {:?})", cause, place),
1849-
// (reuse lifetime rendering policy from ppaux.)
1850-
EndRegion(ref ce) => write!(fmt, "EndRegion({})", ty::ReScope(*ce)),
18511844
Retag { fn_entry, ref place } =>
18521845
write!(fmt, "Retag({}{:?})", if fn_entry { "[fn entry] " } else { "" }, place),
18531846
EscapeToRaw(ref place) => write!(fmt, "EscapeToRaw({:?})", place),
@@ -3028,7 +3021,6 @@ EnumTypeFoldableImpl! {
30283021
(StatementKind::InlineAsm) { asm, outputs, inputs },
30293022
(StatementKind::Retag) { fn_entry, place },
30303023
(StatementKind::EscapeToRaw)(place),
3031-
(StatementKind::EndRegion)(a),
30323024
(StatementKind::AscribeUserType)(a, v, b),
30333025
(StatementKind::Nop),
30343026
}

src/librustc/mir/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ macro_rules! make_mir_visitor {
377377
location
378378
);
379379
}
380-
StatementKind::EndRegion(_) => {}
381380
StatementKind::SetDiscriminant{ ref $($mutability)* place, .. } => {
382381
self.visit_place(
383382
place,

src/librustc/session/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11491149
"when debug-printing compiler state, do not include spans"), // o/w tests have closure@path
11501150
identify_regions: bool = (false, parse_bool, [UNTRACKED],
11511151
"make unnamed regions display as '# (where # is some non-ident unique id)"),
1152-
emit_end_regions: bool = (false, parse_bool, [UNTRACKED],
1153-
"emit EndRegion as part of MIR; enable transforms that solely process EndRegion"),
11541152
borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
11551153
"select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"),
11561154
two_phase_borrows: bool = (false, parse_bool, [UNTRACKED],

src/librustc/ty/context.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,13 +1540,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15401540
}
15411541
}
15421542

1543-
/// Should we emit EndRegion MIR statements? These are consumed by
1544-
/// MIR borrowck, but not when NLL is used.
1545-
pub fn emit_end_regions(self) -> bool {
1546-
self.sess.opts.debugging_opts.emit_end_regions ||
1547-
self.use_mir_borrowck()
1548-
}
1549-
15501543
#[inline]
15511544
pub fn local_crate_exports_generics(self) -> bool {
15521545
debug_assert!(self.sess.opts.share_generics());

src/librustc_codegen_ssa/mir/statement.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
105105
bx
106106
}
107107
mir::StatementKind::FakeRead(..) |
108-
mir::StatementKind::EndRegion(..) |
109108
mir::StatementKind::Retag { .. } |
110109
mir::StatementKind::EscapeToRaw { .. } |
111110
mir::StatementKind::AscribeUserType(..) |

src/librustc_mir/borrow_check/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,6 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
592592
self.consume_operand(context, (input, span), flow_state);
593593
}
594594
}
595-
StatementKind::EndRegion(ref _rgn) => {
596-
// ignored when consuming results (update to
597-
// flow_state already handled).
598-
}
599595
StatementKind::Nop
600596
| StatementKind::AscribeUserType(..)
601597
| StatementKind::Retag { .. }

src/librustc_mir/borrow_check/nll/invalidation.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
132132
self.consume_operand(context, input);
133133
}
134134
}
135-
// EndRegion matters to older NLL/MIR AST borrowck, not to alias NLL
136-
StatementKind::EndRegion(..) |
137135
StatementKind::Nop |
138136
StatementKind::AscribeUserType(..) |
139137
StatementKind::Retag { .. } |

src/librustc_mir/borrow_check/nll/renumber.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use rustc::ty::subst::Substs;
1212
use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable};
13-
use rustc::mir::{BasicBlock, Location, Mir, Statement, StatementKind, UserTypeAnnotation};
13+
use rustc::mir::{Location, Mir, UserTypeAnnotation};
1414
use rustc::mir::visit::{MutVisitor, TyContext};
1515
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
1616

@@ -119,16 +119,4 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
119119

120120
debug!("visit_closure_substs: substs={:?}", substs);
121121
}
122-
123-
fn visit_statement(
124-
&mut self,
125-
block: BasicBlock,
126-
statement: &mut Statement<'tcx>,
127-
location: Location,
128-
) {
129-
if let StatementKind::EndRegion(_) = statement.kind {
130-
statement.kind = StatementKind::Nop;
131-
}
132-
self.super_statement(block, statement, location);
133-
}
134122
}

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,6 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
13141314
| StatementKind::StorageLive(..)
13151315
| StatementKind::StorageDead(..)
13161316
| StatementKind::InlineAsm { .. }
1317-
| StatementKind::EndRegion(_)
13181317
| StatementKind::Retag { .. }
13191318
| StatementKind::EscapeToRaw { .. }
13201319
| StatementKind::Nop => {}

src/librustc_mir/build/cfg.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
//! Routines for manipulating the control-flow graph.
1515
1616
use build::CFG;
17-
use rustc::middle::region;
1817
use rustc::mir::*;
19-
use rustc::ty::TyCtxt;
2018

2119
impl<'tcx> CFG<'tcx> {
2220
pub fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> {
@@ -45,30 +43,6 @@ impl<'tcx> CFG<'tcx> {
4543
self.block_data_mut(block).statements.push(statement);
4644
}
4745

48-
pub fn push_end_region<'a, 'gcx:'a+'tcx>(&mut self,
49-
tcx: TyCtxt<'a, 'gcx, 'tcx>,
50-
block: BasicBlock,
51-
source_info: SourceInfo,
52-
region_scope: region::Scope) {
53-
if tcx.emit_end_regions() {
54-
if let region::ScopeData::CallSite = region_scope.data {
55-
// The CallSite scope (aka the root scope) is sort of weird, in that it is
56-
// supposed to "separate" the "interior" and "exterior" of a closure. Being
57-
// that, it is not really a part of the region hierarchy, but for some
58-
// reason it *is* considered a part of it.
59-
//
60-
// It should die a hopefully painful death with NLL, so let's leave this hack
61-
// for now so that nobody can complain about soundness.
62-
return
63-
}
64-
65-
self.push(block, Statement {
66-
source_info,
67-
kind: StatementKind::EndRegion(region_scope),
68-
});
69-
}
70-
}
71-
7246
pub fn push_assign(&mut self,
7347
block: BasicBlock,
7448
source_info: SourceInfo,

src/librustc_mir/build/scope.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ should go to.
9090
use build::{BlockAnd, BlockAndExtension, Builder, CFG};
9191
use hair::LintLevel;
9292
use rustc::middle::region;
93-
use rustc::ty::{Ty, TyCtxt};
93+
use rustc::ty::Ty;
9494
use rustc::hir;
9595
use rustc::hir::def_id::LOCAL_CRATE;
9696
use rustc::mir::*;
@@ -381,7 +381,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
381381
let scope = self.scopes.pop().unwrap();
382382
assert_eq!(scope.region_scope, region_scope.0);
383383

384-
self.cfg.push_end_region(self.hir.tcx(), block, region_scope.1, scope.region_scope);
385384
let resume_block = self.resume_block();
386385
unpack!(block = build_scope_drops(&mut self.cfg,
387386
resume_block,
@@ -439,9 +438,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
439438
b
440439
};
441440

442-
// End all regions for scopes out of which we are breaking.
443-
self.cfg.push_end_region(self.hir.tcx(), block, region_scope.1, scope.region_scope);
444-
445441
unpack!(block = build_scope_drops(&mut self.cfg,
446442
resume_block,
447443
scope,
@@ -491,9 +487,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
491487
b
492488
};
493489

494-
// End all regions for scopes out of which we are breaking.
495-
self.cfg.push_end_region(self.hir.tcx(), block, src_info, scope.region_scope);
496-
497490
unpack!(block = build_scope_drops(&mut self.cfg,
498491
resume_block,
499492
scope,
@@ -790,7 +783,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
790783

791784
if scopes.iter().any(|scope| scope.needs_cleanup) {
792785
for scope in scopes.iter_mut() {
793-
target = build_diverge_scope(self.hir.tcx(), cfg, scope.region_scope_span,
786+
target = build_diverge_scope(cfg, scope.region_scope_span,
794787
scope, target, generator_drop);
795788
}
796789
}
@@ -950,8 +943,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
950943
block.unit()
951944
}
952945

953-
fn build_diverge_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
954-
cfg: &mut CFG<'tcx>,
946+
fn build_diverge_scope<'a, 'gcx, 'tcx>(cfg: &mut CFG<'tcx>,
955947
span: Span,
956948
scope: &mut Scope<'tcx>,
957949
mut target: BasicBlock,
@@ -1018,7 +1010,6 @@ fn build_diverge_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
10181010
cached_block
10191011
} else {
10201012
let block = cfg.start_new_cleanup_block();
1021-
cfg.push_end_region(tcx, block, source_info(span), scope.region_scope);
10221013
cfg.terminate(block, source_info(span), TerminatorKind::Goto { target });
10231014
*cached_block = Some(block);
10241015
block

src/librustc_mir/dataflow/impls/borrows.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
190190
}
191191

192192
/// Add all borrows to the kill set, if those borrows are out of scope at `location`.
193-
/// That means either they went out of either a nonlexical scope, if we care about those
194-
/// at the moment, or the location represents a lexical EndRegion
193+
/// That means they went out of a nonlexical scope
195194
fn kill_loans_out_of_scope_at_location(&self,
196195
sets: &mut BlockSets<BorrowIndex>,
197196
location: Location) {
@@ -252,9 +251,6 @@ impl<'a, 'gcx, 'tcx> BitDenotation for Borrows<'a, 'gcx, 'tcx> {
252251
});
253252

254253
match stmt.kind {
255-
mir::StatementKind::EndRegion(_) => {
256-
}
257-
258254
mir::StatementKind::Assign(ref lhs, ref rhs) => {
259255
// Make sure there are no remaining borrows for variables
260256
// that are assigned over.

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
301301
span_bug!(stmt.source_info.span,
302302
"SetDiscriminant should not exist during borrowck");
303303
}
304-
StatementKind::EndRegion(..) |
305304
StatementKind::Retag { .. } |
306305
StatementKind::EscapeToRaw { .. } |
307306
StatementKind::AscribeUserType(..) |

src/librustc_mir/interpret/step.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
129129
}
130130

131131
// Statements we do not track.
132-
EndRegion(..) => {}
133132
AscribeUserType(..) => {}
134133

135134
// Defined to do nothing. These are added by optimization passes, to avoid changing the

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
112112
StatementKind::SetDiscriminant { .. } |
113113
StatementKind::StorageLive(..) |
114114
StatementKind::StorageDead(..) |
115-
StatementKind::EndRegion(..) |
116115
StatementKind::Retag { .. } |
117116
StatementKind::EscapeToRaw { .. } |
118117
StatementKind::AscribeUserType(..) |

0 commit comments

Comments
 (0)