You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiles successfully on rustc 1.52.1 (9bc8c42bb 2021-05-09), errors on rustc 1.54.0-nightly (3e99439f4 2021-05-17):
error[E0283]:type annotations needed
--> src/main.rs:6:56
|
6 | Some((1,(None::<i32>,None::<i32>.into_iter().collect())))
| ^^^^^^^ cannot infer typefortype parameter `B` declared on the associated function `collect`
|
= note: cannot satisfy `_:FromIterator<i32>`
help:consider specifying the type argument in the method call
|
6 | Some((1,(None::<i32>,None::<i32>.into_iter().collect::<B>())))
| ^^^^^
error: aborting due to previous error
Now this code heavily relies on type inference, and it would be easy to make it less so by adding an annotation as suggested by the compiler. However I still wanted to understand why this errors happens in one case but not the other.
At first I suspected that a new standard library impl made inference ambiguous where it wasn’t before, but the same error also happens with older Nightlies from before 1.52 was branched.
The difference turns out to be im-rs enabling impl specialization when building on the Nightly channel:
The FromIterator impls involve From conversions of items, but the map value in the example is a tuple and tuples don’t implement From other than for the identity conversion.
The text was updated successfully, but these errors were encountered:
Test case (reduced for macro-generated unit tests):
Compiles successfully on
rustc 1.52.1 (9bc8c42bb 2021-05-09)
, errors onrustc 1.54.0-nightly (3e99439f4 2021-05-17)
:Now this code heavily relies on type inference, and it would be easy to make it less so by adding an annotation as suggested by the compiler. However I still wanted to understand why this errors happens in one case but not the other.
At first I suspected that a new standard library impl made inference ambiguous where it wasn’t before, but the same error also happens with older Nightlies from before 1.52 was branched.
The difference turns out to be
im-rs
enabling impl specialization when building on the Nightly channel:im-rs/build.rs
Lines 9 to 13 in 3f4e01a
If I remove this
println
(effectively disabling specialization) the test case compiles successfully on Nightly.I tried but failed to reproduce the error without the full
im-rs
crate by using this instead:Possible it’s adding some other impl that causes inference ambiguity, but reading through docs I don’t see what would be relevant:
The
FromIterator
impls involveFrom
conversions of items, but the map value in the example is a tuple and tuples don’t implementFrom
other than for the identity conversion.The text was updated successfully, but these errors were encountered: