gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Location Info error for "missing function in trait implementation"

Open MahadMuhammad opened this issue 1 year ago • 1 comments

Location Info error for "missing function in trait implementation"

  • Solving this issue helps this PR https://github.com/Rust-GCC/gccrs/pull/2377 to emit error code similiar to rustc.

I tried this code from E0046:

// https://doc.rust-lang.org/error_codes/E0046.html
trait Foo {
    fn foo();
}

struct Bar;

impl Foo for Bar {}
// error: not all trait items implemented, missing: `foo`

This happened:

  • Location info was not clear.
➜  gccrs-build gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use ../mahad-testsuite/E0046.rs
../mahad-testsuite/E0046.rs:9:1: error: missing foo in implementation of trait ‘Foo’ [E0046]
    4 |     fn foo();
+     |     ~~
-     |     --------- `foo` from trait
......
    9 | impl Foo for Bar {}
+     | ^~~~
-     | ^^^^^^^^^^^^^^^^ missing `foo` in implementation


I expected to see this happen:

  • Location info similiar to rustc-1.49.
  • This is the output of rust-1.49:
➜  gccrs-build rustc  ../mahad-testsuite/E0046.rs
error[E0046]: not all trait items implemented, missing: `foo`
 --> ../mahad-testsuite/E0046.rs:9:1
  |
4 |     fn foo();
  |     --------- `foo` from trait
...
9 | impl Foo for Bar {}
  | ^^^^^^^^^^^^^^^^ missing `foo` in implementation

error: aborting due to previous error

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

Meta

  • What version of Rust GCC were you using, git sha 562a7824220746c3ce9c803d8fb87cb7cace6ff1.

MahadMuhammad avatar Jul 04 '23 12:07 MahadMuhammad