Skip to content

Commit 6dead55

Browse files
committed
Call lower_const_param instead of duplicating the code
1 parent c2239bc commit 6dead55

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+29
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,35 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
717717
}
718718
}
719719

720+
#[instrument(level = "debug", skip(self))]
721+
fn visit_pattern_type_pattern(&mut self, p: &'tcx hir::Pat<'tcx>) {
722+
match p.kind {
723+
hir::PatKind::Range(start, end, _) => {
724+
if let Some(start) = start {
725+
self.visit_expr(start);
726+
}
727+
728+
if let Some(end) = end {
729+
self.visit_expr(end);
730+
}
731+
}
732+
hir::PatKind::Wild
733+
| hir::PatKind::Binding(_, _, _, _)
734+
| hir::PatKind::Struct(_, _, _)
735+
| hir::PatKind::TupleStruct(_, _, _)
736+
| hir::PatKind::Or(_)
737+
| hir::PatKind::Never
738+
| hir::PatKind::Path(_)
739+
| hir::PatKind::Tuple(_, _)
740+
| hir::PatKind::Box(_)
741+
| hir::PatKind::Deref(_)
742+
| hir::PatKind::Ref(_, _)
743+
| hir::PatKind::Lit(_)
744+
| hir::PatKind::Slice(_, _, _)
745+
| hir::PatKind::Err(_) => {}
746+
}
747+
}
748+
720749
#[instrument(level = "debug", skip(self))]
721750
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
722751
use self::hir::TraitItemKind::*;

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2234,11 +2234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
22342234
.type_of(def_id)
22352235
.no_bound_vars()
22362236
.expect("const parameter types cannot be generic");
2237-
let item_def_id = tcx.parent(def_id);
2238-
let generics = tcx.generics_of(item_def_id);
2239-
let index = generics.param_def_id_to_index[&def_id];
2240-
let name = tcx.item_name(def_id);
2241-
ty::Const::new_param(tcx, ty::ParamConst::new(index, name), ty)
2237+
self.lower_const_param(expr.hir_id, ty)
22422238
}
22432239

22442240
_ => {

0 commit comments

Comments
 (0)