Skip to content

Request handler panics when editing impl block with RPIT #21455

@danbaterisna

Description

@danbaterisna

rust-analyzer version: 0.3.2753-standalone

rustc version: rustc 1.91.0 (f8297e351 2025-10-28)

editor or extension: nvim 0.11.5

code snippet to reproduce:
In a newly initialized library (i.e. via cargo init), fill src/main.rs with the following:

pub struct Miku {}

impl Miku {
    pub fn all_paths_to(&self) -> impl Copy {
        Miku {
            full_paths: Vec::new(),
        }
    }
}

Editing the line with full_paths: Vec::new() results in the following error (as seen in the LSP log):


thread 'Worker0' (374073) 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(6400), Idx::<ImplTrait>(0)) }), .. }), Equate, StructA), bound_vars: [] }, recursion_depth: 0 })]
stack backtrace:

   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: hir_ty::method_resolution::probe::ProbeContext<Choice>::consider_probe::{{closure}}::{{closure}}
   3: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   4: hir_ty::method_resolution::probe::ProbeContext<Choice>::pick_method
   5: hir_ty::method_resolution::probe::ProbeContext<hir_ty::method_resolution::probe::ProbeForNameChoice>::pick_core
   6: <hir_ty::method_resolution::probe::ProbeForNameChoice as
 hir_ty::method_resolution::probe::ProbeChoice>::choose
   7: hir_ty::next_solver::infer::snapshot::<impl hir_ty::next_solver::infer::InferCtxt>::probe
   8: hir_ty::method_resolution::probe::<impl hir_ty::method_resolution::MethodResolutionContext>::probe_op
   9: hir_ty::method_resolution::probe::<impl hir_ty::method_resolution::MethodResolutionContext>::probe_for_name
  10: hir_ty::infer::path::<impl hir_ty::infer::InferenceContext>::resolve_ty_assoc_item

  11: hir_ty::infer::path::<impl hir_ty::infer::InferenceContext>::resolve_value_path_inner
  12: hir_ty::infer::path::<impl hir_ty::infer::InferenceContext>::infer_path
  13: hir_ty::infer::expr::
<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  14: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  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_expr_inner
  18: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  19: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>
::infer_block
  20: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  21: hir_ty::infer::expr::<
impl hir_ty::infer::InferenceContext>::infer_return
  22: hir_ty::infer::infer_query_with_inspect
  23: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute

  24: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
  25: std::thread::local::LocalKey<T>::with
  26
: hir::semantics::SemanticsImpl::get_unsafe_ops
  27: ide::syntax_highlighting::traverse
  28: ide::syntax_highlighting::highlight

  29: salsa::cancelled::Cancelled::catch
  30: std::thread::local::LocalKey<T>::with
  31: ide::Analysis::highlight
  32: rust_analyzer::handlers::request::handle_semantic_tokens_full_delta
  33: core::ops::function::FnOnce::call_once{{vtable.shim}}
  34: <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(6400)) -> (R21, Durability::LOW)
             at crates/hir-ty/src/infer.rs:552


additional context:
   0: 
version: 0.3.2753-standalone
request: textDocument/semanticTokens/full/delta SemanticTokensDeltaParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: [path to main.rs here]
            query: None,
            fragment: None,
        },
    },
    previous_result_id: "2",
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions