Skip to content

ICE: compiler/rustc_mir_build/src/build/expr/as_place.rs fn to_place None #123255

Closed

Description

@cushionbadak

Code

(slightly reduced)

#![crate_type = "lib"]

pub fn a() {}

mod handlers {
    pub struct C(&());
    pub fn c() -> impl Fn() -> C {
        let a1 = ();
        || C((crate::a(), a1).into())
    }
}

(original code)

Code

// ICE in mir building with captured value of unresolved type
// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
// issue: rust-lang/rust#110453
//@ edition:2021

#![crate_type="lib"]

pub struct B;
pub fn a() -> B { B }

mod handlers {
    pub struct C(&'a ());
    //~^ ERROR cannot find type `B` in this scope
    pub fn c() -> impl Fn() -> C {
        let a1 = ();
        || C((crate::a(), a1).into())
    }
}

Note

  • I guess the ICE-causing original code is mutated from rustc mir-build testscase,
    • where the original struct definition pub struct C(B); has been modified to pub struct C(&'a ());.

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (8df7e723e 2024-03-30)
binary: rustc
commit-hash: 8df7e723ea729a7f917501cc2d91d640b7021373
commit-date: 2024-03-30
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2

Command

rustc --edition=2021

Error output

error[E0106]: missing lifetime specifier
 --> reduced_66B4F29C3A73E1402A5F012317DC752A09758EA84D1682C6AA92AEB993764FAA.rs:6:18
  |
6 |     pub struct C(&());
  |                  ^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
6 |     pub struct C<'a>(&'a ());
  |                 ++++  ++
Backtrace

thread 'rustc' panicked at compiler/rustc_mir_build/src/build/expr/as_place.rs:253:31:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <rustc_mir_build::build::Builder>::expr_into_dest
   5: <rustc_mir_build::build::Builder>::as_temp_inner
   6: <rustc_mir_build::build::Builder>::as_operand
   7: <rustc_mir_build::build::Builder>::as_operand
   8: <rustc_mir_build::build::Builder>::as_rvalue
   9: <rustc_mir_build::build::Builder>::expr_into_dest
  10: <rustc_mir_build::build::Builder>::as_temp_inner
  11: <rustc_mir_build::build::Builder>::as_operand
  12: <rustc_mir_build::build::Builder>::as_call_operand
  13: <rustc_mir_build::build::Builder>::as_call_operand
  14: <rustc_mir_build::build::Builder>::expr_into_dest
  15: <rustc_mir_build::build::Builder>::as_temp_inner
  16: <rustc_mir_build::build::Builder>::as_operand
  17: <rustc_mir_build::build::Builder>::as_operand
  18: <rustc_mir_build::build::Builder>::expr_into_dest
  19: <rustc_mir_build::build::Builder>::expr_into_dest::{closure#0}
  20: <rustc_mir_build::build::Builder>::expr_into_dest
  21: rustc_mir_build::build::construct_fn
  22: rustc_mir_build::build::mir_build
  23: rustc_mir_transform::mir_built
      [... omitted 1 frame ...]
  24: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
  25: rustc_mir_transform::ffi_unwind_calls::has_ffi_unwind_calls
      [... omitted 1 frame ...]
  26: rustc_mir_transform::mir_promoted
      [... omitted 2 frames ...]
  27: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 16]>>>
  28: rustc_borrowck::mir_borrowck
      [... omitted 1 frame ...]
  29: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
  30: <rustc_borrowck::type_check::TypeChecker>::prove_closure_bounds
  31: <rustc_borrowck::type_check::TypeChecker>::check_rvalue
  32: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
  33: rustc_borrowck::type_check::type_check
  34: rustc_borrowck::nll::compute_regions
  35: rustc_borrowck::do_mir_borrowck
  36: rustc_borrowck::mir_borrowck
      [... omitted 1 frame ...]
  37: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
  38: rustc_hir_analysis::collect::type_of::type_of_opaque
      [... omitted 1 frame ...]
  39: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
  40: rustc_hir_analysis::collect::type_of::type_of
      [... omitted 1 frame ...]
  41: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
  42: rustc_hir_analysis::check::check::check_item_type
  43: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  44: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
  45: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 1 frame ...]
  46: rustc_hir_analysis::check_crate
  47: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  48: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  49: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `/Volumes/T7/workspace/placeholder_rustexec/0329/rustc-ice-2024-03-31T03_52_25-27883.txt` to your bug report

query stack during panic:
#0 [mir_built] building MIR for `handlers::c::{closure#0}`
#1 [has_ffi_unwind_calls] checking if `handlers::c::{closure#0}` contains FFI-unwind calls
#2 [mir_promoted] promoting constants in MIR for `handlers::c::{closure#0}`
#3 [mir_borrowck] borrow-checking `handlers::c::{closure#0}`
#4 [mir_borrowck] borrow-checking `handlers::c`
#5 [type_of_opaque] computing type of opaque `handlers::c::{opaque#0}`
#6 [type_of] computing type of `handlers::c::{opaque#0}`
#7 [check_well_formed] checking that `handlers::c::{opaque#0}` is well-formed
#8 [check_mod_type_wf] checking that types are well-formed in module `handlers`
#9 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0106`.

Related Issues

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 31, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 31, 2024
  3. matthiaskrgr commented on Apr 4, 2024

    @matthiaskrgr
    Member

    Looks like a duplicate of #123157

  4. cushionbadak commented on Apr 5, 2024

    @cushionbadak
    Author

    Looks like a duplicate of #123157

    Oh, I missed that one 😅
    Should I close this issue as not-planned?

  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 8, 2024
  6. added 3 commits that reference this issue on Jun 19, 2024
    3f36c28
    53ecfe7
    f0af381
  7. added a commit that references this issue on Jun 20, 2024
    e7be356
  8. added a commit that references this issue on Jun 20, 2024
    053c10c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions