]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/call-on-missing.rs
Auto merge of #106696 - kylematsuda:early-binder, r=lcnr
[rust.git] / tests / ui / suggestions / call-on-missing.rs
1 struct Foo { i: i32 }
2
3 impl Foo {
4     fn bar(&self) {}
5 }
6
7 fn foo() -> Foo {
8     Foo { i: 1 }
9 }
10
11 fn main() {
12     foo.bar();
13     //~^ ERROR no method named `bar`
14     //~| HELP use parentheses to call this function
15
16     foo.i;
17     //~^ ERROR no field `i`
18     //~| HELP use parentheses to call this function
19
20     let callable = Box::new(|| Foo { i: 1 }) as Box<dyn Fn() -> Foo>;
21
22     callable.bar();
23     //~^ ERROR no method named `bar`
24     //~| HELP use parentheses to call this trait object
25
26     callable.i;
27     //~^ ERROR no field `i`
28     //~| HELP use parentheses to call this trait object
29 }
30
31 fn type_param<T: Fn() -> Foo>(t: T) {
32     t.bar();
33     //~^ ERROR no method named `bar`
34     //~| HELP use parentheses to call this type parameter
35
36     t.i;
37     //~^ ERROR no field `i`
38     //~| HELP use parentheses to call this type parameter
39 }