Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cushionbadak opened this issue Mar 31, 2024 · 2 comments · Fixed by #126620
Closed

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

cushionbadak opened this issue Mar 31, 2024 · 2 comments · Fixed by #126620
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

cushionbadak commented Mar 31, 2024

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

@cushionbadak cushionbadak added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 31, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 31, 2024
@matthiaskrgr
Copy link
Member

Looks like a duplicate of #123157

@cushionbadak
Copy link
Author

Looks like a duplicate of #123157

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

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 8, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
@bors bors closed this as completed in e7be356 Jun 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 20, 2024
Rollup merge of rust-lang#126620 - oli-obk:taint_errors, r=fee1-dead

Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants