Skip to content

Panic in Rust-Analyzer's - unexpected autoderef error #21551

Description

@EderNunez

rust-analyzer version: rust-analyzer version: 0.3.2769-standalone

rustc version: rustc 1.93.0 stable

editor or extension: VSCode with rust-analyzer

code snippet to reproduce:

fn f(b: bool) -> impl Iterator<Item = ()> {
    if b {
        return Vec::new();
    }
    std::iter::empty().map(|()|())
}

stacktrace


thread 'Worker5' (16260) panicked at crates\hir-ty\src\method_resolution\probe.rs:1555:17:
internal error: entered unreachable code: unexpected autoderef error [TrueError(Obligation { cause: ObligationCause { _private: () }, param_env: ParamEnv { clauses: [] }, predicate: Binder { value: AliasRelate(Alias(Opaque, AliasTy { args: [], def_id: InternedOpaqueTyId(InternedOpaqueTyId { loc: ReturnTypeImplTrait(FunctionId(3a72e), Idx::<ImplTrait>(0)) }), .. }), Equate, Vec<?73t, Global>), bound_vars: [] }, recursion_depth: 0 })]
stack backtrace:
   0: std::panicking::panic_handler
             at /rustc/254b59607d4417e9dffbc307138ae5c86280fe4c/library\std\src\panicking.rs:689
   1: core::panicking::panic_fmt
             at /rustc/254b59607d4417e9dffbc307138ae5c86280fe4c/library\core\src\panicking.rs:80
   2: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   3: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   4: <hir_ty::method_resolution::probe::ProbeForNameChoice as hir_ty::method_resolution::probe::ProbeChoice>::choose
   5: hir_ty::next_solver::infer::snapshot::<impl hir_ty::next_solver::infer::InferCtxt>::probe
   6: hir_ty::method_resolution::probe::<impl hir_ty::method_resolution::MethodResolutionContext>::probe_for_name
   7: hashbrown::map::HashMap<K,V,S,A>::insert
   8: <hir_ty::autoderef::GeneralAutoderef<Ctx,Steps> as core::iter::traits::iterator::Iterator>::next
   9: <hir_ty::next_solver::ty::Ty as ra_ap_rustc_type_ir::fold::TypeSuperFoldable<hir_ty::next_solver::interner::DbInterner>>::super_fold_with
  10: <DB as hir_def::db::DefDatabase>::function_signature
  11: <DB as hir_def::db::DefDatabase>::impl_signature
  12: <hir_ty::next_solver::ty::Ty as ra_ap_rustc_type_ir::fold::TypeSuperFoldable<hir_ty::next_solver::interner::DbInterner>>::super_fold_with
  13: hir_ty::lower::TyLoweringContext::impl_trait_mode
  14: hir_ty::infer::infer_query_with_inspect
  15: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
  16: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
  17: std::thread::local::LocalKey<T>::with
  18: hir::semantics::SemanticsImpl::analyze_impl
  19: hir::semantics::SemanticsImpl::type_of_expr
  20: ide::hover::render::type_info_of
  21: ide::hover::HoverAction::goto_type_from_targets
  22: ide::hover::hover
  23: salsa::cancelled::Cancelled::catch
  24: std::thread::local::LocalKey<T>::with
  25: ide::Analysis::hover
  26: rust_analyzer::handlers::request::handle_hover
  27: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  28: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
   0: InferenceResult::for_body_(Id(3a72e)) -> (R2361, Durability::LOW)
             at crates\hir-ty\src\infer.rs:552

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions