rust-lang / rust-lang/rust-analyzer
Panic in `rowan::cursor::SyntaxNode::token_at_offset`
Open
Nobody has claimed this yet.
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: 0.3.2307-standalone
rustc version: recent nightly
editor or extension: VSCode
relevant settings: -
repository link (if public, optional): https://github.com/pczarn/cfg/pull/20/commits/13cdaa789066be38a81cf436720f26da66a9e8b3
Panic context:
>
version: 0.3.2037-standalone
request: textDocument/codeAction CodeActionParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/piotr/src/cfg/cfg-grammar/src/lib.rs",
query: None,
fragment: None,
},
},
range: Range {
start: Position {
line: 34,
character: 12,
},
end: Position {
line: 34,
character: 43,
},
},
context: CodeActionContext {
diagnostics: [
Diagnostic {
range: Range {
start: Position {
line: 34,
character: 12,
},
end: Position {
line: 34,
character: 43,
},
},
severity: Some(
Warning,
),
code: Some(
String(
"Click for full compiler diagnostic",
),
),
code_description: Some(
CodeDescription {
href: Url {
scheme: "rust-analyzer-diagnostics-view",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/diagnostic%20message%20%5B6%5D",
query: Some(
"6",
),
fragment: Some(
"file%3A%2F%2F%2Fhome%2Fpiotr%2Fsrc%2Fcfg%2Fcfg-grammar%2Fsrc%2Flib.rs",
),
},
},
),
source: Some(
"rustc",
),
message: "unused import: `crate::symbol_set::SymbolBitSet`",
related_information: Some(
[
DiagnosticRelatedInformation {
location: Location {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/piotr/src/cfg/cfg-grammar/src/lib.rs",
query: None,
fragment: None,
},
range: Range {
start: Position {
line: 34,
character: 4,
},
end: Position {
line: 34,
character: 44,
},
},
},
message: "remove the whole `use` item",
},
],
),
tags: Some(
[
Unnecessary,
],
),
data: Some(
Object {
"rendered": String("\u{1b}[0m\u{1b}[1m\u{1b}[33mwarning\u{1b}[0m\u{1b}[0m\u{1b}[1m: unused import: `crate::symbol_set::SymbolBitSet`\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m--> \u{1b}[0m\u{1b}[0mcfg-grammar/src/lib.rs:35:13\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\n\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m35\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m pub use crate::symbol_set::SymbolBitSet;\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m| \u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[33m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u{1b}[0m\n\n"),
},
),
},
Diagnostic {
range: Range {
start: Position {
line: 34,
character: 4,
},
end: Position {
line: 34,
character: 44,
},
},
severity: Some(
Hint,
),
code: Some(
String(
"unused_imports",
),
),
code_description: None,
source: Some(
"rustc",
),
message: "remove the whole `use` item",
related_information: Some(
[
DiagnosticRelatedInformation {
location: Location {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/piotr/src/cfg/cfg-grammar/src/lib.rs",
query: None,
fragment: None,
},
range: Range {
start: Position {
line: 34,
character: 12,
},
end: Position {
line: 34,
character: 43,
},
},
},
message: "original diagnostic",
},
],
),
tags: None,
data: None,
},
Diagnostic {
range: Range {
start: Position {
line: 34,
character: 12,
},
end: Position {
line: 34,
character: 43,
},
},
severity: Some(
Error,
),
code: Some(
String(
"Click for full compiler diagnostic",
),
),
code_description: Some(
CodeDescription {
href: Url {
scheme: "rust-analyzer-diagnostics-view",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/diagnostic%20message%20%5B10%5D",
query: Some(
"10",
),
fragment: Some(
"file%3A%2F%2F%2Fhome%2Fpiotr%2Fsrc%2Fcfg%2Fcfg-grammar%2Fsrc%2Flib.rs",
),
},
},
),
source: Some(
"rustc",
),
message: "unused import: `crate::symbol_set::SymbolBitSet`",
related_information: Some(
[
DiagnosticRelatedInformation {
location: Location {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/piotr/src/cfg/cfg-grammar/src/lib.rs",
query: None,
fragment: None,
},
range: Range {
start: Position {
line: 34,
character: 4,
},
end: Position {
line: 34,
character: 44,
},
},
},
message: "remove the whole `use` item",
},
],
),
tags: Some(
[
Unnecessary,
],
),
data: Some(
Object {
"rendered": String("\u{1b}[0m\u{1b}[1m\u{1b}[38;5;9merror\u{1b}[0m\u{1b}[0m\u{1b}[1m: unused import: `crate::symbol_set::SymbolBitSet`\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m--> \u{1b}[0m\u{1b}[0mcfg-grammar/src/lib.rs:35:13\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\n\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m35\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m pub use crate::symbol_set::SymbolBitSet;\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m| \u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;9m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u{1b}[0m\n\n"),
},
),
},
],
only: Some(
[
CodeActionKind(
"quickfix",
),
],
),
trigger_kind: Some(
Invoked,
),
},
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
}
thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.15/src/cursor.rs:751:9:
Bad offset: range 0..1013 offset 1022
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: rowan::cursor::SyntaxNode::token_at_offset
3: ide_assists::assist_context::AssistContext::new
4: ide_assists::assists
5: std::panicking::try
6: ide::Analysis::assists_with_fixes
7: rust_analyzer::handlers::request::handle_code_action
8: std::panicking::try
9: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rowan::cursor::SyntaxNode::token_at_offset and the textDocument/codeAction request shown in the panic context. Reproduce the request using the linked cfg repository and inspect the reported panic path; done means the code action request completes without this panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100