-
Notifications
You must be signed in to change notification settings - Fork 136
Return more specific errors from parsing APIs #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Since servo/servo#16752 is ready for review, please review this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks overall pretty great to me.
I'm curious about which non-UnexpectedEof
errors you're seeing coming from Tokenizer::next
(what other errors can it possibly return?), and I have a few minor nits around.
Probably @SimonSapin wants to take a look, since he was looking into parsing performance and this has a potential impact on that (though probably not too much).
I also wonder if we could (ab)use the UnexpectedToken
errors to do a bit less tokenization in Servo...
Awesome job overall!
src/parser.rs
Outdated
Ok(_) => { | ||
Err(()) | ||
} | ||
//FIXME: swallowing non-UnexpectedEof errors seems wrong, but tests fail otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh... Could you file an issue with more details, and perhaps an example, and reference it here, just to see if it's something expected or not? Which other errors are reported?
(also, uber-nit: a space after //
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #144.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look at #144, It's legit and we should remove the fixme and perhaps add a comment there.
src/rules_and_declarations.rs
Outdated
@@ -52,6 +52,9 @@ pub trait DeclarationParser { | |||
/// The finished representation of a declaration. | |||
type Declaration; | |||
|
|||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docs? :)
src/rules_and_declarations.rs
Outdated
@@ -89,6 +93,9 @@ pub trait AtRuleParser { | |||
/// The finished representation of an at-rule. | |||
type AtRule; | |||
|
|||
/// | |||
type Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document it too
@@ -266,8 +284,8 @@ pub struct RuleListParser<'i: 't, 't: 'a, 'a, P> { | |||
} | |||
|
|||
|
|||
impl<'i: 't, 't: 'a, 'a, R, P> RuleListParser<'i, 't, 'a, P> | |||
where P: QualifiedRuleParser<QualifiedRule = R> + AtRuleParser<AtRule = R> { | |||
impl<'i: 't, 't: 'a, 'a, R, P, E> RuleListParser<'i, 't, 'a, P> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, those are a lot of lifetimes.
Review comments addressed. @SimonSapin when do you think you will be able to look at this? |
src/rules_and_declarations.rs
Outdated
@@ -157,6 +164,9 @@ pub trait QualifiedRuleParser { | |||
/// The finished representation of a qualified rule. | |||
type QualifiedRule; | |||
|
|||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one seems to still be missing. A copy of the other Error
docs is probably ok.
IRC conversation:
|
☔ The latest upstream changes (presumably #146) made this pull request unmergeable. Please resolve the merge conflicts. |
I've spent some time trying to integrate your ideas about returning E where |
I’m still convinced that the generic Reviewed 5 of 7 files at r2, 2 of 2 files at r4. src/parser.rs, line 373 at r4 (raw file):
Returning Maybe src/parser.rs, line 610 at r4 (raw file):
Please use Comments from Reviewable |
I don't like this design either. What I would have expected is for This way each specific parser in Servo would care only about its specific errors, and we wouldn't need to have all errors possible in Servo in a single huge enum. |
I suspect that reconciling lifetime parameters with generic error types would require "associated type constructors" rust-lang/rfcs#1598 |
I see. |
@bors-servo r+ Reviewed 8 of 8 files at r6. Comments from Reviewable |
📌 Commit 40d86b0 has been approved by |
Return more specific errors from parsing APIs This shouldn't be merged until the related Servo and Gecko work is complete, but I figured I would put this up for feedback. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/143) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
Report more informative CSS errors This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- 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/16752) <!-- Reviewable:end -->
Return meaningful error values when parsing This is #143 with an extra commit added to accommodate changes requested in servo/servo#16752. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/155) <!-- Reviewable:end -->
Report more informative CSS errors This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- 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/16752) <!-- Reviewable:end -->
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 683cf352b472110df4b28c191e8850763334134d
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341 UltraBlame original commit: 79d8f06313932e8f116100390dd153a1c8f9734b
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341 UltraBlame original commit: 79d8f06313932e8f116100390dd153a1c8f9734b
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341 UltraBlame original commit: 79d8f06313932e8f116100390dd153a1c8f9734b
…s-parse-error); r=SimonSapin This requires servo/rust-cssparser#143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 061cb5f48e5c93a5decf39e530aea4a566e97341
This shouldn't be merged until the related Servo and Gecko work is complete, but I figured I would put this up for feedback.
This change is