Skip to content

Commit f5bc295

Browse files
committed
Add test suggest-self-in-bare-function
Signed-off-by: xizheyin <[email protected]>
1 parent 8e77954 commit f5bc295

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// We should not suggest `self` in bare functions.
2+
// And a note for RFC 1685 should not be shown.
3+
// See #144968
4+
5+
//@ edition:2018
6+
7+
fn is_even(value) -> bool { //~ ERROR expected one of `:`, `@`, or `|`, found `)`
8+
value % 2 == 0
9+
}
10+
11+
struct S;
12+
13+
impl S {
14+
fn is_even(value) -> bool { //~ ERROR expected one of `:`, `@`, or `|`, found `)`
15+
value % 2 == 0
16+
}
17+
}
18+
19+
trait T {
20+
fn is_even(value) -> bool { //~ ERROR expected one of `:`, `@`, or `|`, found `)`
21+
value % 2 == 0
22+
}
23+
}
24+
25+
fn main() {}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
error: expected one of `:`, `@`, or `|`, found `)`
2+
--> $DIR/suggest-self-in-bare-function.rs:7:17
3+
|
4+
LL | fn is_even(value) -> bool {
5+
| ^ expected one of `:`, `@`, or `|`
6+
|
7+
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
8+
help: if this is a `self` type, give it a parameter name
9+
|
10+
LL | fn is_even(self: value) -> bool {
11+
| +++++
12+
help: if this is a parameter name, give it a type
13+
|
14+
LL | fn is_even(value: TypeName) -> bool {
15+
| ++++++++++
16+
help: if this is a type, explicitly ignore the parameter name
17+
|
18+
LL | fn is_even(_: value) -> bool {
19+
| ++
20+
21+
error: expected one of `:`, `@`, or `|`, found `)`
22+
--> $DIR/suggest-self-in-bare-function.rs:14:21
23+
|
24+
LL | fn is_even(value) -> bool {
25+
| ^ expected one of `:`, `@`, or `|`
26+
|
27+
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
28+
help: if this is a `self` type, give it a parameter name
29+
|
30+
LL | fn is_even(self: value) -> bool {
31+
| +++++
32+
help: if this is a parameter name, give it a type
33+
|
34+
LL | fn is_even(value: TypeName) -> bool {
35+
| ++++++++++
36+
help: if this is a type, explicitly ignore the parameter name
37+
|
38+
LL | fn is_even(_: value) -> bool {
39+
| ++
40+
41+
error: expected one of `:`, `@`, or `|`, found `)`
42+
--> $DIR/suggest-self-in-bare-function.rs:20:21
43+
|
44+
LL | fn is_even(value) -> bool {
45+
| ^ expected one of `:`, `@`, or `|`
46+
|
47+
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
48+
help: if this is a `self` type, give it a parameter name
49+
|
50+
LL | fn is_even(self: value) -> bool {
51+
| +++++
52+
help: if this is a parameter name, give it a type
53+
|
54+
LL | fn is_even(value: TypeName) -> bool {
55+
| ++++++++++
56+
help: if this is a type, explicitly ignore the parameter name
57+
|
58+
LL | fn is_even(_: value) -> bool {
59+
| ++
60+
61+
error: aborting due to 3 previous errors
62+

0 commit comments

Comments
 (0)