Skip to content

Constant panic/crashing while typing on a string inside a macro #16731

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

Closed
ThomasMiz opened this issue Mar 1, 2024 · 5 comments
Closed

Constant panic/crashing while typing on a string inside a macro #16731

ThomasMiz opened this issue Mar 1, 2024 · 5 comments
Labels
C-bug Category: bug

Comments

@ThomasMiz
Copy link

Hello! I'm getting panic messages each time I type a character inside a string formatting macro. I have been able to reproduce this on an empty project with nothing but a main method like so:

fn main() {
    let some_number = 0;
    format!("hola {some_number}");
}

To trigger the bug, copy and paste this into the main.rs of a new, empty project, and then put the cursor somewhere between the { and the }, and type anything. Each character typed causes a panic message being printed to stderr. I have tested this behavior with println!, panic!, and format! and the panics happen on all three.

NOTE: The bug only happens if there is an opening AND closing bracket! The bug does NOT happen when typing like so:

println!("hola {s
println!("hola {some_num
println!("hola {some_number}");

The bug does happen when typing like so:

print
println!()
println!("")
println!("hola {}")
println!("hola {some_}") // <== Panics start here
println!("hola {some_number}")

Here is a text file with my stderr output.

rust-analyzer version: 0.3.1860-standalone (5346002 2024-02-25)
rustc 1.78.0-nightly (878c8a2a6 2024-02-29)

@ThomasMiz ThomasMiz added the C-bug Category: bug label Mar 1, 2024
@flodiebold
Copy link
Member

It seems you already reported this as #16712, or is this a different panic? If you are still using the RA version you mentioned, you'll need to update it to get the fix.

@ThomasMiz
Copy link
Author

The crashing I reported on my previous issue stopped when I installed the nightly toolchain, so I'm guessing this is different. That said, I thought I had updated rust-analyzer, but I just discovered rustup didn't install it with the nightly toolchain, so apparently the only thing that changed is the rustc version.

Even after manually adding rust-analyzer, VS Code is refusing to switch to it, I'll figure out what's wrong and report back once I have tested this on nightly.

@ThomasMiz
Copy link
Author

For anyone wondering, what was happening with VS Code was that it seems that on Windows it downloads its own rust-analyzer binary rather than using the one in %PATH%. I couldn't change it to do so, nor find any documentation for this on Windows.

Either way, I got VS Code to use rust-analyzer version: 0.4.1865-standalone (79e0fee6a 2024-03-01). The panics have been replaced with simple errors:

2024-03-02T14:05:46.868528Z ERROR hir::diagnostics: synthetic syntax
2024-03-02T14:05:46.905885Z ERROR hir::diagnostics: synthetic syntax
2024-03-02T14:05:47.122497Z ERROR hir::diagnostics: synthetic syntax
2024-03-02T14:05:47.202246Z ERROR hir::diagnostics: synthetic syntax
2024-03-02T14:05:47.234640Z ERROR hir::diagnostics: synthetic syntax
2024-03-02T14:05:47.479064Z ERROR hir::diagnostics: synthetic syntax

Is this intended as a fix?

@lnicola
Copy link
Member

lnicola commented Mar 2, 2024

on Windows it downloads its own rust-analyzer binary

Doesn't download, but bundle it. The VSIX has a matching binary, you can find the path here (%USERPROFILE%\.vscode\extensions).

I couldn't change it to do so, nor find any documentation for this on Windows.

Setting "rust-analyzer.server.path": "rust-analyzer" should work, but you can set an absolute path to make sure. Anyway, this shouldn't be needed.

@ThomasMiz
Copy link
Author

Ah, I see! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants