File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -454,6 +454,30 @@ where
454454}
455455```
456456
457+ #### Trait definition cannot use associated types from always applicable impls
458+
459+ The ` T: Trait ` assumption in the trait definition prevents it from normalizing
460+ ` <Self as Trait>::Assoc ` to ` T ` by using the blanket impl. This feels like a somewhat
461+ desirable constraint, if not incredibly so.
462+
463+ ``` rust
464+ trait Eq <T > {}
465+ impl <T > Eq <T > for T {}
466+ struct IsEqual <T : Eq <U >, U >(T , U );
467+
468+ trait Trait : Sized {
469+ type Assoc ;
470+ fn foo () -> IsEqual <Self , Self :: Assoc > {
471+ // ~^ ERROR the trait bound `Self: Eq<<Self as Trait>::Assoc>` is not satisfied
472+ todo! ()
473+ }
474+ }
475+
476+ impl <T > Trait for T {
477+ type Assoc = T ;
478+ }
479+ ```
480+
457481[ `Candidate` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_next_trait_solver/solve/assembly/struct.Candidate.html
458482[ `CandidateSource` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_next_trait_solver/solve/enum.CandidateSource.html
459483[ `fn merge_trait_candidates` ] : https://github.com/rust-lang/rust/blob/e3ee7f7aea5b45af3b42b5e4713da43876a65ac9/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs#L1342-L1424
You can’t perform that action at this time.
0 commit comments