rust-lang / rust

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

regression: inference conflicts due to new From imps on Vec<T> #117054

Closed Mark-Simulacrum closed 1 year ago

Mark-Simulacrum commented 1 year ago

This breaks many libraries that depend on the tui crate (see method: https://docs.rs/tui/latest/tui/layout/struct.Layout.html#method.constraints).

[INFO] [stdout] error[E0283]: type annotations needed
[INFO] [stdout]   --> src/app/app_parts.rs:18:14
[INFO] [stdout]    |
[INFO] [stdout] 18 |             .constraints(vec![Constraint::Percentage(15), Constraint::Percentage(85)].as_ref())
[INFO] [stdout]    |              ^^^^^^^^^^^                                                              ------ type must be known at this point
[INFO] [stdout]    |              |
[INFO] [stdout]    |              cannot infer type of the type parameter `C` declared on the method `constraints`
[INFO] [stdout]    |
[INFO] [stdout]    = note: multiple `impl`s satisfying `Vec<Constraint>: AsRef<_>` found in the `alloc` crate:
[INFO] [stdout]            - impl<T, A> AsRef<Vec<T, A>> for Vec<T, A>
[INFO] [stdout]              where A: Allocator;
[INFO] [stdout]            - impl<T, A> AsRef<[T]> for Vec<T, A>
[INFO] [stdout]              where A: Allocator;
[INFO] [stdout] help: consider specifying the generic argument
[INFO] [stdout]    |
[INFO] [stdout] 18 |             .constraints::<&T>(vec![Constraint::Percentage(15), Constraint::Percentage(85)].as_ref())
[INFO] [stdout]    |                         ++++++
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] error: aborting due to previous error

Added in https://github.com/rust-lang/rust/pull/111278.

Around 69 errors likely attributable to this were detected in Crater:

Due to the tui method calls:

Other cases:

apiraino commented 1 year ago

Added in https://github.com/rust-lang/rust/pull/111278 cc @EFanZh

Amanieu commented 1 year ago

We discussed this in the t-libs meeting. We consider this to be acceptable inference breakage due to overly-generic code. We should however add a compatibility note in the release notes.

Mark-Simulacrum commented 1 year ago

Closing - we have a pending comments on the relnotes PR.