Skip to content

Commit b9ea182

Browse files
committed
Don't needlessly search for already-found HIR generic param
1 parent e742ed9 commit b9ea182

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,16 +1058,13 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
10581058
}
10591059

10601060
fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: LocalDefId) -> ObjectLifetimeDefault {
1061-
debug_assert_eq!(tcx.def_kind(param_def_id), DefKind::TyParam);
10621061
let hir::Node::GenericParam(param) = tcx.hir_node_by_def_id(param_def_id) else {
10631062
bug!("expected GenericParam for object_lifetime_default");
10641063
};
10651064
match param.source {
10661065
hir::GenericParamSource::Generics => {
10671066
let parent_def_id = tcx.local_parent(param_def_id);
10681067
let generics = tcx.hir_get_generics(parent_def_id).unwrap();
1069-
let param_hir_id = tcx.local_def_id_to_hir_id(param_def_id);
1070-
let param = generics.params.iter().find(|p| p.hir_id == param_hir_id).unwrap();
10711068

10721069
// Scan the bounds and where-clauses on parameters to extract bounds
10731070
// of the form `T:'a` so as to determine the `ObjectLifetimeDefault`
@@ -1101,7 +1098,7 @@ fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: LocalDefId) -> ObjectL
11011098
}
11021099
}
11031100
_ => {
1104-
bug!("object_lifetime_default_raw must only be called on a type parameter")
1101+
bug!("object_lifetime_default must only be called on a type parameter")
11051102
}
11061103
}
11071104
}

0 commit comments

Comments
 (0)