Skip to content

Commit 9a0b71c

Browse files
committed
merge bare-fn-start.rs and trait-fn.rs into invalid-self-argument.rs
1 parent 427a3ad commit 9a0b71c

File tree

6 files changed

+36
-40
lines changed

6 files changed

+36
-40
lines changed

tests/ui/self/bare-fn-start.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/self/bare-fn-start.stderr

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1-
fn b(foo: u32, &mut self) { }
1+
//! regression test for <https://github.com/rust-lang/rust/issues/55972>
2+
3+
fn a(&self) {}
4+
//~^ ERROR `self` parameter is only allowed in associated functions
5+
//~| NOTE not semantically valid as function parameter
6+
//~| NOTE associated functions are those in `impl` or `trait` definitions
7+
8+
fn b(foo: u32, &mut self) {}
29
//~^ ERROR unexpected `self` parameter in function
310
//~| NOTE must be the first parameter of an associated function
411

5-
fn main() { }
12+
struct Foo {}
13+
14+
impl Foo {
15+
fn c(foo: u32, self) {}
16+
//~^ ERROR unexpected `self` parameter in function
17+
//~| NOTE must be the first parameter of an associated function
18+
19+
fn good(&mut self, foo: u32) {}
20+
}
21+
22+
fn main() {}
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
error: unexpected `self` parameter in function
2-
--> $DIR/bare-fn.rs:1:16
2+
--> $DIR/invalid-self-argument.rs:8:16
33
|
4-
LL | fn b(foo: u32, &mut self) { }
4+
LL | fn b(foo: u32, &mut self) {}
55
| ^^^^^^^^^ must be the first parameter of an associated function
66

7-
error: aborting due to 1 previous error
7+
error: unexpected `self` parameter in function
8+
--> $DIR/invalid-self-argument.rs:15:20
9+
|
10+
LL | fn c(foo: u32, self) {}
11+
| ^^^^ must be the first parameter of an associated function
12+
13+
error: `self` parameter is only allowed in associated functions
14+
--> $DIR/invalid-self-argument.rs:3:6
15+
|
16+
LL | fn a(&self) {}
17+
| ^^^^^ not semantically valid as function parameter
18+
|
19+
= note: associated functions are those in `impl` or `trait` definitions
20+
21+
error: aborting due to 3 previous errors
822

tests/ui/self/trait-fn.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/ui/self/trait-fn.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)