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 when binding a type param to a trait with an impl type param #17191

Open
orcharddweller opened this issue May 5, 2024 · 0 comments
Open
Labels
C-bug Category: bug

Comments

@orcharddweller
Copy link

Rust-analyzer panics when hovering over T in the definition of test() function. Also panics when using the function anywhere in code. Rust compiles correctly.

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
rust-analyzer version: 0.3.1940-standalone (f216be4 2024-04-27)

rustc version: (eg. output of rustc -V)
rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
VSCode v0.3.1940

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

trait A {
    type Item;
}

trait B<T: A> {}

fn test<T: B<impl A>>() {}

fn main() {}

Error:

[Error - 01:02:43] Request textDocument/hover failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 0.3.1940-standalone (f216be4a0 2024-04-27)
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "...",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 6,
            character: 9,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

thread 'Worker' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.97.0/src/fold/subst.rs:55:19:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::TypeFolder<I>>::fold_free_var_ty
   4: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   5: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   6: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
   7: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
   8: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Binders<T>>::try_fold_with
   9: chalk_ir::Binders<T>::substitute
  10: <core::iter::adapters::cloned::Cloned<I> as core::iter::traits::iterator::Iterator>::try_fold
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  12: hir::display::<impl hir_ty::display::HirDisplay for hir::TypeParam>::hir_fmt
  13: <hir_ty::display::HirDisplayWrapper<T> as core::fmt::Display>::fmt
  14: ide_db::defs::Definition::label
  15: ide::hover::render::definition
  16: ide::hover::hover_for_definition
  17: ide::hover::hover_simple
  18: ide::hover::hover
  19: salsa::Cancelled::catch
  20: rust_analyzer::handlers::request::handle_hover
  21: std::panicking::try
  22: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 01:02:43] Request textDocument/hover failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
@orcharddweller orcharddweller added the C-bug Category: bug label May 5, 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

1 participant