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

Location Info error for "multiple applicable items in scope for: test" #2366

Closed
MahadMuhammad opened this issue Jul 3, 2023 · 0 comments · Fixed by #2560
Closed

Location Info error for "multiple applicable items in scope for: test" #2366

MahadMuhammad opened this issue Jul 3, 2023 · 0 comments · Fixed by #2560
Labels

Comments

@MahadMuhammad
Copy link
Contributor

MahadMuhammad commented Jul 3, 2023

I tried this code:

// https://doc.rust-lang.org/error_codes/E0034.html
struct Test;

trait Trait1 {
    fn foo();
}

trait Trait2 {
    fn foo();
}

impl Trait1 for Test { fn foo() {} }
impl Trait2 for Test { fn foo() {} }

fn main() {
    Test::foo() // { dg-error "multiple applicable items in scope for: test" } 
    // error, which foo() to call?
}

This happened:

  • Location info was not clear.
gcc/crab1 ../mahad-testsuite/E0034.rs  -frust-incomplete-and-experimental-compiler-do-not-use
../mahad-testsuite/E0034.rs:16:11: error: multiple applicable items in scope for: foo
-   12 | impl Trait1 for Test { fn foo() {} }
-      |                        ^^^^^^^^
+   12 | impl Trait1 for Test { fn foo() {} }
+      |                        ~~
-   13 | impl Trait2 for Test { fn foo() {} }
-      |                        ^^^^^^^^
+   13 | impl Trait2 for Test { fn foo() {} }
+      |                        ~~
......
+   16 |     Test::foo() // { dg-error "multiple applicable items in scope for: test" }
-      |           ^^^ multiple `foo` found
+      |           ^~~

../mahad-testsuite/E0034.rs:16:5: error: Failed to resolve expression of function call
   16 |     Test::foo() // { dg-error "multiple applicable items in scope for: test" }
      |     ^~~~

Analyzing compilation unit

Time variable                                   usr           sys          wall           GGC
 phase parsing                      :   0.00 (  0%)   0.00 (  0%)   0.01 (100%)  8192  (  5%)
 parser (global)                    :   0.00 (  0%)   0.00 (  0%)   0.01 (100%)  8192  (  5%)
 TOTAL                              :   0.00          0.00          0.01          146k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

I expected to see this happen:

  • Location info similiar to rustc-1.49.
mahad@linux:~/Desktop/mahad/gccrs-build$ rustc ../mahad-testsuite/E0034.rs  
error[E0034]: multiple applicable items in scope
  --> ../mahad-testsuite/E0034.rs:16:11
   |
16 |     Test::foo() // { dg-error "multiple applicable items in scope for: test" } 
   |           ^^^ multiple `foo` found
   |
note: candidate #1 is defined in an impl of the trait `Trait1` for the type `Test`
  --> ../mahad-testsuite/E0034.rs:12:24
   |
12 | impl Trait1 for Test { fn foo() {} }
   |                        ^^^^^^^^
note: candidate #2 is defined in an impl of the trait `Trait2` for the type `Test`
  --> ../mahad-testsuite/E0034.rs:13:24
   |
13 | impl Trait2 for Test { fn foo() {} }
   |                        ^^^^^^^^
help: disambiguate the associated function for candidate #1
   |
16 |     Trait1::foo() // { dg-error "multiple applicable items in scope for: test" } 
   |     ^^^^^^^^^^^
help: disambiguate the associated function for candidate #2
   |
16 |     Trait2::foo() // { dg-error "multiple applicable items in scope for: test" } 
   |     ^^^^^^^^^^^

error: aborting due to previous error

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

Meta

  • What version of Rust GCC were you using, git sha 5d33b88.
MahadMuhammad added a commit to MahadMuhammad/gccrs that referenced this issue Aug 15, 2023
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
github-merge-queue bot pushed a commit that referenced this issue Aug 17, 2023
Multiple items found with same prototype.
Fixes: #2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 15, 2023
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 21, 2023
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 21, 2023
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 5, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 8, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 11, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 12, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 16, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 16, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
nstester pushed a commit to nstester/gcc that referenced this issue Jan 16, 2024
Multiple items found with same prototype.
Fixes: Rust-GCC/gccrs#2366

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.h:
	Fixes issue & added rich location message.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added rich location and error code.

gcc/testsuite/ChangeLog:

	* rust/compile/generics6.rs: Updated dejagnu comment.
	* rust/compile/generics7.rs: likewise.
	* rust/compile/issue-925.rs: likewise.

Signed-off-by: Muhammad Mahad <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant