Skip to content

Commit 76be7e2

Browse files
authored
Rollup merge of #83734 - JohnTitor:issue-83621, r=davidtwco
Catch a bad placeholder type error for statics in `extern`s Fixes #83621
2 parents d9f123a + b5782ba commit 76be7e2

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

compiler/rustc_typeck/src/collect.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,14 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
734734
tcx.ensure().generics_of(item.def_id);
735735
tcx.ensure().type_of(item.def_id);
736736
tcx.ensure().predicates_of(item.def_id);
737-
if let hir::ForeignItemKind::Fn(..) = item.kind {
738-
tcx.ensure().fn_sig(item.def_id);
737+
match item.kind {
738+
hir::ForeignItemKind::Fn(..) => tcx.ensure().fn_sig(item.def_id),
739+
hir::ForeignItemKind::Static(..) => {
740+
let mut visitor = PlaceholderHirTyCollector::default();
741+
visitor.visit_foreign_item(item);
742+
placeholder_type_error(tcx, None, &[], visitor.0, false, None);
743+
}
744+
_ => (),
739745
}
740746
}
741747
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for #83621.
2+
3+
extern "C" {
4+
static x: _; //~ ERROR: [E0121]
5+
}
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
2+
--> $DIR/issue-83621-placeholder-static-in-extern.rs:4:15
3+
|
4+
LL | static x: _;
5+
| ^ not allowed in type signatures
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)