Skip to content

Commit 8cf9ad6

Browse files
committed
diagnostics: add test case for issue 102354
1 parent b205a5a commit 8cf9ad6

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
trait Trait {
2+
fn func() {}
3+
}
4+
5+
impl Trait for i32 {}
6+
7+
fn main() {
8+
let x: i32 = 123;
9+
x.func(); //~ERROR no method
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0599]: no method named `func` found for type `i32` in the current scope
2+
--> $DIR/issue-102354.rs:9:7
3+
|
4+
LL | x.func();
5+
| ^^^^ this is an associated function, not a method
6+
|
7+
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
8+
note: the candidate is defined in the trait `Trait`
9+
--> $DIR/issue-102354.rs:2:5
10+
|
11+
LL | fn func() {}
12+
| ^^^^^^^^^
13+
help: use associated function syntax instead
14+
|
15+
LL | i32::func();
16+
| ~~~~~~~~~
17+
help: disambiguate the associated function for the candidate
18+
|
19+
LL | <i32 as Trait>::func(x);
20+
| ~~~~~~~~~~~~~~~~~~~~~~~
21+
22+
error: aborting due to previous error
23+
24+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)