Remove unnecessary RegionKind::
quals.
The variant names are exported, so we can use them directly (possibly with a `ty::` qualifier). Lots of places already do this, this commit just increases consistency.
This commit is contained in:
parent
7024dc523a
commit
7eb15509ce
10 changed files with 56 additions and 71 deletions
|
@ -416,7 +416,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
|||
let tcx = self.fcx.tcx;
|
||||
let ref_ty = tcx.mk_ref(
|
||||
// Use `ReErased` as `resolve_interior` is going to replace all the regions anyway.
|
||||
tcx.mk_region(ty::RegionKind::ReErased),
|
||||
tcx.mk_region(ty::ReErased),
|
||||
ty::TypeAndMut { ty, mutbl: hir::Mutability::Not },
|
||||
);
|
||||
self.record(
|
||||
|
|
|
@ -355,12 +355,11 @@ fn check_gat_where_clauses(
|
|||
// Same for the region. In our example, 'a corresponds
|
||||
// to the 'me parameter.
|
||||
let region_param = generics.param_at(*region_idx, tcx);
|
||||
let region_param =
|
||||
tcx.mk_region(ty::RegionKind::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: region_param.def_id,
|
||||
index: region_param.index,
|
||||
name: region_param.name,
|
||||
}));
|
||||
let region_param = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: region_param.def_id,
|
||||
index: region_param.index,
|
||||
name: region_param.name,
|
||||
}));
|
||||
// The predicate we expect to see. (In our example,
|
||||
// `Self: 'me`.)
|
||||
let clause = ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
||||
|
@ -397,20 +396,18 @@ fn check_gat_where_clauses(
|
|||
debug!("required clause: {} must outlive {}", region_a, region_b);
|
||||
// Translate into the generic parameters of the GAT.
|
||||
let region_a_param = generics.param_at(*region_a_idx, tcx);
|
||||
let region_a_param =
|
||||
tcx.mk_region(ty::RegionKind::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: region_a_param.def_id,
|
||||
index: region_a_param.index,
|
||||
name: region_a_param.name,
|
||||
}));
|
||||
let region_a_param = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: region_a_param.def_id,
|
||||
index: region_a_param.index,
|
||||
name: region_a_param.name,
|
||||
}));
|
||||
// Same for the region.
|
||||
let region_b_param = generics.param_at(*region_b_idx, tcx);
|
||||
let region_b_param =
|
||||
tcx.mk_region(ty::RegionKind::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: region_b_param.def_id,
|
||||
index: region_b_param.index,
|
||||
name: region_b_param.name,
|
||||
}));
|
||||
let region_b_param = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: region_b_param.def_id,
|
||||
index: region_b_param.index,
|
||||
name: region_b_param.name,
|
||||
}));
|
||||
// The predicate we expect to see.
|
||||
let clause = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
||||
region_a_param,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc_infer::infer::outlives::components::{push_outlives_components, Component};
|
||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
|
||||
use rustc_middle::ty::{self, Region, RegionKind, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Region, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use smallvec::smallvec;
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -141,7 +141,7 @@ fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
|
|||
// }
|
||||
//
|
||||
// We care about these, so fall through.
|
||||
RegionKind::ReEarlyBound(_) => true,
|
||||
ty::ReEarlyBound(_) => true,
|
||||
|
||||
// These correspond to `T: 'static` relationships which can be
|
||||
// rather surprising. We are therefore putting this behind a
|
||||
|
@ -150,7 +150,7 @@ fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
|
|||
// struct Foo<'a, T> {
|
||||
// field: &'static T, // this would generate a ReStatic
|
||||
// }
|
||||
RegionKind::ReStatic => tcx.sess.features_untracked().infer_static_outlives_requirements,
|
||||
ty::ReStatic => tcx.sess.features_untracked().infer_static_outlives_requirements,
|
||||
|
||||
// Late-bound regions can appear in `fn` types:
|
||||
//
|
||||
|
@ -160,19 +160,16 @@ fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
|
|||
//
|
||||
// The type above might generate a `T: 'b` bound, but we can
|
||||
// ignore it. We can't put it on the struct header anyway.
|
||||
RegionKind::ReLateBound(..) => false,
|
||||
ty::ReLateBound(..) => false,
|
||||
|
||||
// This can appear in `where Self: ` bounds (#64855):
|
||||
//
|
||||
// struct Bar<T>(<Self as Foo>::Type) where Self: ;
|
||||
// struct Baz<'a>(&'a Self) where Self: ;
|
||||
RegionKind::ReEmpty(_) => false,
|
||||
ty::ReEmpty(_) => false,
|
||||
|
||||
// These regions don't appear in types from type declarations:
|
||||
RegionKind::ReErased
|
||||
| RegionKind::ReVar(..)
|
||||
| RegionKind::RePlaceholder(..)
|
||||
| RegionKind::ReFree(..) => {
|
||||
ty::ReErased | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReFree(..) => {
|
||||
bug!("unexpected region in outlives inference: {:?}", region);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue