Skip to content

Error - Unable to find lang-item & cannot apply operation to types  #2384

@MahadMuhammad

Description

@MahadMuhammad

Unable to find lang item (fatal-error)

  • Fixing this error will improve gccrs to emit error codes similiar to rustc.
  • You can view the same on compiler-explorer

I tried this code from E0057 - invalid number of arguments was given when calling a closure:

// https://doc.rust-lang.org/error_codes/E0057.html
#![allow(unused)]
fn main() {
let f = |x| x * 3;
let a = f();        // invalid, too few parameters
let b = f(4);       // this works!
let c = f(2, 3);    // invalid, too many parameters
}

I expected to see this happen:

  • Give error like rustc:
error[E0057]: this function takes 1 argument but 0 arguments were supplied
 --> <source>:4:9
  |
4 | let a = f();        // invalid, too few parameters
  |         ^-- supplied 0 arguments
  |         |
  |         expected 1 argument

error[E0057]: this function takes 1 argument but 2 arguments were supplied
 --> <source>:6:9
  |
6 | let c = f(2, 3);    // invalid, too many parameters
  |         ^ -  - supplied 2 arguments
  |         |
  |         expected 1 argument

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0057`.
Compiler returned: 1

Instead, this happened:

  • Gives wrong and fatal error:
<source>:3:13: error: cannot apply this operator to types T? and <integer>
    3 | let f = |x| x * 3;
      |             ^
<source>:3:9: fatal error: unable to find lang item: 'fn_once'
    3 | let f = |x| x * 3;
      |         ^
compilation terminated.
Compiler returned: 1

Meta

  • What version of Rust GCC were you using, git sha 5406b63.
  • Godbolt version : gccrs (Compiler-Explorer-Build-gcc-2f91d511200bf85558c9013b09a458c06edd1e02-binutils-2.40) 13.0.1 20230417 (experimental)

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions