Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f856ee3

Browse files
committedMay 24, 2024
Remove DefId from EarlyParamRegion (clippy/smir)
1 parent fe2d779 commit f856ee3

File tree

3 files changed

+9
-12
lines changed
  • compiler
    • rustc_smir/src/rustc_smir/convert
    • stable_mir/src
  • src/tools/clippy/clippy_lints/src

3 files changed

+9
-12
lines changed
 

‎compiler/rustc_smir/src/rustc_smir/convert/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,6 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
771771
use stable_mir::ty::{BoundRegion, EarlyParamRegion, RegionKind};
772772
match self {
773773
ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion {
774-
def_id: tables.region_def(todo!()),
775774
index: early_reg.index,
776775
name: early_reg.name.to_string(),
777776
}),

‎compiler/stable_mir/src/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ pub(crate) type DebruijnIndex = u32;
190190

191191
#[derive(Clone, Debug, Eq, PartialEq)]
192192
pub struct EarlyParamRegion {
193-
pub def_id: RegionDef,
194193
pub index: u32,
195194
pub name: Symbol,
196195
}

‎src/tools/clippy/clippy_lints/src/ptr.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,19 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
460460
}
461461
None
462462
}) {
463-
if !lifetime.is_anonymous()
463+
if let LifetimeName::Param(param_def_id) = lifetime.res
464+
&& !lifetime.is_anonymous()
464465
&& fn_sig
465466
.output()
466467
.walk()
467468
.filter_map(|arg| {
468469
arg.as_region().and_then(|lifetime| match lifetime.kind() {
469-
ty::ReEarlyParam(r) => Some(r.def_id),
470+
ty::ReEarlyParam(r) => Some(
471+
cx.tcx
472+
.generics_of(cx.tcx.parent(param_def_id.to_def_id()))
473+
.region_param(r, cx.tcx)
474+
.def_id,
475+
),
470476
ty::ReBound(_, r) => r.kind.get_id(),
471477
ty::ReLateParam(r) => r.bound_region.get_id(),
472478
ty::ReStatic
@@ -476,14 +482,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
476482
| ty::ReError(_) => None,
477483
})
478484
})
479-
.any(|def_id| {
480-
matches!(
481-
lifetime.res,
482-
LifetimeName::Param(param_def_id) if def_id
483-
.as_local()
484-
.is_some_and(|def_id| def_id == param_def_id),
485-
)
486-
})
485+
.any(|def_id| def_id.as_local().is_some_and(|def_id| def_id == param_def_id))
487486
{
488487
// `&Cow<'a, T>` when the return type uses 'a is okay
489488
return None;

0 commit comments

Comments
 (0)
Failed to load comments.