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

Panic on textDocument/semanticTokens/full #16619

Closed
liquidev opened this issue Feb 20, 2024 · 3 comments
Closed

Panic on textDocument/semanticTokens/full #16619

liquidev opened this issue Feb 20, 2024 · 3 comments
Labels
C-bug Category: bug

Comments

@liquidev
Copy link

rust-analyzer version: rust-analyzer 1.78.0-nightly (3246e79 2024-02-19)

rustc version: rustc 1.78.0-nightly (3246e7951 2024-02-19)

relevant settings: none

Panic logs:

Panic context:
> 
version: 1.78.0-nightly (3246e79 2024-02-19)
request: textDocument/semanticTokens/full SemanticTokensParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/daknus/Coding/Rust/treehouse/crates/treehouse/src/tree/attributes.rs",
            query: None,
            fragment: None,
        },
    },
}

thread 'Worker' panicked at /rustc/3246e79513cb89ddbfc0f21cb5a877e5b321dcc5/src/tools/rust-analyzer/crates/mbe/src/to_parser_input.rs:45:48:
Fail to convert given literal Literal {
    text: "\"\"field identifier\"\"",
    span: SpanData {
        range: 527..528,
        anchor: SpanAnchor(
            FileId(
                2170,
            ),
            0,
        ),
        ctx: SyntaxContextId(
            17677,
        ),
    },
}
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3246e79513cb89ddbfc0f21cb5a877e5b321dcc5/library/std/src/panicking.rs:648:5
   1: core::panicking::panic_fmt
             at /rustc/3246e79513cb89ddbfc0f21cb5a877e5b321dcc5/library/core/src/panicking.rs:72:14
   2: mbe::to_parser_input::to_parser_input::<span::SpanData<span::SyntaxContextId>>
   3: hir_expand::db::token_tree_to_syntax_node
   4: <hir_expand::db::ParseMacroExpansionQuery as salsa::plumbing::QueryFunction>::execute
   5: <salsa::derived::slot::Slot<hir_expand::db::ParseMacroExpansionQuery, salsa::derived::AlwaysMemoizeValue>>::execute
   6: <_ as hir_expand::db::ExpandDatabase>::parse_macro_expansion::__shim
   7: <ide_db::RootDatabase as hir_expand::db::ExpandDatabase>::parse_macro_expansion
   8: <hir_expand::db::ParseMacroExpansionErrorQuery as salsa::plumbing::QueryFunction>::execute
   9: <salsa::derived::slot::Slot<hir_expand::db::ParseMacroExpansionErrorQuery, salsa::derived::AlwaysMemoizeValue>>::execute
  10: <_ as hir_expand::db::ExpandDatabase>::parse_macro_expansion_error::__shim
  11: <ide_db::RootDatabase as hir_expand::db::ExpandDatabase>::parse_macro_expansion_error
  12: <hir_def::nameres::collector::DefCollector>::collect_macro_expansion
  13: hir_def::nameres::collector::collect_defs
  14: <hir_def::db::CrateDefMapQueryQuery as salsa::plumbing::QueryFunction>::execute
  15: <salsa::derived::slot::Slot<hir_def::db::CrateDefMapQueryQuery, salsa::derived::AlwaysMemoizeValue>>::execute
  16: <_ as hir_def::db::DefDatabase>::crate_def_map_query::__shim
  17: hir_def::db::crate_def_map_wait
  18: <hir::semantics::source_to_def::SourceToDefCtx>::file_to_def
  19: <hir::semantics::source_to_def::SourceToDefCtx>::find_container
  20: <hir::semantics::SemanticsImpl>::analyze_impl
  21: <hir::semantics::SemanticsImpl>::scope
  22: ide::syntax_highlighting::highlight
  23: <ide::Analysis>::highlight
  24: rust_analyzer::handlers::request::handle_semantic_tokens_full
  25: <<stdx::thread::pool::Pool>::spawn<<rust_analyzer::task_pool::TaskPool<rust_analyzer::main_loop::Task>>::spawn<<rust_analyzer::dispatch::RequestDispatcher>::on_with_thread_intent<true, lsp_types::request::SemanticTokensFullRequest>::{closure#0}>::{closure#0}>::{closure#0} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 10:04:14 PM] Request textDocument/semanticTokens/full failed.
  Message: request handler panicked: Fail to convert given literal Literal {
    text: "\"\"field identifier\"\"",
    span: SpanData {
        range: 527..528,
        anchor: SpanAnchor(
            FileId(
                2170,
            ),
            0,
        ),
        ctx: SyntaxContextId(
            17677,
        ),
    },
}
  Code: -32603 

Reverting back to rust-analyzer 1.78.0-nightly (6cc4843 2024-02-10) fixes the issue, I haven't tested any other versions.

@liquidev liquidev added the C-bug Category: bug label Feb 20, 2024
@Veykril
Copy link
Member

Veykril commented Feb 21, 2024

Needs a reproducer to be workable

@liquidev
Copy link
Author

liquidev commented Feb 22, 2024

The "field identifier" string literal doesn't appear in my codebase, neither does the panic report mention which crate it comes from. Is there any way I can debug this? (preferably without having to compile RA separately)

It seems like the FileId could hint at which file the literal comes from. Is it possible to convert that to a human readable filename somehow?

@Veykril
Copy link
Member

Veykril commented Feb 22, 2024

Ah, nevermind. This is #16622, fixed by #16637

@Veykril Veykril closed this as completed Feb 22, 2024
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

2 participants