Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace inheritance_integrity by trait shenanigans #15567
Conversation
Oops.
| } else { | ||
| panic!("#[derive(DomObject)] should only be applied on proper structs") | ||
| }; | ||
|
|
||
| let first_field_name = fields | ||
| .first() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Is this covered by existing compile-fail tests? Reviewed 1 of 1 files at r1, 3 of 4 files at r2, 1 of 1 files at r3. components/domobject_derive/lib.rs, line 67 at r3 (raw file):
This could use a code comment, in particular components/plugins/lints/inheritance_integrity.rs, line 30 at r3 (raw file):
Since this is removed, I think components/plugins/lints/inheritance_integrity.rs, line 34 at r3 (raw file):
I think this was the last use of Comments from Reviewable |
For each derived DomObject impl, we also generate a dummy trait
ShouldNotImplDomObject that is implemented for all T: DomObject.
We then try to implement it for each field type except the first one.
If compilation succeed, this means that field type doesn't implement
DomObject itself otherwise it would break coherence rules.
error[E0119]: conflicting implementations of trait `dom::xmlhttprequest::_IMPL_DOMOBJECT_FOR_XMLHttpRequest::ShouldNotImplDomObject` for type `((), SomeFieldTypeThatShouldNotImplementDomObject)`:
--> /Users/nox/src/servo/components/script/dom/xmlhttprequest.rs:120:1
|
120 | #[dom_struct]
| ^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `((), SomeFieldTypeThatShouldNotImplementDomObject)`
|
@SimonSapin Addressed your remarks. |
|
It's quite involved to make a test for it because you need to redefine the traits etc, given they are defined in |
|
@bors-servo r+ Reviewed 5 of 5 files at r4, 1 of 1 files at r5. Comments from Reviewable |
|
|
Replace inheritance_integrity by trait shenanigans <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15567) <!-- Reviewable:end -->
|
|
|
@bors-servo retry #15583 |
|
|
|
|
nox commentedFeb 15, 2017
•
edited by larsbergstrom
This change is