improve error when self is used as not the first argument

This commit is contained in:
Axary 2018-11-16 19:27:27 +01:00
parent 646d68f585
commit fe23ffbda0
5 changed files with 30 additions and 13 deletions

View file

@ -1,5 +0,0 @@
fn a(&self) { }
//~^ ERROR unexpected `self` argument in bare function
//~| NOTE invalid argument in bare function
fn main() { }

View 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() { }

View 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() { }

View 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() { }