about summary refs log tree commit diff
path: root/compiler/rustc_privacy/src/lib.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-06-17 15:43:33 +0200
committerGitHub <noreply@github.com>2024-06-17 15:43:33 +0200
commit592f9aa544e1f4238a5279b76589b43dce6fefe0 (patch)
treee95d13fd191db3fb98e1c9a82ab27929789dba27 /compiler/rustc_privacy/src/lib.rs
parentc768d6e57cdc9e47be548c57c47765299e9b269a (diff)
parent9074427c69773ca20eef8b6e9613402882f8fb0b (diff)
downloadrust-592f9aa544e1f4238a5279b76589b43dce6fefe0.tar.gz
rust-592f9aa544e1f4238a5279b76589b43dce6fefe0.zip
Rollup merge of #126584 - cjgillot:issue-122736, r=michaelwoerister
Do not ICE in privacy when type inference fails.

Fixes https://github.com/rust-lang/rust/issues/122736
Diffstat (limited to 'compiler/rustc_privacy/src/lib.rs')
-rw-r--r--compiler/rustc_privacy/src/lib.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs
index fb57d42f6df..d3705626938 100644
--- a/compiler/rustc_privacy/src/lib.rs
+++ b/compiler/rustc_privacy/src/lib.rs
@@ -973,8 +973,12 @@ impl<'tcx> NamePrivacyVisitor<'tcx> {
 
 impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
     fn visit_nested_body(&mut self, body_id: hir::BodyId) {
-        let old_maybe_typeck_results =
-            self.maybe_typeck_results.replace(self.tcx.typeck_body(body_id));
+        let new_typeck_results = self.tcx.typeck_body(body_id);
+        // Do not try reporting privacy violations if we failed to infer types.
+        if new_typeck_results.tainted_by_errors.is_some() {
+            return;
+        }
+        let old_maybe_typeck_results = self.maybe_typeck_results.replace(new_typeck_results);
         self.visit_body(self.tcx.hir().body(body_id));
         self.maybe_typeck_results = old_maybe_typeck_results;
     }