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

@ -42,7 +42,7 @@ pub fn find_param_with_region<'tcx>(
anon_region: Region<'tcx>,
replace_region: Region<'tcx>,
) -> Option<AnonymousParamInfo<'tcx>> {
let (id, kind) = match *anon_region {
let (id, kind) = match anon_region.kind() {
ty::ReLateParam(late_param) => (late_param.scope, late_param.kind),
ty::ReEarlyParam(ebr) => {
let region_def = tcx.generics_of(generic_param_scope).region_param(ebr, tcx).def_id;

View file

@ -299,7 +299,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.tcx.param_env(generic_param_scope),
terr,
);
match (*sub, *sup) {
match (sub.kind(), sup.kind()) {
(ty::RePlaceholder(_), ty::RePlaceholder(_)) => {}
(ty::RePlaceholder(_), _) => {
note_and_explain_region(
@ -391,7 +391,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
})
}
infer::RelateParamBound(span, ty, opt_span) => {
let prefix = match *sub {
let prefix = match sub.kind() {
ty::ReStatic => note_and_explain::PrefixKind::TypeSatisfy,
_ => note_and_explain::PrefixKind::TypeOutlive,
};
@ -1048,7 +1048,7 @@ pub(super) fn note_and_explain_region<'tcx>(
suffix: &str,
alt_span: Option<Span>,
) {
let (description, span) = match *region {
let (description, span) = match region.kind() {
ty::ReEarlyParam(_) | ty::ReLateParam(_) | ty::RePlaceholder(_) | ty::ReStatic => {
msg_span_from_named_region(tcx, generic_param_scope, region, alt_span)
}
@ -1085,7 +1085,7 @@ fn msg_span_from_named_region<'tcx>(
region: ty::Region<'tcx>,
alt_span: Option<Span>,
) -> (String, Option<Span>) {
match *region {
match region.kind() {
ty::ReEarlyParam(br) => {
let param_def_id = tcx.generics_of(generic_param_scope).region_param(br, tcx).def_id;
let span = tcx.def_span(param_def_id);
@ -1185,7 +1185,7 @@ pub fn unexpected_hidden_region_diagnostic<'a, 'tcx>(
});
// Explain the region we are capturing.
match *hidden_region {
match hidden_region.kind() {
ty::ReEarlyParam(_) | ty::ReLateParam(_) | ty::ReStatic => {
// Assuming regionck succeeded (*), we ought to always be
// capturing *some* region from the fn header, and hence it

View file

@ -20,7 +20,7 @@ impl<'a> DescriptionCtx<'a> {
region: ty::Region<'tcx>,
alt_span: Option<Span>,
) -> Option<Self> {
let (span, kind, arg) = match *region {
let (span, kind, arg) = match region.kind() {
ty::ReEarlyParam(br) => {
let scope = tcx
.parent(tcx.generics_of(generic_param_scope).region_param(br, tcx).def_id)

View file

@ -46,7 +46,7 @@ pub fn check_opaque_type_parameter_valid<'tcx>(
GenericArgKind::Lifetime(lt) => match defining_scope_kind {
DefiningScopeKind::HirTypeck => continue,
DefiningScopeKind::MirBorrowck => {
matches!(*lt, ty::ReEarlyParam(_) | ty::ReLateParam(_))
matches!(lt.kind(), ty::ReEarlyParam(_) | ty::ReLateParam(_))
|| (lt.is_static() && opaque_env.param_equal_static(i))
}
},

View file

@ -382,7 +382,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
for (new_region, old_region) in
iter::zip(new_args.regions(), old_args.regions())
{
match (*new_region, *old_region) {
match (new_region.kind(), old_region.kind()) {
// If both predicates have an `ReBound` (a HRTB) in the
// same spot, we do nothing.
(ty::ReBound(_, _), ty::ReBound(_, _)) => {}

View file

@ -537,7 +537,7 @@ fn plug_infer_with_placeholders<'tcx>(
}
fn visit_region(&mut self, r: ty::Region<'tcx>) {
if let ty::ReVar(vid) = *r {
if let ty::ReVar(vid) = r.kind() {
let r = self
.infcx
.inner

View file

@ -797,7 +797,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEscapingBoundRegions<'tcx> {
}
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
if let ty::ReBound(debruijn, _) = *r
if let ty::ReBound(debruijn, _) = r.kind()
&& debruijn < self.binder
{
r

View file

@ -144,7 +144,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxEscapingBoundVarVisitor {
#[inline]
fn visit_region(&mut self, r: ty::Region<'tcx>) {
match *r {
match r.kind() {
ty::ReBound(debruijn, _) if debruijn > self.outer_index => {
self.escaping =
self.escaping.max(debruijn.as_usize() - self.outer_index.as_usize());

View file

@ -289,7 +289,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
}
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r {
match r.kind() {
ty::ReBound(debruijn, _)
if debruijn.as_usize()
>= self.current_index.as_usize() + self.universe_indices.len() =>
@ -407,7 +407,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
}
fn fold_region(&mut self, r0: ty::Region<'tcx>) -> ty::Region<'tcx> {
let r1 = match *r0 {
let r1 = match r0.kind() {
ty::ReVar(vid) => self
.infcx
.inner
@ -417,7 +417,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
_ => r0,
};
let r2 = match *r1 {
let r2 = match r1.kind() {
ty::RePlaceholder(p) => {
let replace_var = self.mapped_regions.get(&p);
match replace_var {