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 upWebidl lint #23200
Webidl lint #23200
Conversation
highfive
commented
Apr 14, 2019
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @SimonSapin (or someone else) soon. |
highfive
commented
Apr 14, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Apr 14, 2019
| } | ||
| } | ||
|
|
||
| fn get_typ_name(typ: String) -> String { |
This comment has been minimized.
This comment has been minimized.
KiChjang
Apr 14, 2019
Member
- Since
typeis a keyword, by convention we usually shorten it toty. - Is
get_typ_namea typo? - Can this function receive a
&strinstead of aString?
This comment has been minimized.
This comment has been minimized.
| dir.push("components/script/dom/webidls/"); | ||
| dir.push(format!("{}.webidl", struct_name)); | ||
|
|
||
| return Ok(dir); |
This comment has been minimized.
This comment has been minimized.
|
|
|
|
||
| impl fmt::Display for WebIdlError { | ||
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
| match self { |
This comment has been minimized.
This comment has been minimized.
KiChjang
Apr 16, 2019
Member
It is sort of weird seeing a match here being used solely for destructuring. You can actually instead do the following:
let WebIdlError { name, rust_parent, webidl_parent } = self;or simply just use self.name, self.rust_parent and self.webidl_parent without destructuring.
| rust_parent, | ||
| webidl_parent, | ||
| } => { | ||
| return write!(f, "webidl-rust inheritance mismatch, rust: {:?}, rust parent: {:?}, webidl parent: {:?}", |
This comment has been minimized.
This comment has been minimized.
KiChjang
Apr 16, 2019
•
Member
Following on my review comment above, I would actually write this in a one-liner:
// Note the lack of the return keyword
write!(f, "webidl-rust inheritance mismatch, rust: {:?}, rust parent, {:?}, WebIDL parent: {:?}", self.name, self.rust_parent, self.webidl_parent)
This comment has been minimized.
This comment has been minimized.
krk
Apr 16, 2019
Author
Contributor
This one does not compile as WebIdlError contains a member ParentMismatch.
This comment has been minimized.
This comment has been minimized.
|
|
||
| let ty: String; | ||
| let mut parent_name: Option<&str> = None; | ||
| for ref field in def.fields() { |
This comment has been minimized.
This comment has been minimized.
KiChjang
Apr 16, 2019
Member
let parent_name = def.fields().next().map(|field| {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(field.hir_id);
let ty = cx.tcx.type_of(def_id);
get_ty_name(ty).to_string()
});
|
|
Wait a minute, this doesn't look like the correct change... when there's a |
|
The lint passes for |
|
I think we should special case |
|
Oh, I didn't know that you were already asking for solutions in the original issue. Please follow what @jdm has advised and ignore my comments. |
|
|
|
@jdm, @KiChjang; now that the changes #20461 (comment) and #20461 (comment) are committed, do you think that this PR is mergeable? |
|
@bors-servo r+ |
|
|
Webidl lint Parse webidl files and lint for inheritance correctness. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #20461 <!-- 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/23200) <!-- Reviewable:end -->
|
|
|
@KiChjang thanks for the comprehensive review! |
krk commentedApr 14, 2019
•
edited
Parse webidl files and lint for inheritance correctness.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is