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
{{ message }}
Repository navigation
Type checker doesn't consider trait duality when reasoning about type parameters for associated types #38917
Trait resolution basically doesn't know how to figure out that two types are equal in the case of "dual traits".
This is one of the inevitable issues @nox is going to hit in his Servo script bindings refactor 😉
I do wish we had a more formalized notion of type families that could be used to better instruct the compiler in these cases. @nikomatsakis was talking about this in his blog, and I've personally found the need for a family-trait type situation more than once, both when modeling dualities and when modeling generic abstractions over sets of types like you're trying to do.
error[E0277]: the trait bound `<D as DomTraversal<<E as TElement>::ConcreteNode>>::BorrowElement: std::borrow::Borrow<E>` is not satisfied
--> src/main.rs:15:1
|
11 | trait DomTraversal<N: TNode> {
| ---------------------------- required by `DomTraversal`
...
15 | / fn recalc_style_at<E, D>()
16 | | where E: TElement,
17 | | D: DomTraversal<E::ConcreteNode>,
| | - help: consider further restricting the associated type: `, <D as DomTraversal<<E as TElement>::ConcreteNode>>::BorrowElement: std::borrow::Borrow<E>`
18 | | {
19 | | }
| |_^ the trait `std::borrow::Borrow<E>` is not implemented for `<D as DomTraversal<<E as TElement>::ConcreteNode>>::BorrowElement`
Activity
Manishearth commentedon Jan 8, 2017
Trait resolution basically doesn't know how to figure out that two types are equal in the case of "dual traits".
This is one of the inevitable issues @nox is going to hit in his Servo script bindings refactor 😉
I do wish we had a more formalized notion of type families that could be used to better instruct the compiler in these cases. @nikomatsakis was talking about this in his blog, and I've personally found the need for a family-trait type situation more than once, both when modeling dualities and when modeling generic abstractions over sets of types like you're trying to do.
Bug 1325734 - Parameterize the style traversal on TElement instead of…
Bug 1325734 - Parameterize the style traversal on TElement instead of…
Mark-Simulacrum commentedon May 19, 2017
This appears to work today; E-needstest.
nikomatsakis commentedon May 25, 2017
I don't think it works necessarily -- if you remove the bound that @bholley highlighted, you still get an error.
nikomatsakis commentedon May 25, 2017
The example that @bholley expected to pass (and I think he is right that it should) is this one:
estebank commentedon Nov 5, 2019
Current output:
Rollup merge of rust-lang#81485 - jackh726:atb-issues, r=Mark-Simulacrum