Remove DefId from EarlyParamRegion (clippy/smir)

This commit is contained in:
Boxy 2024-05-24 17:25:50 +01:00
parent fe2d7794ca
commit f856ee357c
3 changed files with 9 additions and 12 deletions

View File

@ -771,7 +771,6 @@ fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
use stable_mir::ty::{BoundRegion, EarlyParamRegion, RegionKind}; use stable_mir::ty::{BoundRegion, EarlyParamRegion, RegionKind};
match self { match self {
ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion { ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion {
def_id: tables.region_def(todo!()),
index: early_reg.index, index: early_reg.index,
name: early_reg.name.to_string(), name: early_reg.name.to_string(),
}), }),

View File

@ -190,7 +190,6 @@ pub enum RegionKind {
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
pub struct EarlyParamRegion { pub struct EarlyParamRegion {
pub def_id: RegionDef,
pub index: u32, pub index: u32,
pub name: Symbol, pub name: Symbol,
} }

View File

@ -460,13 +460,19 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
} }
None None
}) { }) {
if !lifetime.is_anonymous() if let LifetimeName::Param(param_def_id) = lifetime.res
&& !lifetime.is_anonymous()
&& fn_sig && fn_sig
.output() .output()
.walk() .walk()
.filter_map(|arg| { .filter_map(|arg| {
arg.as_region().and_then(|lifetime| match lifetime.kind() { arg.as_region().and_then(|lifetime| match lifetime.kind() {
ty::ReEarlyParam(r) => Some(r.def_id), ty::ReEarlyParam(r) => Some(
cx.tcx
.generics_of(cx.tcx.parent(param_def_id.to_def_id()))
.region_param(r, cx.tcx)
.def_id,
),
ty::ReBound(_, r) => r.kind.get_id(), ty::ReBound(_, r) => r.kind.get_id(),
ty::ReLateParam(r) => r.bound_region.get_id(), ty::ReLateParam(r) => r.bound_region.get_id(),
ty::ReStatic ty::ReStatic
@ -476,14 +482,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
| ty::ReError(_) => None, | ty::ReError(_) => None,
}) })
}) })
.any(|def_id| { .any(|def_id| def_id.as_local().is_some_and(|def_id| def_id == param_def_id))
matches!(
lifetime.res,
LifetimeName::Param(param_def_id) if def_id
.as_local()
.is_some_and(|def_id| def_id == param_def_id),
)
})
{ {
// `&Cow<'a, T>` when the return type uses 'a is okay // `&Cow<'a, T>` when the return type uses 'a is okay
return None; return None;