rust-lang / rust-lang/rust-analyzer

thread 'Worker' panicked at 'internal error: entered unreachable code: Only adt has field, found AssocTypeId(525)<[?0 := AdtId(StructId(StructId(870)))<[?0 := !0_3]>]>', crates/hir-ty/src/mir.rs:170:21

Open
#15,664 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: rust-analyzer version: 0.4.0-standalone.amzn.519.0 (05666441 2023-09-18)

rustc version: rustc 1.72.1 (d5c2e9c34 2023-09-13) (built from a source tarball)

Been getting this error every time I try to autocomplete (Ctrl+Space on mac) in my workspace

Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at 'internal error: entered unreachable code: Only adt has field, found AssocTypeId(525)<[?0 := AdtId(StructId(StructId(870)))<[?0 := !0_3]>]>', crates/hir-ty/src/mir.rs:170:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
   2: hir_ty::mir::ProjectionElem<V,T>::projected_ty
   3: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}}
   4: hir_ty::mir::borrowck::moved_out_of_ref
   5: hir_ty::mir::borrowck::borrowck_query::{{closure}}
   6: hir_ty::mir::borrowck::all_mir_bodies
   7: hir_ty::mir::borrowck::borrowck_query
   8: salsa::runtime::Runtime::execute_query_implementation
   9: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  10: salsa::derived::slot::Slot<Q,MP>::read
  11: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  12: <DB as hir_ty::db::HirDatabase>::borrowck::__shim
  13: <DB as hir_ty::db::HirDatabase>::borrowck
  14: hir::DefWithBody::diagnostics
  15: hir::Module::diagnostics
  16: ide_diagnostics::diagnostics
  17: salsa::Cancelled::catch
  18: ide::Analysis::diagnostics
  19: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  20: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  21: rust_analyzer::diagnostics::fetch_native_diagnostics
  22: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 0.4.0-standalone.amzn.519.0 (05666441 2023-09-18)
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/<snip>/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 142,
            character: 40,
        },
        end: Position {
            line: 142,
            character: 40,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
        trigger_kind: Some(
            Automatic,
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at 'internal error: entered unreachable code: Only adt has field, found AssocTypeId(525)<[?0 := AdtId(StructId(StructId(870)))<[?0 := !0_3]>]>', crates/hir-ty/src/mir.rs:170:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
   2: hir_ty::mir::ProjectionElem<V,T>::projected_ty
   3: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}}
   4: hir_ty::mir::borrowck::moved_out_of_ref
   5: hir_ty::mir::borrowck::borrowck_query::{{closure}}
   6: hir_ty::mir::borrowck::all_mir_bodies
   7: hir_ty::mir::borrowck::borrowck_query
   8: salsa::runtime::Runtime::execute_query_implementation
   9: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  10: salsa::derived::slot::Slot<Q,MP>::read
  11: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  12: <DB as hir_ty::db::HirDatabase>::borrowck::__shim
  13: <DB as hir_ty::db::HirDatabase>::borrowck
  14: hir::DefWithBody::diagnostics
  15: hir::Module::diagnostics
  16: ide_diagnostics::diagnostics
  17: std::panicking::try
  18: ide::Analysis::assists_with_fixes
  19: rust_analyzer::handlers::request::handle_code_action
  20: std::panicking::try
  21: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 0.4.0-standalone.amzn.519.0 (05666441 2023-09-18)
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/<snip>/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 143,
            character: 14,
        },
        end: Position {
            line: 143,
            character: 14,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
        trigger_kind: Some(
            Automatic,
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at 'internal error: entered unreachable code: Only adt has field, found AssocTypeId(525)<[?0 := AdtId(StructId(StructId(870)))<[?0 := !0_3]>]>', crates/hir-ty/src/mir.rs:170:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
   2: hir_ty::mir::ProjectionElem<V,T>::projected_ty
   3: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}}
   4: hir_ty::mir::borrowck::moved_out_of_ref
   5: hir_ty::mir::borrowck::borrowck_query::{{closure}}
   6: hir_ty::mir::borrowck::all_mir_bodies
   7: hir_ty::mir::borrowck::borrowck_query
   8: salsa::runtime::Runtime::execute_query_implementation
   9: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  10: salsa::derived::slot::Slot<Q,MP>::read
  11: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  12: <DB as hir_ty::db::HirDatabase>::borrowck::__shim
  13: <DB as hir_ty::db::HirDatabase>::borrowck
  14: hir::DefWithBody::diagnostics
  15: hir::Module::diagnostics
  16: ide_diagnostics::diagnostics
  17: std::panicking::try
  18: ide::Analysis::assists_with_fixes
  19: rust_analyzer::handlers::request::handle_code_action
  20: std::panicking::try
  21: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at crates/hir-ty/src/mir.rs:170 in ProjectionElem::projected_ty and trace the borrowck::moved_out_of_ref call shown in the backtrace. Reproduce the panic through autocomplete or code-action requests, then verify those requests no longer panic for the reported associated-type case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.