about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-25 16:32:34 +0000
committerbors <bors@rust-lang.org>2023-09-25 16:32:34 +0000
commit1cbfeabfa9fb688cd5d2b8faf7ef2de8ab38dd9d (patch)
tree039e90b61447550c296dd5731c5662397fed38c1 /compiler/rustc_hir_analysis/src
parent9d32ba3a7219e28b0d44b5eb4d564ca58114356f (diff)
parenta1d181d740df13972533475b4b35d59678b3ab50 (diff)
downloadrust-1cbfeabfa9fb688cd5d2b8faf7ef2de8ab38dd9d.tar.gz
rust-1cbfeabfa9fb688cd5d2b8faf7ef2de8ab38dd9d.zip
Auto merge of #113396 - lenko-d:dont_ICE_when_no_bound_vars_for_lifetime_binders, r=compiler-errors
Don't ICE when no bound vars found while doing closure hir type check

The problem was that we were not visiting the const generic default argument in a bound where predicate when the HIR gets traversed in hir_analysis -> collect -> resolve_bound_vars.

Fixes [112574](https://github.com/rust-lang/rust/issues/112574)
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
-rw-r--r--compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
index a39cfd7b6e1..d9207f2de52 100644
--- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
+++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
@@ -856,22 +856,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
         let scope = Scope::TraitRefBoundary { s: self.scope };
         self.with(scope, |this| {
             walk_list!(this, visit_generic_param, generics.params);
-            for param in generics.params {
-                match param.kind {
-                    GenericParamKind::Lifetime { .. } => {}
-                    GenericParamKind::Type { default, .. } => {
-                        if let Some(ty) = default {
-                            this.visit_ty(ty);
-                        }
-                    }
-                    GenericParamKind::Const { ty, default } => {
-                        this.visit_ty(ty);
-                        if let Some(default) = default {
-                            this.visit_body(this.tcx.hir().body(default.body));
-                        }
-                    }
-                }
-            }
             walk_list!(this, visit_where_predicate, generics.predicates);
         })
     }
@@ -1000,6 +984,21 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
                 // like implicit `?Sized` or const-param-has-ty predicates.
             }
         }
+
+        match p.kind {
+            GenericParamKind::Lifetime { .. } => {}
+            GenericParamKind::Type { default, .. } => {
+                if let Some(ty) = default {
+                    self.visit_ty(ty);
+                }
+            }
+            GenericParamKind::Const { ty, default } => {
+                self.visit_ty(ty);
+                if let Some(default) = default {
+                    self.visit_body(self.tcx.hir().body(default.body));
+                }
+            }
+        }
     }
 }