-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve parser #125117
Improve parser #125117
Conversation
dev-ardi
commented
May 14, 2024
•
edited by fmease
Loading
edited by fmease
- Add a few more help diagnostics to incorrect semicolons
- Overall improved that function
- Addded a few comments
- Renamed diff_marker fns to git_diff_marker
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
Nice improvements! @bors r+ rollup |
(0..3).all(|i| self.look_ahead(i, |tok| tok == long_kind)) | ||
&& self.look_ahead(3, |tok| tok == short_kind) | ||
} | ||
|
||
fn diff_marker(&mut self, long_kind: &TokenKind, short_kind: &TokenKind) -> Option<Span> { | ||
if self.is_diff_marker(long_kind, short_kind) { | ||
fn git_diff_marker(&mut self, long_kind: &TokenKind, short_kind: &TokenKind) -> Option<Span> { |
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.
If I remember correctly it was intentional to not mention git
here. I'd need to look for the original PRs. CC @estebank
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.
Indeed, diff markers are used by git, but not exclusive to it.
Sorry but the markdown docs are butchered. |
Thanks for noticing! @rustbot ready |
Thanks. One last thing, could you squash the commits into one? |
All of them or just the "applied suggestions" one? If all with what name? |
Eh, I guess git-fixup the “apply suggs” commit into 9db789a should be fine |
@rustbot ready |
As far as I'm aware, conflict markers (the I think now might be the best time to rename [git] diff marker to conflict markers which is the more appropriate term as touched upon in #113826. If you could do that in this PR, that would be great! Diff markers are |
Maybe vcs_conflict_marker then? |
I guess that's fine, yes. From a purist / theoretical point of view, these conflict markers not necessarily tied to VCSs but to be fair, in practice, that shouldn't matter. CC https://www.gnu.org/software/diffutils/, https://www.geeksforgeeks.org/diff3-command-in-linux-with-examples/ (^^') |
conflicts specifically and a few more improvements.
@rustbot ready Question about the review: I rebased edit the specific commit with the fix. Should I have made the fix commit and made the fixup rebase after you approve so that it's easier to review? |
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.
Those a very nice changes, thanks a lot for your patience! I've noticed two small things but they're not worth blocking on. That can be done when fixing #113826, maybe you're up for it? ;).
/// * `>>>>>` | ||
/// * `=====` | ||
/// * `<<<<<` | ||
/// |
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.
/// * `>>>>>` | |
/// * `=====` | |
/// * `<<<<<` | |
/// | |
/// * `>>>>>` | |
/// * `|||||` | |
/// * `=====` | |
/// * `<<<<<` |
@@ -567,7 +567,7 @@ impl<'a> Parser<'a> { | |||
if self.token == token::Eof { | |||
break; | |||
} | |||
if self.is_diff_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt) { | |||
if self.is_vcs_conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt) { | |||
// Account for `<<<<<<<` diff markers. We can't proactively error here because |
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.
// Account for `<<<<<<<` diff markers. We can't proactively error here because | |
// Account for `<<<<<<<` conflict markers. We can't proactively error here because |
@bors r=wesleywiser,fmease rollup |
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#125117 (Improve parser) - rust-lang#125184 (Fix ICE in non-operand `aggregate_raw_ptr` intrinsic codegen) - rust-lang#125240 (Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable) - rust-lang#125248 (Migrate `run-make/rustdoc-scrape-examples-invalid-expr` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
This comment was marked as outdated.
This comment was marked as outdated.
Rollup merge of rust-lang#125117 - dev-ardi:improve-parser, r=wesleywiser,fmease Improve parser Fixes rust-lang#124935. - Add a few more help diagnostics to incorrect semicolons - Overall improved that function - Addded a few comments - Renamed diff_marker fns to git_diff_marker
Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks `@gurry` for your code and sorry for making it confusing :P r? fmease
Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks ``@gurry`` for your code and sorry for making it confusing :P r? fmease
Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks ```@gurry``` for your code and sorry for making it confusing :P r? fmease
Rollup merge of rust-lang#125276 - dev-ardi:no-main-diag, r=fmease Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks ```@gurry``` for your code and sorry for making it confusing :P r? fmease