Skip to content

Commit

Permalink
Catch a bad placeholder type error for statics in externs
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Apr 1, 2021
1 parent a5029ac commit b5782ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/rustc_typeck/src/collect.rs
Expand Up @@ -735,8 +735,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);
}
_ => (),
}
}
}
Expand Down
@@ -0,0 +1,7 @@
// Regression test for #83621.

extern "C" {
static x: _; //~ ERROR: [E0121]
}

fn main() {}
@@ -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`.

0 comments on commit b5782ba

Please sign in to comment.