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

rust-analyzer panics if a format string refers to a nonexitent variable. #16682

Closed
TDecking opened this issue Feb 26, 2024 · 2 comments
Closed
Assignees
Labels
C-bug Category: bug

Comments

@TDecking
Copy link

TDecking commented Feb 26, 2024

rust-analyzer version: rust-analyzer version: 0.3.1860-standalone (5346002 2024-02-25)

rustc version: rustc 1.77.0-nightly (bf8716f1c 2023-12-24)

relevant settings: None

code snippet to reproduce:

fn main() {
    //println!("Hello, world!{va}");
}
main.rs.-.playground.-.Visual.Studio.Code.2024-02-26.16-30-36.mp4

log output:

Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at crates\hir\src\diagnostics.rs:521:63:
unexpected synthetic: SyntheticSyntax
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\result.rs:1649
   3: hir::diagnostics::AnyDiagnostic::inference_diagnostic
   4: hir::DefWithBody::diagnostics
   5: hir::ModuleDef::diagnostics
   6: hir::Module::diagnostics
   7: ide_diagnostics::diagnostics
   8: salsa::Cancelled::catch
   9: ide::Analysis::diagnostics
  10: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  12: rust_analyzer::diagnostics::fetch_native_diagnostics
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at crates\hir\src\diagnostics.rs:521:63:
unexpected synthetic: SyntheticSyntax
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\result.rs:1649
   3: hir::diagnostics::AnyDiagnostic::inference_diagnostic
   4: hir::DefWithBody::diagnostics
   5: hir::ModuleDef::diagnostics
   6: hir::Module::diagnostics
   7: ide_diagnostics::diagnostics
   8: salsa::Cancelled::catch
   9: ide::Analysis::diagnostics
  10: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  12: rust_analyzer::diagnostics::fetch_native_diagnostics
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'LspServer' panicked at D:\a\rust-analyzer\rust-analyzer\crates\stdx\src\thread\pool.rs:86:35:
called `Result::unwrap()` on an `Err` value: "SendError(..)"
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\result.rs:1649
   3: rust_analyzer::task_pool::TaskPool<T>::spawn
   4: rust_analyzer::dispatch::RequestDispatcher::on_with_thread_intent
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::prime_caches::{{closure}}::{{closure}}
   6: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   7: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   8: rust_analyzer::main_loop::main_loop
   9: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\lsp-server-0.7.6\src\stdio.rs:28:37:
receiver was dropped, failed to send a message: "SendError(..)"
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\result.rs:1649
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\jod-thread-0.1.2\src\lib.rs:33:22:
called `Result::unwrap()` on an `Err` value: Any { .. }
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\result.rs:1649
   3: stdx::thread::JoinHandle<T>::join
   4: lsp_types::inline_completion::_::<impl serde::ser::Serialize for lsp_types::inline_completion::InlineCompletionOptions>::serialize
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 16:33:28] Connection to server got closed. Server will restart.
true
@TDecking TDecking added the C-bug Category: bug label Feb 26, 2024
@TDecking
Copy link
Author

I also decided to test this after running rustup update. The crash persists.

@Veykril Veykril self-assigned this Feb 26, 2024
bors added a commit that referenced this issue Feb 26, 2024
fix: Don't panic on synthetic syntax in inference diagnostics

Temporary fix for #16682

We ought to rethink how we attach diagnostics to things, as IDs don't work for `format_args` like that!
@Veykril
Copy link
Member

Veykril commented Feb 28, 2024

Fixed in #16684

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