Skip to content

Location Info error for "associated type bindings" #2368

@MahadMuhammad

Description

@MahadMuhammad

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 8628813.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions