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

Spammed with textDocument/hover failed + other related errors #14474

Closed
RaminKav opened this issue Apr 3, 2023 · 10 comments · Fixed by #14544
Closed

Spammed with textDocument/hover failed + other related errors #14474

RaminKav opened this issue Apr 3, 2023 · 10 comments · Fixed by #14544
Assignees
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug I-panic

Comments

@RaminKav
Copy link

RaminKav commented Apr 3, 2023

rust-analyzer version: v0.3.1459

rustc version: rustc 1.67.0 (fc594f156 2023-01-24)

relevant settings: N/A (i think)
Restarting RA or VSCode, or downgrading to an RA version 1 week older did not work.
Hovering over most parts of my document spams the message in the title, with the following error log:

Panic context:
> 
version: 0.3.1459-standalone (236576227 2023-04-02)
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/Users/ramin/Documents/Dev/horizon-games/SkyWeaver/state/state/src/live_game.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 575,
            character: 44,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

thread 'Worker' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir-ty/src/mir/eval.rs:1161:52
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <hir_ty::mir::eval::Evaluator::ty_filler::Filler as chalk_ir::fold::FallibleTypeFolder<hir_ty::interner::Interner>>::try_fold_ty
   4: hir_ty::mir::eval::Evaluator::size_of
   5: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   6: core::iter::adapters::try_process
   7: hir_ty::mir::eval::interpret_mir
   8: hir_ty::consteval::eval_to_const
   9: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  11: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  12: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  13: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  14: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  15: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  16: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  17: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  18: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_async_block
  19: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
  20: hir_ty::infer::infer_query
  21: salsa::runtime::Runtime::execute_query_implementation
  22: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  23: salsa::derived::slot::Slot<Q,MP>::read
  24: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  25: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  26: <DB as hir_ty::db::HirDatabase>::infer_query
  27: hir_ty::db::infer_wait
  28: <DB as hir_ty::db::HirDatabase>::infer
  29: hir::source_analyzer::SourceAnalyzer::new_for_body
  30: hir::semantics::SemanticsImpl::analyze_impl
  31: ide_db::defs::NameRefClass::classify
  32: ide_db::defs::IdentClass::classify_node
  33: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  34: <itertools::unique_impl::UniqueBy<I,V,F> as core::iter::traits::iterator::Iterator>::next
  35: ide::hover::hover
  36: std::panicking::try
  37: rust_analyzer::handlers::handle_hover
  38: std::panicking::try
  39: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 11:36:46 AM] Request textDocument/hover failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
@RaminKav RaminKav added the C-bug Category: bug label Apr 3, 2023
@HKalbasi
Copy link
Member

HKalbasi commented Apr 3, 2023

If you provide a reproduction, we can fix the underlying problem. Meanwhile for a workaround you can downgrade to the previous month version.

@RaminKav
Copy link
Author

RaminKav commented Apr 3, 2023

Im not entirely sure what is causing it, since its being used in a large project. Some files work fine, but some dont. If i find any clues that would let me make an MVP/repro ill report back. Ill try downgrading further for now

@lnicola
Copy link
Member

lnicola commented Apr 3, 2023

Check if it reproduces with rust-analyzer analysis-stats -v ., then remove code files until you isolate it.

@HKalbasi
Copy link
Member

HKalbasi commented Apr 3, 2023

And you can remove parts that are not related to const generics / const eval first.

@connorskees
Copy link
Contributor

I ran into this as well. I'm not able to provide a reproduction as the repo is quite large and proprietary. But it occurred when constructing a class with an async constructor and not calling .await. Effectively,

struct Foo {}

impl Foo {
  pub async fn new() -> Self { Foo {} }
}

// error goes away after adding `.await`
let x = Foo::new();

@ivan
Copy link
Contributor

ivan commented Apr 9, 2023

@HKalbasi
Copy link
Member

HKalbasi commented Apr 9, 2023

@ivan Thanks for repro, yours is similar to #14461 and is fixed in latest version.

@HKalbasi HKalbasi added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Apr 9, 2023
@ivan
Copy link
Contributor

ivan commented Apr 9, 2023

@HKalbasi my reproducer at https://github.com/ludios/rust-analyzer-issue-14474-repro should still be triggering this bug in rust-analyzer 51d5862:

# uname -a
Linux dev 6.1.22 #1-NixOS SMP PREEMPT_DYNAMIC Thu Mar 30 10:49:31 UTC 2023 x86_64 GNU/Linux

# rustc --version
rustc 1.70.0-nightly (af06dce64 2023-04-08)

# ~/bin/_rust-analyzer --version
rust-analyzer 0.0.0 (51d5862ca 2023-04-09)

rust-analyzer-issue-14474-repro:master# ~/bin/_rust-analyzer analysis-stats -v .
Failed to create perf counter: Operation not permitted (os error 1)
Failed to create perf counter: Operation not permitted (os error 1)
Database loaded:     1.80s (metadata 917.68ms; build 616.15ms)
Failed to create perf counter: Operation not permitted (os error 1)
  crates: 1, mods: 1, decls: 4, fns: 3
Item Collection:     5.70s
Failed to create perf counter: Operation not permitted (os error 1)
1/3 33% processing: stream_file (rust-analyzer-issue-14474-repro/src/main.rs 233..428)thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir-ty/src/mir/eval.rs:1161:52
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <hir_ty::mir::eval::Evaluator::ty_filler::Filler as chalk_ir::fold::FallibleTypeFolder<hir_ty::interner::Interner>>::try_fold_ty
   4: hir_ty::mir::eval::Evaluator::size_of
   5: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   6: core::iter::adapters::try_process
   7: hir_ty::mir::eval::interpret_mir
   8: hir_ty::consteval::eval_to_const
   9: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  11: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  12: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  13: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  14: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  15: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  16: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  17: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  18: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  19: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
  20: hir_ty::infer::infer_query
  21: salsa::runtime::Runtime::execute_query_implementation
  22: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  23: salsa::derived::slot::Slot<Q,MP>::read
  24: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  25: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  26: <DB as hir_ty::db::HirDatabase>::infer_query
  27: hir_ty::db::infer_wait
  28: <DB as hir_ty::db::HirDatabase>::infer
  29: rust_analyzer::cli::analysis_stats::<impl rust_analyzer::cli::flags::AnalysisStats>::run_inference
  30: rust_analyzer::cli::analysis_stats::<impl rust_analyzer::cli::flags::AnalysisStats>::run
  31: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@HKalbasi
Copy link
Member

Sorry, I was on #14470 which silence (and not fix) this issue. Will look at it.

@HKalbasi HKalbasi added A-ty type system / type inference / traits / method resolution and removed S-unactionable Issue requires feedback, design decisions or is blocked on other work A-mir labels Apr 10, 2023
@HKalbasi HKalbasi self-assigned this Apr 10, 2023
@ivan
Copy link
Contributor

ivan commented Apr 10, 2023

My git bisect finds that cd67589 ("beginning of MIR") is the first bad commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug I-panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants