Skip to content

Commit 78da436

Browse files
committed
Remove lub_empty from lexical region resolve
1 parent b60f7b5 commit 78da436

File tree

1 file changed

+19
-46
lines changed
  • compiler/rustc_infer/src/infer/lexical_region_resolve

1 file changed

+19
-46
lines changed

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_data_structures::graph::implementation::{
1515
use rustc_data_structures::intern::Interned;
1616
use rustc_index::{IndexSlice, IndexVec};
1717
use rustc_middle::ty::fold::TypeFoldable;
18-
use rustc_middle::ty::PlaceholderRegion;
1918
use rustc_middle::ty::{self, Ty, TyCtxt};
2019
use rustc_middle::ty::{ReEarlyBound, ReErased, ReError, ReFree, ReStatic};
2120
use rustc_middle::ty::{ReLateBound, RePlaceholder, ReVar};
@@ -173,38 +172,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
173172
}
174173
}
175174

176-
/// Gets the LUb of a given region and the empty region
177-
fn lub_empty(&self, a_region: Region<'tcx>) -> Result<Region<'tcx>, PlaceholderRegion> {
178-
match *a_region {
179-
ReLateBound(..) | ReErased => {
180-
bug!("cannot relate region: {:?}", a_region);
181-
}
182-
183-
ReVar(v_id) => {
184-
span_bug!(
185-
self.var_infos[v_id].origin.span(),
186-
"lub invoked with non-concrete regions: {:?}",
187-
a_region,
188-
);
189-
}
190-
191-
ReStatic => {
192-
// nothing lives longer than `'static`
193-
Ok(self.tcx().lifetimes.re_static)
194-
}
195-
196-
ReError(_) => Ok(a_region),
197-
198-
ReEarlyBound(_) | ReFree(_) => {
199-
// All empty regions are less than early-bound, free,
200-
// and scope regions.
201-
Ok(a_region)
202-
}
203-
204-
RePlaceholder(placeholder) => Err(placeholder),
205-
}
206-
}
207-
208175
fn expansion(&self, var_values: &mut LexicalRegionResolutions<'tcx>) {
209176
// In the first pass, we expand region vids according to constraints we
210177
// have previously found. In the second pass, we loop through the region
@@ -247,15 +214,17 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
247214
true
248215
}
249216
VarValue::Value(cur_region) => {
250-
let lub = match self.lub_empty(cur_region) {
251-
Ok(r) => r,
217+
let lub = match *cur_region {
252218
// If the empty and placeholder regions are in the same universe,
253219
// then the LUB is the Placeholder region (which is the cur_region).
254220
// If they are not in the same universe, the LUB is the Static lifetime.
255-
Err(placeholder) if a_universe == placeholder.universe => {
256-
cur_region
221+
RePlaceholder(placeholder)
222+
if a_universe != placeholder.universe =>
223+
{
224+
self.tcx().lifetimes.re_static
257225
}
258-
Err(_) => self.tcx().lifetimes.re_static,
226+
227+
_ => cur_region,
259228
};
260229

261230
if lub == cur_region {
@@ -341,15 +310,19 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
341310

342311
match *b_data {
343312
VarValue::Empty(empty_ui) => {
344-
let lub = match self.lub_empty(a_region) {
345-
Ok(r) => r,
346-
// If this empty region is from a universe that can
347-
// name the placeholder, then the placeholder is
348-
// larger; otherwise, the only ancestor is `'static`.
349-
Err(placeholder) if empty_ui.can_name(placeholder.universe) => {
350-
ty::Region::new_placeholder(self.tcx(), placeholder)
313+
let lub = match *a_region {
314+
RePlaceholder(placeholder) => {
315+
// If this empty region is from a universe that can
316+
// name the placeholder, then the placeholder is
317+
// larger; otherwise, the only ancestor is `'static`.
318+
if empty_ui.can_name(placeholder.universe) {
319+
ty::Region::new_placeholder(self.tcx(), placeholder)
320+
} else {
321+
self.tcx().lifetimes.re_static
322+
}
351323
}
352-
Err(_) => self.tcx().lifetimes.re_static,
324+
325+
_ => a_region,
353326
};
354327

355328
debug!("Expanding value of {:?} from empty lifetime to {:?}", b_vid, lub);

0 commit comments

Comments
 (0)