Skip to content
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

expected expression, found .. #105634

Closed
CAD97 opened this issue Dec 12, 2022 · 4 comments · Fixed by #105701
Closed

expected expression, found .. #105634

CAD97 opened this issue Dec 12, 2022 · 4 comments · Fixed by #105701
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. relnotes Marks issues that should be documented in the release notes of the next release. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CAD97
Copy link
Contributor

CAD97 commented Dec 12, 2022

Given the following code:

let _ = &..;

The current output is:

error: expected expression, found `..`
 --> src/main.rs:2:14
  |
2 |     let _ = &..;
  |              ^^ expected expression

.. is a valid expression (a RangeFull literal), so this error is misleading. It should at a minimum have a suggestion to replace with the valid version &(..), and probably should just work. It also imho ideally shouldn't be a hard parser error blocking semantic passes; the parse of &(..) is fairly unambiguously intended, even if we decide we should still require the parenthesis.

@CAD97 CAD97 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 12, 2022
@agluszak
Copy link

agluszak commented Dec 12, 2022

I'm interested! Where should I look first? (I have no experience in rustc, some general experience in compilers tho)

@CAD97
Copy link
Contributor Author

CAD97 commented Dec 13, 2022

The rustc dev guide is a good place to start. If you have some compiler development experience already, that should get you going quickly enough.

One specifically relevant section is -Ztreat-err-as-bug, which will allow you to get a backtrace for what code is emitting this error. Then it should just be a matter of threading the proper information through. The rustdoc for the compiler crates is also available online; rustc_parse is likely to be where you'll need to change.

Also, the rustbot docs; you can @rustbot claim to assign yourself to the issue to track that you're working on it.

@CAD97
Copy link
Contributor Author

CAD97 commented Dec 13, 2022

For extra context, .. is accepted in expression position at least for both let _ = ..;, macro_rules! m {($x:expr) => {}} m!(..), and obviously &slice[..], so I have absolutely no idea what makes &.. different that it causes a parser error in this case.

@inquisitivecrystal inquisitivecrystal added the C-bug Category: This is a bug. label Dec 13, 2022
@RedDocMD
Copy link
Contributor

@rustbot claim

@inquisitivecrystal inquisitivecrystal added the relnotes Marks issues that should be documented in the release notes of the next release. label Dec 16, 2022
@bors bors closed this as completed in 300aa90 Dec 25, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
Allow .. to be parsed as let initializer

.. and ..= are valid expressions, however when used in a let statement
it is not parsed.
Fixes rust-lang#105634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. relnotes Marks issues that should be documented in the release notes of the next release. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants