rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.06k stars 12.26k forks source link

coercions do not reach into aggregates - converging coercions #52075

Open gnzlbg opened 6 years ago

gnzlbg commented 6 years ago

This (playground):

fn foo() {}
fn bar() {}
fn main() {
    let _ = [(foo), (bar)]; // OK
    let _ = [(foo,), (bar,)]; // FAILS
}

fails to compile with the following error:

error[E0308]: mismatched types
 --> src/main.rs:5:23
  |
5 |     let _ = [(foo,), (bar,)]; // FAILS
  |                       ^^^ expected fn item, found a different fn item
  |
  = note: expected type `fn() {foo}`
             found type `fn() {bar}`
gnzlbg commented 6 years ago

cc @eddyb

hanna-kruppe commented 6 years ago

Aside: as @eddyb's working example shows, my description of coercions "not reaching into aggregates" is not actually correct.