Description
Code
#![allow(unused_associated_type_bounds)]
pub trait Other {}
pub trait Trait {
type Assoc where Self: Sized;
}
impl Other for dyn Trait {}
impl Other for dyn Trait<Assoc = ()> {}
impl<T> dyn Trait<Assoc = T> {}
I expected to see this happen: successful compilation.
Instead, this happened:
error[E0119]: conflicting implementations of trait `Other` for type `(dyn Trait + 'static)`
--> src/lib.rs:9:1
|
8 | impl Other for dyn Trait {}
| ------------------------ first implementation here
9 | impl Other for dyn Trait<Assoc = ()> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Trait + 'static)`
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> src/lib.rs:10:6
|
10 | impl<T> dyn Trait<Assoc = T> {}
| ^ unconstrained type parameter
Some errors have detailed explanations: E0119, E0207.
For more information about an error, try `rustc --explain E0119`.
Version it worked on
It most recently worked on: Rust 1.86.0
Version with regression
Playground: Beta version: 1.87.0-beta.8 (2025-05-03 973ec11)
More notes
CC #125560
Before Beta, dyn Trait
and dyn Trait<Assoc = ()>
were different types. Now they are the same type.
Here's a more complete example that makes practical (albeit contrived) use of distinct dyn Trait<Assoc = ...>
types.
Considering the release notes, #136458 may be the cause (but there's no discussion about this change in particular). Assuming this is the case and the use case that broke is considered unimportant, this aspect of the change could at least be mentioned in the release notes.
Incidentally, this also means dyn Trait<Assoc = &'can_be_non_static str>
meets a 'static
bound now. Hopefully irrelevant, but it does seem like an exception to outlive bounds being syntactical.
@rustbot modify labels: +regression-from-stable-to-beta, -regression-untriaged