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

Parse error in tuple access foo.0. bar #10492

Closed
ogoffart opened this issue Oct 9, 2021 · 4 comments · Fixed by #12149
Closed

Parse error in tuple access foo.0. bar #10492

ogoffart opened this issue Oct 9, 2021 · 4 comments · Fixed by #12149
Labels
A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@ogoffart
Copy link

ogoffart commented Oct 9, 2021

This is supported rust syntax since rust 1.46, but rust-analyzer fail to parse it in some cases:

The following code compiles fine, but rust-analizer incorrectly reports an error:

fn main() {
    let foo = (String::new(),);
    foo.0.as_str(); // OK
    foo.0. as_str(); // ERROR in rust-analyzer! (Syntax Error: expected SEMICOLON);
}
@lnicola lnicola added A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now labels Oct 9, 2021
@ogoffart
Copy link
Author

ogoffart commented Oct 9, 2021

Context: you might argue that this is incorrect style, but in my case, rust-analyzer was reporting error in auto-generated code using quote. It was generated with something like the following exampe

fn main() {
   let xx = quote::quote!(as_str());
   println!("{}", quote::quote!(foo.0.#xx));
}

which prints foo . 0. as_str ()

@divagant-martian
Copy link
Contributor

I'd like to work on this if that's ok

ogoffart added a commit to slint-ui/slint that referenced this issue Oct 12, 2021
@kassens
Copy link

kassens commented Oct 16, 2021

@divagant-martian
Copy link
Contributor

Yeah, @Veykril pointed to me that might be a subcase of #1109
Rn I'm just trying to understand the problem to check if that's something I can actually solve with my very limited ra knowledge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants