Skip to content

Commit cef19b8

Browse files
committed
Split non-fixable case to different test
1 parent da588e6 commit cef19b8

5 files changed

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

src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ impl<T> GenericAssocMethod<T> {
1111
fn main() {
1212
// Test for inferred types
1313
let x = GenericAssocMethod(33);
14-
// This particular case is unfixable without more information by the user,
15-
// but `cargo fix --broken-code` reports a bug if
16-
// x.default_hello();
1714
GenericAssocMethod::<_>::self_ty_ref_hello(&x);
1815
//~^ ERROR no method named `self_ty_ref_hello` found
1916
GenericAssocMethod::<_>::self_ty_hello(x);

src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ impl<T> GenericAssocMethod<T> {
1111
fn main() {
1212
// Test for inferred types
1313
let x = GenericAssocMethod(33);
14-
// This particular case is unfixable without more information by the user,
15-
// but `cargo fix --broken-code` reports a bug if
16-
// x.default_hello();
1714
x.self_ty_ref_hello();
1815
//~^ ERROR no method named `self_ty_ref_hello` found
1916
x.self_ty_hello();

src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
2-
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:17:7
2+
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:14:7
33
|
44
LL | struct GenericAssocMethod<T>(T);
55
| ---------------------------- method `self_ty_ref_hello` not found for this struct
@@ -18,7 +18,7 @@ LL | fn self_ty_ref_hello(_: &Self) {}
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919

2020
error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
21-
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:19:7
21+
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:16:7
2222
|
2323
LL | struct GenericAssocMethod<T>(T);
2424
| ---------------------------- method `self_ty_hello` not found for this struct
@@ -37,7 +37,7 @@ LL | fn self_ty_hello(_: Self) {}
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3838

3939
error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<i32>` in the current scope
40-
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:23:7
40+
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:20:7
4141
|
4242
LL | struct GenericAssocMethod<T>(T);
4343
| ---------------------------- method `default_hello` not found for this struct
@@ -56,7 +56,7 @@ LL | fn default_hello() {}
5656
| ^^^^^^^^^^^^^^^^^^
5757

5858
error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<i32>` in the current scope
59-
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:25:7
59+
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:22:7
6060
|
6161
LL | struct GenericAssocMethod<T>(T);
6262
| ---------------------------- method `self_ty_ref_hello` not found for this struct
@@ -75,7 +75,7 @@ LL | fn self_ty_ref_hello(_: &Self) {}
7575
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7676

7777
error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<i32>` in the current scope
78-
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:27:7
78+
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:24:7
7979
|
8080
LL | struct GenericAssocMethod<T>(T);
8181
| ---------------------------- method `self_ty_hello` not found for this struct

0 commit comments

Comments
 (0)