Skip to content

Commit a76dc83

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

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
fn is_even(value) -> bool { //~ ERROR expected one of `:`, `@`, or `|`, found `)`
6+
value % 2 == 0
7+
}
8+
9+
struct S;
10+
11+
impl S {
12+
fn is_even(value) -> bool { //~ ERROR expected one of `:`, `@`, or `|`, found `)`
13+
value % 2 == 0
14+
}
15+
}
16+
17+
fn main() {}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error: expected one of `:`, `@`, or `|`, found `)`
2+
--> $DIR/suggest-self-in-bare-function.rs:5: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:12: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: aborting due to 2 previous errors
42+

0 commit comments

Comments
 (0)