Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak self arg not as first argument of a method diagnostic #61087

Merged
merged 3 commits into from
May 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
588 changes: 580 additions & 8 deletions src/libsyntax/parse/diagnostics.rs

Large diffs are not rendered by default.

587 changes: 43 additions & 544 deletions src/libsyntax/parse/parser.rs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/test/ui/invalid-self-argument/bare-fn-start.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fn a(&self) { }
//~^ ERROR unexpected `self` argument in function
//~| NOTE `self` is only valid as the first argument of an associated function
//~^ ERROR unexpected `self` parameter in function
//~| NOTE not valid as function parameter
//~| NOTE `self` is only valid as the first parameter of an associated function

fn main() { }
8 changes: 5 additions & 3 deletions src/test/ui/invalid-self-argument/bare-fn-start.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error: unexpected `self` argument in function
--> $DIR/bare-fn-start.rs:1:7
error: unexpected `self` parameter in function
--> $DIR/bare-fn-start.rs:1:6
|
LL | fn a(&self) { }
| ^^^^ `self` is only valid as the first argument of an associated function
| ^^^^^ not valid as function parameter
|
= note: `self` is only valid as the first parameter of an associated function

error: aborting due to previous error

5 changes: 3 additions & 2 deletions src/test/ui/invalid-self-argument/bare-fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fn b(foo: u32, &mut self) { }
//~^ ERROR unexpected `self` argument in function
//~| NOTE `self` is only valid as the first argument of an associated function
//~^ ERROR unexpected `self` parameter in function
//~| NOTE not valid as function parameter
//~| NOTE `self` is only valid as the first parameter of an associated function

fn main() { }
8 changes: 5 additions & 3 deletions src/test/ui/invalid-self-argument/bare-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error: unexpected `self` argument in function
--> $DIR/bare-fn.rs:1:21
error: unexpected `self` parameter in function
--> $DIR/bare-fn.rs:1:16
|
LL | fn b(foo: u32, &mut self) { }
| ^^^^ `self` is only valid as the first argument of an associated function
| ^^^^^^^^^ not valid as function parameter
|
= note: `self` is only valid as the first parameter of an associated function

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/invalid-self-argument/trait-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ struct Foo {}

impl Foo {
fn c(foo: u32, self) {}
//~^ ERROR unexpected `self` argument in function
//~| NOTE `self` is only valid as the first argument of an associated function
//~^ ERROR unexpected `self` parameter in function
//~| NOTE must be the first associated function parameter

fn good(&mut self, foo: u32) {}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/invalid-self-argument/trait-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: unexpected `self` argument in function
error: unexpected `self` parameter in function
--> $DIR/trait-fn.rs:4:20
|
LL | fn c(foo: u32, self) {}
| ^^^^ `self` is only valid as the first argument of an associated function
| ^^^^ must be the first associated function parameter

error: aborting due to previous error

3 changes: 3 additions & 0 deletions src/test/ui/parser/self-in-function-arg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn foo(x:i32, self: i32) -> i32 { self } //~ ERROR unexpected `self` parameter in function

fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui/parser/self-in-function-arg.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: unexpected `self` parameter in function
--> $DIR/self-in-function-arg.rs:1:15
|
LL | fn foo(x:i32, self: i32) -> i32 { self }
| ^^^^ not valid as function parameter
|
= note: `self` is only valid as the first parameter of an associated function

error: aborting due to previous error