Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MahadMuhammad opened this issue Jul 5, 2023 · 1 comment
Open
Assignees
Labels

Comments

@MahadMuhammad
Copy link
Contributor

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)

@MahadMuhammad
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants