Skip to content

Commit

Permalink
Remove DefId from EarlyParamRegion (clippy/smir)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed May 24, 2024
1 parent fe2d779 commit f856ee3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/convert/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,6 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
use stable_mir::ty::{BoundRegion, EarlyParamRegion, RegionKind};
match self {
ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion {
def_id: tables.region_def(todo!()),
index: early_reg.index,
name: early_reg.name.to_string(),
}),
Expand Down
1 change: 0 additions & 1 deletion compiler/stable_mir/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ pub(crate) type DebruijnIndex = u32;

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EarlyParamRegion {
pub def_id: RegionDef,
pub index: u32,
pub name: Symbol,
}
Expand Down
19 changes: 9 additions & 10 deletions src/tools/clippy/clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,19 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
}
None
}) {
if !lifetime.is_anonymous()
if let LifetimeName::Param(param_def_id) = lifetime.res
&& !lifetime.is_anonymous()
&& fn_sig
.output()
.walk()
.filter_map(|arg| {
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::ReLateParam(r) => r.bound_region.get_id(),
ty::ReStatic
Expand All @@ -476,14 +482,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
| ty::ReError(_) => None,
})
})
.any(|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),
)
})
.any(|def_id| 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
return None;
Expand Down

0 comments on commit f856ee3

Please sign in to comment.