rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.62k stars 1.49k forks source link

Panic: Mismatched Kinds In Substitution #17182

Closed mcmah309 closed 1 week ago

mcmah309 commented 2 weeks ago

This code makes the rust analyzer panic. And in VsCode, it continues to panic every time you enter the file with the code or scroll:

use std::pin::Pin;
use futures::{stream, Stream};

async fn outer<'a>(
    messages: &'a mut Vec<u32>,
) -> Pin<Box<dyn Stream<Item = u32> + Send + 'a >> {
    let stream = inner(messages);
    stream
}

fn inner<'a>(
    messages: &'a mut Vec<u32>,
) -> Pin<Box<dyn Stream<Item = u32> + Send + 'a>> {
    Box::pin(stream::iter(Vec::new()))
}

Message:

Panic context:
> 
version: 0.3.1940-standalone
request: textDocument/inlayHint InlayHintParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/workspaces/obelisk/obelisk_server/src/core/chat/temp.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 0,
            character: 0,
        },
        end: Position {
            line: 14,
            character: 1,
        },
    },
}

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.97.0/src/fold/subst.rs:81:22:
mismatched kinds in substitution
stack backtrace:
   0: std::panicking::begin_panic
   1: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::TypeFolder<I>>::fold_free_var_lifetime
   2: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   3: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::DynTy<I>>::try_fold_with
   4: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
   6: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
   7: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   8: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
   9: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  10: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
  11: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
  12: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  13: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  14: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  15: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
  16: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Binders<T>>::try_fold_with
  17: chalk_ir::Binders<T>::substitute
  18: <hir_ty::fold_tys_and_consts::TyFolder<F> as chalk_ir::fold::TypeFolder<hir_ty::interner::Interner>>::fold_ty
  19: hir_ty::infer::InferenceContext::insert_inference_vars_for_impl_trait
  20: hir_ty::infer::infer_query
  21: salsa::Cycle::catch
  22: salsa::derived::slot::Slot<Q,MP>::execute
  23: salsa::derived::slot::Slot<Q,MP>::read
  24: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  25: <DB as hir_ty::db::HirDatabase>::infer
  26: hir::source_analyzer::SourceAnalyzer::new_for_body
  27: hir::semantics::SemanticsImpl::analyze_impl
  28: ide::inlay_hints::bind_pat::hints
  29: ide::inlay_hints::hints
  30: ide::inlay_hints::inlay_hints
  31: salsa::Cancelled::catch
  32: rust_analyzer::handlers::request::handle_inlay_hints
  33: std::panicking::try
  34: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 2:04:45 AM] Request textDocument/inlayHint failed.
  Message: request handler panicked: mismatched kinds in substitution
  Code: -32603 

Cargo.toml

futures = "0.3.30"

rust-analyzer version: 0.3.1940-standalone

rustc version: rustc 1.75.0 (82e1608df 2023-12-21)

editor or extension: VsCode 1.88.1