Skip to content

Error: Type or Const Parameters on Foreign Items #2376

@MahadMuhammad

Description

@MahadMuhammad

Type or Const Parameters Not Allowed on Foreign Items

I tried this code from E0044:

#![allow(unused)]
fn main() {
extern "C" { fn some_func<T>(x: T); }
}

I expected to see this happen:

  • Give error, like rustc-1.49:
➜  mahad-testsuite rustc E0044.rs                   
error[E0044]: foreign items may not have type parameters
 --> E0044.rs:3:14
  |
3 | extern "C" { fn some_func<T>(x: T); }
  |              ^^^^^^^^^^^^^^^^^^^^^^ can't have type parameters
  |
  = help: replace the type parameters with concrete types like `u32`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0044`.

Instead, this happened:

  • Compiled Successfuly.
➜  gccrs-build gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use ../mahad-testsuite/E0044.rs

Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data> {heap 828k} <visibility> {heap 828k} <build_ssa_passes> {heap 828k} <opt_local_passes> {heap 1104k} <remove_symbols> {heap 1104k} <targetclone> {heap 1104k} <free-fnsummary> {heap 1104k}Streaming LTO
 <whole-program> {heap 1104k} <fnsummary> {heap 1104k} <inline> {heap 1104k} <modref> {heap 1104k} <free-fnsummary> {heap 1104k} <single-use> {heap 1104k} <comdats> {heap 1104k}Assembling functions:
 <simdclone> {heap 1104k} E0044::main
Time variable                                   usr           sys          wall           GGC
 phase parsing                      :   0.00 (  0%)   0.00 (  0%)   0.01 ( 33%)    25k ( 12%)
 phase opt and generate             :   0.00 (  0%)   0.01 (100%)   0.02 ( 67%)    58k ( 26%)
 parser (global)                    :   0.00 (  0%)   0.00 (  0%)   0.01 ( 33%)    25k ( 12%)
 integrated RA                      :   0.00 (  0%)   0.01 (100%)   0.01 ( 33%)    24k ( 11%)
 initialize rtl                     :   0.00 (  0%)   0.00 (  0%)   0.01 ( 33%)    12k (  6%)
 TOTAL                              :   0.00          0.01          0.03          221k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

Meta

  • What version of Rust GCC were you using, git sha 5406b63.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions