-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Labels
diagnosticdiagnostic static analysisdiagnostic static analysis
Description
I tried this code: https://godbolt.org/z/9jE9ozo5M
I already have this fix in phil/dev as its making our coercion sites closer to rustc.
struct Foo<A> {
a: A,
}
impl Foo<isize> {
fn bar(self) -> isize {
self.a
}
}
impl Foo<char> {
fn bar(self) -> char {
self.a
}
}
impl<T> Foo<T> {
fn bar(self) -> T {
self.a
}
}
fn main() {
let a = Foo { a: 123 };
a.bar();
}I expected to see this happen:
$ rustc test.rs
error[E0592]: duplicate definitions with name `bar`
--> test.rs:6:5
|
6 | fn bar(self) -> isize {
| ^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `bar`
...
18 | fn bar(self) -> T {
| ----------------- other definition for `bar`
error[E0592]: duplicate definitions with name `bar`
--> test.rs:12:5
|
12 | fn bar(self) -> char {
| ^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `bar`
...
18 | fn bar(self) -> T {
| ----------------- other definition for `bar`
Instead, this happened:
<source>:25:7: error: multiple candidates found for method 'bar'
6 | fn bar(self) -> isize {
| ~~
......
18 | fn bar(self) -> T {
| ~~
......
25 | a.bar();
| ^~~
<source>:25:5: error: failed to type resolve expression
25 | a.bar();
| ^
Meta
- What version of Rust GCC were you using, git sha if possible. 0d4a447
Metadata
Metadata
Assignees
Labels
diagnosticdiagnostic static analysisdiagnostic static analysis
Type
Projects
Status
Todo