Skip to content

Commit 9949ea7

Browse files
committed
Move generic arg checks from the hir item types visitor to ty wfcheck
1 parent bfe4c5f commit 9949ea7

File tree

3 files changed

+23
-38
lines changed

3 files changed

+23
-38
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,29 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
702702
}
703703

704704
pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
705+
let generics = tcx.generics_of(def_id);
706+
707+
for param in &generics.own_params {
708+
match param.kind {
709+
ty::GenericParamDefKind::Lifetime { .. } => {}
710+
ty::GenericParamDefKind::Type { has_default, .. } => {
711+
if has_default {
712+
tcx.ensure_ok().type_of(param.def_id);
713+
}
714+
}
715+
ty::GenericParamDefKind::Const { has_default, .. } => {
716+
tcx.ensure_ok().type_of(param.def_id);
717+
if has_default {
718+
// need to store default and type of default
719+
let ct = tcx.const_param_default(param.def_id).skip_binder();
720+
if let ty::ConstKind::Unevaluated(uv) = ct.kind() {
721+
tcx.ensure_ok().type_of(uv.def);
722+
}
723+
}
724+
}
725+
}
726+
}
727+
705728
match tcx.def_kind(def_id) {
706729
DefKind::Static { .. } => {
707730
check_static_inhabited(tcx, def_id);
@@ -771,7 +794,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
771794
check_opaque(tcx, def_id);
772795
}
773796

774-
tcx.ensure_ok().generics_of(def_id);
775797
tcx.ensure_ok().predicates_of(def_id);
776798
tcx.ensure_ok().explicit_item_bounds(def_id);
777799
tcx.ensure_ok().explicit_item_self_bounds(def_id);

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -287,29 +287,6 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
287287
intravisit::walk_item(self, item);
288288
}
289289

290-
fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
291-
for param in generics.params {
292-
match param.kind {
293-
hir::GenericParamKind::Lifetime { .. } => {}
294-
hir::GenericParamKind::Type { default: Some(_), .. } => {
295-
self.tcx.ensure_ok().type_of(param.def_id);
296-
}
297-
hir::GenericParamKind::Type { .. } => {}
298-
hir::GenericParamKind::Const { default, .. } => {
299-
self.tcx.ensure_ok().type_of(param.def_id);
300-
if let Some(default) = default {
301-
// need to store default and type of default
302-
self.tcx.ensure_ok().const_param_default(param.def_id);
303-
if let hir::ConstArgKind::Anon(ac) = default.kind {
304-
self.tcx.ensure_ok().type_of(ac.def_id);
305-
}
306-
}
307-
}
308-
}
309-
}
310-
intravisit::walk_generics(self, generics);
311-
}
312-
313290
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
314291
if let hir::ExprKind::Closure(closure) = expr.kind {
315292
self.tcx.ensure_ok().generics_of(closure.def_id);

tests/crashes/121429.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)