Skip to content

Commit 823293b

Browse files
committed
Fix subst error for consts in wfcheck
1 parent c187f71 commit 823293b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustc_typeck/check/wfcheck.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
421421
return_ty: Option<Ty<'tcx>>,
422422
) {
423423
let predicates = fcx.tcx.predicates_of(def_id);
424-
425424
let generics = tcx.generics_of(def_id);
425+
426426
let is_our_default = |def: &ty::GenericParamDef| {
427427
match def.kind {
428428
GenericParamDefKind::Type { has_default, .. } => {
@@ -465,6 +465,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
465465
// All regions are identity.
466466
fcx.tcx.mk_param_from_def(param)
467467
}
468+
468469
GenericParamDefKind::Type { .. } => {
469470
// If the param has a default,
470471
if is_our_default(param) {
@@ -478,25 +479,24 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
478479
// Mark unwanted params as err.
479480
fcx.tcx.types.err.into()
480481
}
482+
481483
GenericParamDefKind::Const => {
482484
// FIXME(const_generics:defaults)
483-
fcx.tcx.types.err.into()
485+
fcx.tcx.consts.err.into()
484486
}
485487
}
486488
});
489+
487490
// Now we build the substituted predicates.
488491
let default_obligations = predicates.predicates.iter().flat_map(|&(pred, _)| {
489492
#[derive(Default)]
490493
struct CountParams { params: FxHashSet<u32> }
491494
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
492495
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
493-
match t.sty {
494-
ty::Param(p) => {
495-
self.params.insert(p.idx);
496-
t.super_visit_with(self)
497-
}
498-
_ => t.super_visit_with(self)
496+
if let ty::Param(param) = t.sty {
497+
self.params.insert(param.idx);
499498
}
499+
t.super_visit_with(self)
500500
}
501501

502502
fn visit_region(&mut self, _: ty::Region<'tcx>) -> bool {

0 commit comments

Comments
 (0)