]> git.lizzy.rs Git - rust.git/blob - src/test/ui/methods/method-self-arg-1.rs
169c14c0f5354b1fac53ae1ee894df3f5ee3174f
[rust.git] / src / test / ui / methods / method-self-arg-1.rs
1 // Test method calls with self as an argument cannot subvert type checking.
2
3 struct Foo;
4
5 impl Foo {
6     fn bar(&self) {}
7 }
8
9 fn main() {
10     let x = Foo;
11     Foo::bar(x); //~  ERROR mismatched types
12                  //~| expected &Foo, found struct `Foo`
13                  //~| expected reference `&Foo`
14                  //~| found struct `Foo`
15     Foo::bar(&42); //~  ERROR mismatched types
16                       //~| expected struct `Foo`, found integer
17                       //~| expected reference `&Foo`
18                       //~| found reference `&{integer}`
19 }