Skip to content

Panic when completing Vec<{unknown}> (nightly regression) #10396

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

Closed
iDawer opened this issue Sep 30, 2021 · 5 comments · Fixed by #10399
Closed

Panic when completing Vec<{unknown}> (nightly regression) #10396

iDawer opened this issue Sep 30, 2021 · 5 comments · Fixed by #10399

Comments

@iDawer
Copy link
Contributor

iDawer commented Sep 30, 2021

fn main() {
    let x: Vec<_>;
    x.$0
}
Panic context:
> 
version: b21f15a23 2021-09-30 nightly
request: textDocument/completion CompletionParams {
    text_document_position: TextDocumentPositionParams {
        text_document: TextDocumentIdentifier {
            uri: Url {
                scheme: "file",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: None,
                port: None,
                path: "/tmp/play/src/main.rs",
                query: None,
                fragment: None,
            },
        },
        position: Position {
            line: 2,
            character: 6,
        },
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    context: Some(
        CompletionContext {
            trigger_kind: Invoked,
            trigger_character: None,
        },
    ),
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/runner/.cargo/registry/src/gb.xjqchip.workers.dev-1ecc6299db9ec823/chalk-ir-0.71.0/src/lib.rs:2752:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:69:5
   3: <&chalk_ir::SubstFolder<I,A> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   9: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
  10: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  11: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
  12: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
  13: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::DomainGoal<I>>::fold_with
  14: chalk_ir::_::<impl chalk_ir::fold::Fold<_I> for chalk_ir::InEnvironment<G>>::fold_with
  15: chalk_solve::infer::InferenceTable<I>::from_canonical
  16: chalk_recursive::solve::SolveIteration::solve_iteration
  17: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  18: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  19: hir_ty::traits::trait_solve_query
  20: salsa::runtime::Runtime::execute_query_implementation
  21: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  22: salsa::derived::slot::Slot<Q,MP>::read
  23: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  24: <DB as hir_ty::db::HirDatabase>::trait_solve_query::__shim
  25: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  26: hir_ty::db::trait_solve_wait
  27: <DB as hir_ty::db::HirDatabase>::trait_solve
  28: hir_ty::autoderef::deref_by_trait
  29: hir_ty::autoderef::deref
  30: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
  31: ide_completion::completions::dot::complete_dot
  32: ide_completion::completions
  33: std::panicking::try
  34: rust_analyzer::handlers::handle_completion
  35: std::panicking::try
  36: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 1:26:20 PM] Request textDocument/completion failed.
  Message: server panicked: index out of bounds: the len is 0 but the index is 0
  Code: -32603 

This is even broader. It panics at let _ = Vec::$0, let _ = std::collections::HashMap::$0

CC #10373 This regressed after that PR I suppose. I simply tried examples from it and got the panic.

@lnicola
Copy link
Member

lnicola commented Sep 30, 2021

CC #10390

Are you sure it was caused by #10373?

@iDawer
Copy link
Contributor Author

iDawer commented Sep 30, 2021

Let me recheck with revert

@Nima155
Copy link

Nima155 commented Sep 30, 2021

This is also happening to me!

@iDawer
Copy link
Contributor Author

iDawer commented Sep 30, 2021

Are you sure it was caused by #10373?

I think so: just applied reverts of #10373 to b21f15a nightly tag, dev build didn't panic on the examples.

@iDawer
Copy link
Contributor Author

iDawer commented Sep 30, 2021

Oops

https://github.com/rust-analyzer/rust-analyzer/blob/629db286d1ac8f43d67c65827ff8f5a50c095e04/crates/hir/src/lib.rs#L2505-L2508
I dropped binders here for no reason!

I'll post a fix soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants