aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.cc11
-rw-r--r--gcc/testsuite/rust/compile/extern_generics.rs8
2 files changed, 19 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
index 31164c1..18ac0dd 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
@@ -86,9 +86,20 @@ TypeCheckTopLevelExternItem::visit (HIR::ExternalFunctionItem &function)
case HIR::GenericParam::GenericKind::CONST:
// FIXME: Skipping Lifetime and Const completely until better
// handling.
+ if (parent.get_abi () != Rust::ABI::INTRINSIC)
+ {
+ rust_error_at (function.get_locus (), ErrorCode::E0044,
+ "foreign items may not have const parameters");
+ }
break;
case HIR::GenericParam::GenericKind::TYPE: {
+ if (parent.get_abi () != Rust::ABI::INTRINSIC)
+ {
+ rust_error_at (
+ function.get_locus (), ErrorCode::E0044,
+ "foreign items may not have type parameters");
+ }
auto param_type
= TypeResolveGenericParam::Resolve (*generic_param);
context->insert_type (generic_param->get_mappings (),
diff --git a/gcc/testsuite/rust/compile/extern_generics.rs b/gcc/testsuite/rust/compile/extern_generics.rs
new file mode 100644
index 0000000..26f97a6
--- /dev/null
+++ b/gcc/testsuite/rust/compile/extern_generics.rs
@@ -0,0 +1,8 @@
+#[lang="sized"]
+trait Sized {}
+
+
+// E0044
+fn main() {
+extern "C" { fn some_func<T>(x: T); } // { dg-error "foreign items may not have type parameters .E0044." }
+} \ No newline at end of file