Fix accidental type inference in array coercion by adwinwhite · Pull Request #140283 · rust-lang/rust (original) (raw)
Please add a test to demonstrate the effect of this change. Especially since with this change, we would be accepting more code than on master
(this is the snippet in the original issue):
fn foo() {} fn bar() {}
fn main() { let _a = if true { foo } else { bar }; let _b = vec![foo, bar]; let _c = [foo, bar]; d(if true { foo } else { bar }); e(vec![foo, bar]); f([foo, bar]); // <- this PR now accepts this }
fn d(: T) {} fn e(: Vec) {} fn f(_: [T; 2]) {}
whereas on master
this snippet does not compile w/
error[E0308]: mismatched types
--> src/main.rs:10:7
|
10 | f([foo, bar]);
| - ^^^^^^^^^^ expected `[fn() {foo}; 2]`, found `[fn(); 2]`
| |
| arguments to this function are incorrect
|
= note: expected array `[fn() {foo}; 2]`
found array `[fn(); 2]`
note: function defined here
--> src/main.rs:15:4
|
15 | fn f<T>(_: [T; 2]) {}
| ^ ---------
For more information about this error, try `rustc --explain E0308`.
I'm surprised there are no ui test diffs.