-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Panic due to auto-generated file diagnostics being incorrectly attributed to source files #15803
Comments
Are you using non-ASCII characters in your code? There's currently a bug related to that (#15273). |
I did have one non-ascii character in a string literal. However removing that and adding I have found a way to reproduce the issue, but it is not a minimal reproduction. I built rust-analyzer from source, and I was able to see that it is triggering on this line. pub fn line_col(&self, offset: TextSize) -> LineCol {
self.try_line_col(offset).expect("invalid offset")
} However what I am confused about is that the stderr from RA when it crashes points to this file:
That file does not match what I see in my clone of RA (which is latest). I would have expected if I built from source that source code cache should match what is in the repo I am building from no? It looks like the src cache for that file is pointing to 60056b8. |
It's not just about literals. Even comments can trigger it. The Line 88 in 1087295
|
I wasn't very clear, but I did check for all non-ascii characters (via I added some prints and I can see that the issue is this check rust-analyzer/lib/line-index/src/lib.rs Line 119 in 46c395d
The values when it fails is What is the best way to go about debugging this? So far I have just been adding |
I'm not that familiar with ripgrep, is it Unicode by default? That regex might miss Unicode chars. I don't know a good way to debug these, and macros can cause issues on their own, but those usually look a bit different. I generally try to minimize the code, but the line index is very sensitive to your edits. |
I did some more debugging and traced the issue back to this
I am receiving this diagnostic while editing. Diagnostic {
code: RustcLint("non_upper_case_globals"),
message: "Constant `INTERNAL__DEFINE_UNINITIALIZED_VARIABLE` should have UPPER_SNAKE_CASE name, e.g. `INTERNAL_DEFINE_UNINITIALIZED_VARIABLE`",
range: 23243..23282,
severity: Warning,
unused: false,
experimental: false,
fixes: None,
main_node: Some(InFile {
file_id: MacroFile(MacroFile { macro_call_id: MacroCallId(6976) }),
value: NAME@20598..20637 })
} The I don't understand enough about RA's architecture to determine why this is happening, but hopefully this will help you point me in the right direction. |
Yeah, we sometimes mix up macro expansions with the files containing the macro calls. #15807 is an example of that. |
Can you try to disable the diagnostic (there a setting) or disable check on save and see if it still crashes? Or even fix the warning if possible. |
So the macro call was a red herring, I can trigger this without any macros. In fact just typing |
Disabling the diagnostic "fixed" the issue. That is good to confirm. But I would like to find a way to fix RA. |
Can you enable it back and disable |
re-enabling the diagnostic and disabling |
I created a branch with the issue here https://github.com/CeleritasCelery/rune/tree/ra-bug to reproduce I was going to |
Possibly related to #14968 |
If commenting out the |
commenting out that |
Duplicate of #14968 |
I have been struggling to find a way to reproduce this issue, and it has been plaguing me for a few weeks. While editing rust-analyzer will panic "randomly". It happens multiple times a day. I can't seem to find a good way to make the issue reproducible, but here is the backtrace below. I have uninstalled and reinstalled rust-analyzer multiple times, and used
cargo clean
to clean up the cache, but nothing seems to fix it.rust-analyzer version: rust-analyzer 0.0.0 (1087295 2023-10-22)
rustc version: rustc 1.74.0-beta.1 (b5c050feb 2023-10-03)
relevant settings: default settings
The text was updated successfully, but these errors were encountered: