-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add a test to ensure that we can parse each file #273
Conversation
Awesome! And yeah, we need to fix our parser first 😅 |
This also passes silently if the project is in a folder called |
I don't know how to fix the parser without a large refactoring of type parsing (to pass |
280: Fixed cast expression parsing in ra_syntax. r=matklad a=ruabmbua Fixes #279 Related to #273 The cast expression expected any type via types::type_() function, but the language spec does only allow TypeNoBounds (types without direct extra bounds via `+`). **Example:** ```rust fn test() { 6i8 as i32 + 5; } ``` This fails, because the types::type_() function which should parse the type after the as keyword is greedy, and takes the plus sign after path types as extra type bounds. My proposed fix is to replace the not implemented `type_no_plus()` just calls (`type_()`) function, which is used at several places. The replacement is `type_with_bounds_cond(p: &mut Parser, allow_bounds: bool)`, which passes the condition to relevant sub-parsers. This function is then called by `type_()` and the new public `type_no_bounds()`. Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
Let's see if this passes now... bors r+ |
Build failed |
|
That is #214 |
Now we're blocked on #225. |
@@ -213,7 +213,7 @@ const LHS_FIRST: TokenSet = token_set_union![ | |||
atom::ATOM_EXPR_FIRST, | |||
]; | |||
|
|||
fn lhs(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { | |||
fn lhs(p: &mut Parser, r: Restrictions) -> (Option<CompletedMarker>, Option<BlockLike>) { |
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 would expect an Option<(CompletionMarker, BlockLike)>
here?
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 currently only give a BlockLike
in case of macro invocation. This code makes that work without breaking anything else.
// test stmt_bin_expr_ambiguity | ||
// fn foo() { | ||
// let _ = {1} & 2; | ||
// {1} &2; | ||
// } | ||
if r.prefer_stmt && is_block(lhs.kind()) { | ||
if r.prefer_stmt && (is_block(lhs.kind()) || blocklike == Some(BlockLike::Block)) { |
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.
is_block(lhs.kind())
check should be redundant, given that we return blockfile
from lhs() call
p: &mut Parser, | ||
r: Restrictions, | ||
mut lhs: CompletedMarker, | ||
macro_block_like: Option<BlockLike>, |
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.
Similarly, we don't need Option
here I guess?
Alternatively, I think we can just pass-in allow_calls
directly, instead of both r
and block_like
.
Note that this has a non-spurious failure in ra_analysis/src/mock_analysis
I'm not certain that this is correct, so extra eyes would be good
TODO: Fix this when the block like macro is in expression position E.g. `test(test!{})` currently parses
This approach is correct, but it needs an addition to Restrictions too This reverts commit ad00d0c.
38bf8af
to
def0a95
Compare
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.
Just a couple of nits to fix!
@@ -158,13 +168,13 @@ fn current_op(p: &Parser) -> (u8, Op) { | |||
// Parses expression with binding power of at least bp. | |||
fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> BlockLike { | |||
let mut lhs = match lhs(p, r) { | |||
Some(lhs) => { | |||
Some((lhs, macro_blocklike)) => { |
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.
Let's rename to blocklike
, it's not only about macros
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.
Sure, just missed that one
@@ -362,7 +366,7 @@ fn match_arm(p: &mut Parser) -> BlockLike { | |||
patterns::pattern(p); | |||
} | |||
if p.eat(IF_KW) { | |||
expr_no_struct(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.
Are struct literals really allowed here? Let's add a test if this is the case?
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.
struct Test{field: u32}
fn main() {
match Ok(1u32) as Result<u32, u32> {
Ok(0) if Test{field:0}.field ==0 => Test{field:0},
_ => Test{field:1}
};
}
Yep - allowed. The only reason they aren't in other places is due to ambiguity, but the =>
stops that being an issue anyway.
The |
I think it traversed |
Yeah, I'll do that. 🤦♂️. It did seem very high compared to |
bors r+ Thanks! |
Build succeeded |
383: Bump failure from 0.1.3 to 0.1.4 r=DJMcNab a=dependabot[bot] Bumps [failure](https://github.com/rust-lang-nursery/failure) from 0.1.3 to 0.1.4. <details> <summary>Changelog</summary> *Sourced from [failure's changelog](https://github.com/rust-lang-nursery/failure/blob/master/RELEASES.md).* > # Version 0.1.4 > > - Improved error reporting of the derive feature > - Resolved a potential internal ambiguity when using the backtrace feature > that prevented backtrace from improving an upstream API. > - Changed the bounds on std error compat conversions through the From trait > to take Sync and Send into account. </details> <details> <summary>Commits</summary> - [`70b98e6`](rust-lang-deprecated/failure@70b98e6) 0.1.4 - [`937fb70`](rust-lang-deprecated/failure@937fb70) Add Sync and Send as failure::Error supports them. ([#283](https://github-redirect.dependabot.com/rust-lang-nursery/failure/issues/283)) - [`15b6798`](rust-lang-deprecated/failure@15b6798) Improving procmacro error reporting - [`22bfd31`](rust-lang-deprecated/failure@22bfd31) support trailing commas in macros ([#273](https://github-redirect.dependabot.com/rust-lang-nursery/failure/issues/273)) - [`26fc6eb`](rust-lang-deprecated/failure@26fc6eb) Future proof debug formatting. Fixes [#279](https://github-redirect.dependabot.com/rust-lang-nursery/failure/issues/279) - [`0f89723`](rust-lang-deprecated/failure@0f89723) Reformat for latest rustfmt - [`8f8f92f`](rust-lang-deprecated/failure@8f8f92f) Update metadata to point to new docs - See full diff in [compare view](rust-lang-deprecated/failure@0.1.3...0.1.4) </details> <br /> [![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=failure&package-manager=cargo&previous-version=0.1.3&new-version=0.1.4)](https://dependabot.com/compatibility-score.html?dependency-name=failure&package-manager=cargo&previous-version=0.1.3&new-version=0.1.4) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language - `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com): - Update frequency (including time of day and day of week) - Automerge options (never/patch/minor, and dev/runtime dependencies) - Pull request limits (per update run and/or open at any time) - Out-of-range updates (receive only lockfile updates, if desired) - Security updates (receive only security updates, if desired) Finally, you can contact us by mentioning @dependabot. </details> Co-authored-by: dependabot[bot] <support@dependabot.com>
Note that this has a non-spurious failure in ra_analysis/src/mock_analysis.
Probably fixes #195.
If my understanding is correct, fixes #214 and fixes #225.