improve error when self is used as not the first argument
This commit is contained in:
parent
646d68f585
commit
fe23ffbda0
5 changed files with 30 additions and 13 deletions
|
|
@ -1,5 +0,0 @@
|
|||
fn a(&self) { }
|
||||
//~^ ERROR unexpected `self` argument in bare function
|
||||
//~| NOTE invalid argument in bare function
|
||||
|
||||
fn main() { }
|
||||
5
src/test/ui/invalid-self-argument/bare-fn-start.rs
Normal file
5
src/test/ui/invalid-self-argument/bare-fn-start.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn a(&self) { }
|
||||
//~^ ERROR unexpected `self` argument in function
|
||||
//~| NOTE `self` is only valid as the first argument of a trait function
|
||||
|
||||
fn main() { }
|
||||
5
src/test/ui/invalid-self-argument/bare-fn.rs
Normal file
5
src/test/ui/invalid-self-argument/bare-fn.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn b(foo: u32, &mut self) { }
|
||||
//~^ ERROR unexpected `self` argument in function
|
||||
//~| NOTE `self` is only valid as the first argument of a trait function
|
||||
|
||||
fn main() { }
|
||||
11
src/test/ui/invalid-self-argument/trait-fn.rs
Normal file
11
src/test/ui/invalid-self-argument/trait-fn.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
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 a trait function
|
||||
|
||||
fn good(&mut self, foo: u32) {}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
Loading…
Add table
Add a link
Reference in a new issue