Location Info error for "associated type bindings"

Open
#2,368 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, rust
Domain
compilers

Research direction

Start with gcc/testsuite/rust/compile/type-bindings1.rs and reproduce the diagnostic using gcc/crab1 with -frust-incomplete-and-experimental-compiler-do-not-use. Compare the caret ranges and messages with the rustc-1.49 output shown in the issue, then update the compiler diagnostics so the test reports the expected location information and passes.

Written by the indexing model from the issue text.

Description

bug

Location Info error

I tried this code:
struct Foo<A, B>(A, B);

fn main() {
    let a;
    a = Foo::<A = i32, B = f32>(123f32);
    // { dg-error ErrorCode("E0229") "associated type bindings are not allowed here" "" { target *-*-* } .-1 }
    // { dg-error {Failed to resolve expression of function call} "" { target *-*-* } .-2 }
}
This happened:
  • Location info was not clear.
mahad@linux:~/Desktop/mahad/gccrs-build$ gcc/crab1 /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs -frust-incomplete-and-experimental-compiler-do-not-use
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs:5:15: error: associated type bindings are not allowed here [E0229]
    5 |     a = Foo::<A = i32, B = f32>(123f32);
-     |               ^^^^^^^ associated type not allowed here
+     |               ^        ~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs:5:9: error: Failed to resolve expression of function call
    5 |     a = Foo::<A = i32, B = f32>(123f32);
-     |         ^^^^^^^^^^^^^^^^^^^^^^^ ------ supplied 1 argument
-     |         |
-     |         expected 2 arguments
+     |         ^~~
I expected to see this happen:
  • Location info similiar to rustc-1.49.
  • This is the output of rust-1.49:
mahad@linux:~/Desktop/mahad/gccrs-build$ rustc /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs
error[E0229]: associated type bindings are not allowed here
 --> /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs:5:15
  |
5 |     a = Foo::<A = i32, B = f32>(123f32);
  |               ^^^^^^^ associated type not allowed here

error[E0061]: this function takes 2 arguments but 1 argument was supplied
 --> /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs:5:9
  |
5 |     a = Foo::<A = i32, B = f32>(123f32);
  |         ^^^^^^^^^^^^^^^^^^^^^^^ ------ supplied 1 argument
  |         |
  |         expected 2 arguments
  |
note: tuple struct defined here
 --> /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/type-bindings1.rs:1:1
  |
1 | struct Foo<A, B>(A, B);
  | ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0061, E0229.
For more information about an error, try `rustc --explain E0061`.
Meta
  • What version of Rust GCC were you using, git sha 8628813ff9770a08fb6ac89a6f501b5138acc79b.
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
20h 2m
Merged PRs (30d)
66

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rust-GCC/gccrs

All issues in Rust-GCC/gccrs

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.