about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_typeck/src/collect.rs10
-rw-r--r--src/test/ui/typeck/issue-83621-placeholder-static-in-extern.rs7
-rw-r--r--src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr9
3 files changed, 24 insertions, 2 deletions
diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs
index 05ba8811cc2..53dc79106de 100644
--- a/compiler/rustc_typeck/src/collect.rs
+++ b/compiler/rustc_typeck/src/collect.rs
@@ -734,8 +734,14 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
                 tcx.ensure().generics_of(item.def_id);
                 tcx.ensure().type_of(item.def_id);
                 tcx.ensure().predicates_of(item.def_id);
-                if let hir::ForeignItemKind::Fn(..) = item.kind {
-                    tcx.ensure().fn_sig(item.def_id);
+                match item.kind {
+                    hir::ForeignItemKind::Fn(..) => tcx.ensure().fn_sig(item.def_id),
+                    hir::ForeignItemKind::Static(..) => {
+                        let mut visitor = PlaceholderHirTyCollector::default();
+                        visitor.visit_foreign_item(item);
+                        placeholder_type_error(tcx, None, &[], visitor.0, false, None);
+                    }
+                    _ => (),
                 }
             }
         }
diff --git a/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.rs b/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.rs
new file mode 100644
index 00000000000..16ec2a54643
--- /dev/null
+++ b/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.rs
@@ -0,0 +1,7 @@
+// Regression test for #83621.
+
+extern "C" {
+    static x: _; //~ ERROR: [E0121]
+}
+
+fn main() {}
diff --git a/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr b/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr
new file mode 100644
index 00000000000..b1bec4c0827
--- /dev/null
+++ b/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr
@@ -0,0 +1,9 @@
+error[E0121]: the type placeholder `_` is not allowed within types on item signatures
+  --> $DIR/issue-83621-placeholder-static-in-extern.rs:4:15
+   |
+LL |     static x: _;
+   |               ^ not allowed in type signatures
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0121`.