diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index 233cfd792880b..a511989d972c8 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -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(), }), diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index f3ac2bfcdb01f..d62054eff6092 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -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, } diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index 65929cd5fea9c..5a019c26f4a1a 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -460,13 +460,25 @@ fn check_fn_args<'cx, 'tcx: 'cx>( } None }) { + let binding_item = match lifetime.res { + LifetimeName::Param(param_def_id) => Some(cx.tcx.parent(param_def_id.to_def_id())), + _ => None, + }; + if !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) if binding_item.is_some() => Some( + cx.tcx.generics_of(binding_item.unwrap()).region_param(r, cx.tcx).def_id + ), + // It doesn't seem entirely correct to return none here, since all early-bound + // parameters will have a corresponding `DefId`. It shouldn't matter though as if + // `binding_item` is `None` then the `any` afterwards is going to return `false` + // no matter what `DefId`'s we do or do not return. + ty::ReEarlyParam(_) => None, ty::ReBound(_, r) => r.kind.get_id(), ty::ReLateParam(r) => r.bound_region.get_id(), ty::ReStatic