1
Fork 0

Rollup merge of #139509 - xizheyin:issue-139359, r=lcnr

clean: remove Deref<Target=RegionKind> impl for Region and use `.kind()`

Closes #139359

r? `@lcnr`
This commit is contained in:
Matthias Krüger 2025-04-08 18:05:34 +02:00 committed by GitHub
commit 1cbf8b56af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 117 additions and 127 deletions

View file

@ -442,7 +442,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateParam<'tcx> {
}
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
if let ty::ReLateParam(fr) = *r {
if let ty::ReLateParam(fr) = r.kind() {
ty::Region::new_late_param(
self.tcx,
fr.scope,

View file

@ -631,7 +631,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
// Ignore `'static` lifetimes for the purpose of this lint: it's
// because we know it outlives everything and so doesn't give meaningful
// clues. Also ignore `ReError`, to avoid knock-down errors.
if let ty::ReStatic | ty::ReError(_) = **region_a {
if let ty::ReStatic | ty::ReError(_) = region_a.kind() {
continue;
}
// For each region argument (e.g., `'a` in our example), check for a
@ -672,7 +672,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
// Again, skip `'static` because it outlives everything. Also, we trivially
// know that a region outlives itself. Also ignore `ReError`, to avoid
// knock-down errors.
if matches!(**region_b, ty::ReStatic | ty::ReError(_)) || region_a == region_b {
if matches!(region_b.kind(), ty::ReStatic | ty::ReError(_)) || region_a == region_b {
continue;
}
if region_known_to_outlive(tcx, item_def_id, param_env, wf_tys, *region_a, *region_b) {

View file

@ -656,7 +656,7 @@ fn infringing_fields_error<'tcx>(
.entry((ty.clone(), predicate.clone()))
.or_default()
.push(origin.span());
if let ty::RegionKind::ReEarlyParam(ebr) = *b
if let ty::RegionKind::ReEarlyParam(ebr) = b.kind()
&& ebr.has_name()
{
bounds.push((b.to_string(), a.to_string(), None));

View file

@ -1416,7 +1416,7 @@ fn recover_infer_ret_ty<'tcx>(
GenericParamKind::Lifetime { .. } => true,
_ => false,
});
let fn_sig = fold_regions(tcx, fn_sig, |r, _| match *r {
let fn_sig = fold_regions(tcx, fn_sig, |r, _| match r.kind() {
ty::ReErased => {
if has_region_params {
ty::Region::new_error_with_message(

View file

@ -359,7 +359,7 @@ fn compute_bidirectional_outlives_predicates<'tcx>(
) {
for param in opaque_own_params {
let orig_lifetime = tcx.map_opaque_lifetime_to_parent_lifetime(param.def_id.expect_local());
if let ty::ReEarlyParam(..) = *orig_lifetime {
if let ty::ReEarlyParam(..) = orig_lifetime.kind() {
let dup_lifetime = ty::Region::new_early_param(
tcx,
ty::EarlyParamRegion { index: param.index, name: param.name },

View file

@ -80,7 +80,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
}
fn visit_region(&mut self, r: ty::Region<'tcx>) {
if let ty::ReEarlyParam(data) = *r {
if let ty::ReEarlyParam(data) = r.kind() {
self.parameters.push(Parameter::from(data));
}
}

View file

@ -146,7 +146,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
fn is_free_region(region: Region<'_>) -> bool {
// First, screen for regions that might appear in a type header.
match *region {
match region.kind() {
// These correspond to `T: 'a` relationships:
//
// struct Foo<'a, T> {

View file

@ -428,7 +428,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
region: ty::Region<'tcx>,
variance: VarianceTermPtr<'a>,
) {
match *region {
match region.kind() {
ty::ReEarlyParam(ref data) => {
self.add_constraint(current, data.index, variance);
}