Skip to content

Commit

Permalink
Remove DefIdfrom EarlyParamRegion (clippy/smir)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed May 24, 2024
1 parent 6862b2c commit 5451787
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 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
14 changes: 13 additions & 1 deletion src/tools/clippy/clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5451787

Please sign in to comment.