Skip to content

Commit 0946cb8

Browse files
committed
Remove DefId from EarlyParamRegion (clippy/smir)
1 parent b8ff6ce commit 0946cb8

File tree

3 files changed

+13
-3
lines changed
  • compiler
    • rustc_smir/src/rustc_smir/convert
    • stable_mir/src
  • src/tools/clippy/clippy_lints/src

3 files changed

+13
-3
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

+13-1
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,25 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
460460
}
461461
None
462462
}) {
463+
let binding_item = match lifetime.res {
464+
LifetimeName::Param(param_def_id) => Some(cx.tcx.parent(param_def_id.to_def_id())),
465+
_ => None,
466+
};
467+
463468
if !lifetime.is_anonymous()
464469
&& fn_sig
465470
.output()
466471
.walk()
467472
.filter_map(|arg| {
468473
arg.as_region().and_then(|lifetime| match lifetime.kind() {
469-
ty::ReEarlyParam(r) => Some(r.def_id),
474+
ty::ReEarlyParam(r) if binding_item.is_some() => Some(
475+
cx.tcx.generics_of(binding_item.unwrap()).region_param(r, cx.tcx).def_id
476+
),
477+
// It doesn't seem entirely correct to return none here, since all early-bound
478+
// parameters will have a corresponding `DefId`. It shouldn't matter though as if
479+
// `binding_item` is `None` then the `any` afterwards is going to return `false`
480+
// no matter what `DefId`'s we do or do not return.
481+
ty::ReEarlyParam(_) => None,
470482
ty::ReBound(_, r) => r.kind.get_id(),
471483
ty::ReLateParam(r) => r.bound_region.get_id(),
472484
ty::ReStatic

0 commit comments

Comments
 (0)