Skip to content

Commit f9efcb1

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

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+15
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,21 @@ 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+
if let hir::PatKind::Range(start, end, _) = p.kind {
723+
if let Some(start) = start {
724+
self.visit_expr(start);
725+
}
726+
727+
if let Some(end) = end {
728+
self.visit_expr(end);
729+
}
730+
} else {
731+
intravisit::walk_pat(self, p)
732+
}
733+
}
734+
720735
#[instrument(level = "debug", skip(self))]
721736
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
722737
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)