|
| 1 | +error[E0308]: mismatched types |
| 2 | + --> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:18:9 |
| 3 | + | |
| 4 | +LL | type F = impl Sized; |
| 5 | + | ---------- the expected opaque type |
| 6 | +... |
| 7 | +LL | let mut x = bar::<F>; |
| 8 | + | -------- expected due to this value |
| 9 | +LL | x = foo::<()>; |
| 10 | + | ^^^^^^^^^ expected fn item, found a different fn item |
| 11 | + | |
| 12 | + = note: expected fn item `fn(F) -> F {bar::<F>}` |
| 13 | + found fn item `fn(()) {foo::<()>}` |
| 14 | + |
| 15 | +error[E0308]: mismatched types |
| 16 | + --> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:27:9 |
| 17 | + | |
| 18 | +LL | fn foo<T>(t: T) -> T { |
| 19 | + | -------------------- function `foo` defined here |
| 20 | +... |
| 21 | +LL | type I = impl Sized; |
| 22 | + | ---------- the found opaque type |
| 23 | +... |
| 24 | +LL | let mut x = bar::<()>; |
| 25 | + | --------- expected due to this value |
| 26 | +LL | x = foo::<I>; |
| 27 | + | ^^^^^^^^ expected fn item, found a different fn item |
| 28 | + | |
| 29 | + = note: expected fn item `fn(()) {bar::<()>}` |
| 30 | + found fn item `fn(I) -> I {foo::<I>}` |
| 31 | +help: use parentheses to call this function |
| 32 | + | |
| 33 | +LL | x = foo::<I>(/* I */); |
| 34 | + | +++++++++ |
| 35 | + |
| 36 | +error[E0308]: `match` arms have incompatible types |
| 37 | + --> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:37:18 |
| 38 | + | |
| 39 | +LL | type J = impl Sized; |
| 40 | + | ---------- the expected opaque type |
| 41 | +... |
| 42 | +LL | let x = match true { |
| 43 | + | _____________- |
| 44 | +LL | | true => bar::<J>, |
| 45 | + | | -------- this is found to be of type `fn(J) -> J {bar::<J>}` |
| 46 | +LL | | false => foo::<()>, |
| 47 | + | | ^^^^^^^^^ expected opaque type, found `()` |
| 48 | +LL | | }; |
| 49 | + | |_____- `match` arms have incompatible types |
| 50 | + | |
| 51 | + = note: expected fn item `fn(J) -> J {bar::<J>}` |
| 52 | + found fn item `fn(()) {foo::<()>}` |
| 53 | + |
| 54 | +error[E0308]: `match` arms have incompatible types |
| 55 | + --> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:52:18 |
| 56 | + | |
| 57 | +LL | fn k() -> impl Sized { |
| 58 | + | ---------- the expected opaque type |
| 59 | +... |
| 60 | +LL | let x = match true { |
| 61 | + | _____________- |
| 62 | +LL | | true => { |
| 63 | +LL | | let f = foo; |
| 64 | +LL | | bind(k(), f) |
| 65 | + | | ------------ this is found to be of type `fn(impl Sized) -> impl Sized {foo::<impl Sized>}` |
| 66 | +LL | | } |
| 67 | +LL | | false => bar::<()>, |
| 68 | + | | ^^^^^^^^^ expected opaque type, found `()` |
| 69 | +LL | | }; |
| 70 | + | |_____- `match` arms have incompatible types |
| 71 | + | |
| 72 | + = note: expected fn item `fn(impl Sized) -> impl Sized {foo::<impl Sized>}` |
| 73 | + found fn item `fn(()) {bar::<()>}` |
| 74 | + |
| 75 | +error: aborting due to 4 previous errors |
| 76 | + |
| 77 | +For more information about this error, try `rustc --explain E0308`. |
0 commit comments