1 error[E0308]: mismatched types
2 --> $DIR/as-ref.rs:7:29
4 LL | opt.map(|arg| takes_ref(arg));
5 | --- --------- ^^^ expected `&Foo`, found struct `Foo`
7 | | arguments to this function are incorrect
8 | help: consider using `as_ref` instead: `as_ref().map`
10 note: function defined here
11 --> $DIR/as-ref.rs:3:4
13 LL | fn takes_ref(_: &Foo) {}
16 error[E0308]: mismatched types
17 --> $DIR/as-ref.rs:8:39
19 LL | opt.and_then(|arg| Some(takes_ref(arg)));
20 | -------- --------- ^^^ expected `&Foo`, found struct `Foo`
22 | | arguments to this function are incorrect
23 | help: consider using `as_ref` instead: `as_ref().and_then`
25 note: function defined here
26 --> $DIR/as-ref.rs:3:4
28 LL | fn takes_ref(_: &Foo) {}
31 error[E0308]: mismatched types
32 --> $DIR/as-ref.rs:10:29
34 LL | opt.map(|arg| takes_ref(arg));
35 | --- --------- ^^^ expected `&Foo`, found struct `Foo`
37 | | arguments to this function are incorrect
38 | help: consider using `as_ref` instead: `as_ref().map`
40 note: function defined here
41 --> $DIR/as-ref.rs:3:4
43 LL | fn takes_ref(_: &Foo) {}
46 error[E0308]: mismatched types
47 --> $DIR/as-ref.rs:11:37
49 LL | opt.and_then(|arg| Ok(takes_ref(arg)));
50 | -------- --------- ^^^ expected `&Foo`, found struct `Foo`
52 | | arguments to this function are incorrect
53 | help: consider using `as_ref` instead: `as_ref().and_then`
55 note: function defined here
56 --> $DIR/as-ref.rs:3:4
58 LL | fn takes_ref(_: &Foo) {}
61 error[E0308]: mismatched types
62 --> $DIR/as-ref.rs:13:29
64 LL | let y: Option<&usize> = x;
67 | | expected enum `Option`, found `&Option<usize>`
68 | | help: you can convert from `&Option<T>` to `Option<&T>` using `.as_ref()`: `x.as_ref()`
69 | expected due to this
71 = note: expected enum `Option<&usize>`
72 found reference `&Option<usize>`
74 error[E0308]: mismatched types
75 --> $DIR/as-ref.rs:15:37
77 LL | let y: Result<&usize, &usize> = x;
78 | ---------------------- ^ expected enum `Result`, found reference
80 | expected due to this
82 = note: expected enum `Result<&usize, &usize>`
83 found reference `&Result<usize, usize>`
84 help: you can convert from `&Result<T, E>` to `Result<&T, &E>` using `.as_ref()`
86 LL | let y: Result<&usize, &usize> = x.as_ref();
89 error[E0308]: mismatched types
90 --> $DIR/as-ref.rs:19:36
92 LL | let y: Result<&usize, usize> = x;
93 | --------------------- ^ expected enum `Result`, found reference
95 | expected due to this
97 = note: expected enum `Result<&usize, usize>`
98 found reference `&Result<usize, usize>`
100 error: aborting due to 7 previous errors
102 For more information about this error, try `rustc --explain E0308`.