Skip to content

Commit 3b087b3

Browse files
committed
stop using "free region" for param regions
1 parent d8a2a3e commit 3b087b3

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
462462

463463
// "Liberate" the late-bound regions. These correspond to
464464
// "local" free regions.
465-
466465
let bound_inputs_and_output = self.compute_inputs_and_output(&indices, defining_ty);
467466

468467
let inputs_and_output = self.infcx.replace_bound_regions_with_nll_infer_vars(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,8 +2714,8 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
27142714
a: ty::Region<'tcx>,
27152715
b: ty::Region<'tcx>,
27162716
) -> RelateResult<'tcx, ty::Region<'tcx>> {
2717-
if (a.is_var() && b.is_free_or_static())
2718-
|| (b.is_var() && a.is_free_or_static())
2717+
if (a.is_var() && b.is_free())
2718+
|| (b.is_var() && a.is_free())
27192719
|| (a.is_var() && b.is_var())
27202720
|| a == b
27212721
{

compiler/rustc_infer/src/infer/free_regions.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
2222
Self { tcx, free_regions }
2323
}
2424

25-
pub fn lub_free_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
26-
self.free_regions.lub_free_regions(self.tcx, r_a, r_b)
25+
pub fn lub_param_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
26+
self.free_regions.lub_param_regions(self.tcx, r_a, r_b)
2727
}
2828
}
2929

@@ -59,7 +59,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
5959
r_a: Region<'tcx>,
6060
r_b: Region<'tcx>,
6161
) -> bool {
62-
assert!(r_a.is_free_or_static() && r_b.is_free_or_static());
62+
assert!(r_a.is_free() && r_b.is_free());
6363
let re_static = tcx.lifetimes.re_static;
6464
if self.check_relation(re_static, r_b) {
6565
// `'a <= 'static` is always true, and not stored in the
@@ -80,15 +80,15 @@ impl<'tcx> FreeRegionMap<'tcx> {
8080
/// cases, this is more conservative than necessary, in order to
8181
/// avoid making arbitrary choices. See
8282
/// `TransitiveRelation::postdom_upper_bound` for more details.
83-
pub fn lub_free_regions(
83+
pub fn lub_param_regions(
8484
&self,
8585
tcx: TyCtxt<'tcx>,
8686
r_a: Region<'tcx>,
8787
r_b: Region<'tcx>,
8888
) -> Region<'tcx> {
89-
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
90-
assert!(r_a.is_free());
91-
assert!(r_b.is_free());
89+
debug!("lub_param_regions(r_a={:?}, r_b={:?})", r_a, r_b);
90+
assert!(r_a.is_late_or_early_param());
91+
assert!(r_b.is_late_or_early_param());
9292
let result = if r_a == r_b {
9393
r_a
9494
} else {
@@ -97,7 +97,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
9797
Some(r) => r,
9898
}
9999
};
100-
debug!("lub_free_regions(r_a={:?}, r_b={:?}) = {:?}", r_a, r_b, result);
100+
debug!("lub_param_regions(r_a={:?}, r_b={:?}) = {:?}", r_a, r_b, result);
101101
result
102102
}
103103
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
450450

451451
// Check for the case where we know that `'b: 'static` -- in that case,
452452
// `a <= b` for all `a`.
453-
let b_free_or_static = b.is_free_or_static();
454-
if b_free_or_static && sub_free_regions(tcx.lifetimes.re_static, b) {
453+
if b.is_free() && sub_free_regions(tcx.lifetimes.re_static, b) {
455454
return true;
456455
}
457456

@@ -460,8 +459,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
460459
// `lub` relationship defined below, since sometimes the "lub"
461460
// is actually the `postdom_upper_bound` (see
462461
// `TransitiveRelation` for more details).
463-
let a_free_or_static = a.is_free_or_static();
464-
if a_free_or_static && b_free_or_static {
462+
if a.is_free() && b.is_free() {
465463
return sub_free_regions(a, b);
466464
}
467465

@@ -502,7 +500,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
502500
}
503501

504502
(ReEarlyParam(_) | ReLateParam(_), ReEarlyParam(_) | ReLateParam(_)) => {
505-
self.region_rels.lub_free_regions(a, b)
503+
self.region_rels.lub_param_regions(a, b)
506504
}
507505

508506
// For these types, we cannot define any additional

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,15 +1858,21 @@ impl<'tcx> Region<'tcx> {
18581858
}
18591859

18601860
/// True for free regions other than `'static`.
1861-
pub fn is_free(self) -> bool {
1861+
pub fn is_late_or_early_param(self) -> bool {
18621862
matches!(*self, ty::ReEarlyParam(_) | ty::ReLateParam(_))
18631863
}
18641864

1865-
/// True if `self` is a free region or static.
1866-
pub fn is_free_or_static(self) -> bool {
1865+
/// True for free region in the current context.
1866+
///
1867+
/// This is the case for `'static` and param regions.
1868+
pub fn is_free(self) -> bool {
18671869
match *self {
1868-
ty::ReStatic => true,
1869-
_ => self.is_free(),
1870+
ty::ReStatic | ty::ReEarlyParam(..) | ty::ReLateParam(..) => true,
1871+
ty::ReVar(..)
1872+
| ty::RePlaceholder(..)
1873+
| ty::ReBound(..)
1874+
| ty::ReErased
1875+
| ty::ReError(..) => false,
18701876
}
18711877
}
18721878

0 commit comments

Comments
 (0)