Skip to content

Commit a1d181d

Browse files
committed
Added additional visit steps to visit_generic_param() in order to avoid ICE on no bound vars.
1 parent 91958e0 commit a1d181d

File tree

3 files changed

+53
-16
lines changed

3 files changed

+53
-16
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -856,22 +856,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
856856
let scope = Scope::TraitRefBoundary { s: self.scope };
857857
self.with(scope, |this| {
858858
walk_list!(this, visit_generic_param, generics.params);
859-
for param in generics.params {
860-
match param.kind {
861-
GenericParamKind::Lifetime { .. } => {}
862-
GenericParamKind::Type { default, .. } => {
863-
if let Some(ty) = default {
864-
this.visit_ty(ty);
865-
}
866-
}
867-
GenericParamKind::Const { ty, default } => {
868-
this.visit_ty(ty);
869-
if let Some(default) = default {
870-
this.visit_body(this.tcx.hir().body(default.body));
871-
}
872-
}
873-
}
874-
}
875859
walk_list!(this, visit_where_predicate, generics.predicates);
876860
})
877861
}
@@ -1000,6 +984,21 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
1000984
// like implicit `?Sized` or const-param-has-ty predicates.
1001985
}
1002986
}
987+
988+
match p.kind {
989+
GenericParamKind::Lifetime { .. } => {}
990+
GenericParamKind::Type { default, .. } => {
991+
if let Some(ty) = default {
992+
self.visit_ty(ty);
993+
}
994+
}
995+
GenericParamKind::Const { ty, default } => {
996+
self.visit_ty(ty);
997+
if let Some(default) = default {
998+
self.visit_body(self.tcx.hir().body(default.body));
999+
}
1000+
}
1001+
}
10031002
}
10041003
}
10051004

tests/ui/closures/issue-112547.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(non_lifetime_binders)]
2+
//~^ WARNING the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
3+
4+
pub fn bar()
5+
where
6+
for<const N: usize = {
7+
(||1usize)()
8+
}> V: IntoIterator
9+
//~^ ERROR cannot find type `V` in this scope [E0412]
10+
{
11+
}
12+
13+
fn main() {
14+
bar();
15+
}

tests/ui/closures/issue-112547.stderr

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0412]: cannot find type `V` in this scope
2+
--> $DIR/issue-112547.rs:8:4
3+
|
4+
LL | }> V: IntoIterator
5+
| ^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | pub fn bar<V>()
10+
| +++
11+
12+
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
13+
--> $DIR/issue-112547.rs:1:12
14+
|
15+
LL | #![feature(non_lifetime_binders)]
16+
| ^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
19+
= note: `#[warn(incomplete_features)]` on by default
20+
21+
error: aborting due to previous error; 1 warning emitted
22+
23+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)