Skip to content

Commit 2b4675b

Browse files
committed
add Location::START const
1 parent fc6b2c5 commit 2b4675b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/librustc/mir/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,11 @@ impl fmt::Debug for Location {
19781978
}
19791979

19801980
impl Location {
1981+
pub const START: Location = Location {
1982+
block: START_BLOCK,
1983+
statement_index: 0,
1984+
};
1985+
19811986
/// Returns the location immediately after this one within the enclosing block.
19821987
///
19831988
/// Note that if this location represents a terminator, then the

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
112112
let anon_defn_ty = anon_defn_ty.subst(tcx, anon_decl.substs);
113113
let anon_defn_ty = renumber::renumber_regions(
114114
cx.infcx,
115-
TyContext::Location(start_position),
115+
TyContext::Location(Location::START),
116116
&anon_defn_ty,
117117
);
118118
debug!(
@@ -134,7 +134,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
134134
}).unwrap_or_else(|terr| {
135135
span_mirbug!(
136136
self,
137-
start_position,
137+
Location::START,
138138
"equate_inputs_and_outputs: `{:?}=={:?}` failed with `{:?}`",
139139
output_ty,
140140
mir_output_ty,

src/librustc_mir/transform/elaborate_drops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
550550
}
551551

552552
fn drop_flags_on_init(&mut self) {
553-
let loc = Location { block: START_BLOCK, statement_index: 0 };
553+
let loc = Location::START;
554554
let span = self.patch.source_info_for_location(self.mir, loc).span;
555555
let false_ = self.constant_bool(span, false);
556556
for flag in self.drop_flags.values() {
@@ -576,7 +576,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
576576
}
577577

578578
fn drop_flags_for_args(&mut self) {
579-
let loc = Location { block: START_BLOCK, statement_index: 0 };
579+
let loc = Location::START;
580580
dataflow::drop_flag_effects_for_function_entry(
581581
self.tcx, self.mir, self.env, |path, ds| {
582582
self.set_drop_flag(loc, path, ds);

0 commit comments

Comments
 (0)