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: transmute: not implemented: Cycle #117491

Closed
matthiaskrgr opened this issue Nov 1, 2023 · 1 comment · Fixed by #119772
Closed

ICE: transmute: not implemented: Cycle #117491

matthiaskrgr opened this issue Nov 1, 2023 · 1 comment · Fixed by #119772
Assignees
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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

mod assert {
    use std::mem::{Assume, BikeshedIntrinsicFrom};
    pub struct Context;

    pub fn is_maybe_transmutable<Src, Dst>()
    where
        Dst: BikeshedIntrinsicFrom<Src, Context>,
    {
    }
}

fn should_pad_explicitly_packed_field() {
    #[repr(C)]
    struct ExplicitlyPadded(ExplicitlyPadded);

    assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
}

original:

mod assert {
    use std::mem::{Assume, BikeshedIntrinsicFrom};
    pub struct Context;

    pub fn is_maybe_transmutable<Src, Dst>()
    where
        Dst: BikeshedIntrinsicFrom<Src, Context>,
    {
    }
}

fn should_pad_explicitly_packed_field() {
    enum V0u8 {
        V = 0,
    }

    pub union Uninit {
        a: (),
        b: V0u8,
    }

    #[repr(C)]
    struct ExplicitlyPadded(ExplicitlyPadded);

    assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
}

Version information

rustc 1.75.0-nightly (11cd1f002 2023-11-01)
binary: rustc
commit-hash: 11cd1f00268061dff447bc0df3d679b35d460875
commit-date: 2023-11-01
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.4

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: unused import: `Assume`
 --> /tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs:2:20
  |
2 |     use std::mem::{Assume, BikeshedIntrinsicFrom};
  |                    ^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs:17:2
   |
17 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs`

error[E0658]: use of unstable library feature 'transmutability'
 --> /tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs:2:20
  |
2 |     use std::mem::{Assume, BikeshedIntrinsicFrom};
  |                    ^^^^^^
  |
  = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
  = help: add `#![feature(transmutability)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'transmutability'
 --> /tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs:2:28
  |
2 |     use std::mem::{Assume, BikeshedIntrinsicFrom};
  |                            ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
  = help: add `#![feature(transmutability)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'transmutability'
 --> /tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs:7:14
  |
7 |         Dst: BikeshedIntrinsicFrom<Src, Context>,
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
  = help: add `#![feature(transmutability)]` to the crate attributes to enable

error[E0072]: recursive type `ExplicitlyPadded` has infinite size
  --> /tmp/icemaker_global_tempdir.fRJN4fR6sfYc/rustc_testrunner_tmpdir_reporting.9qgozuo6451M/mvce.rs:14:5
   |
14 |     struct ExplicitlyPadded(ExplicitlyPadded);
   |     ^^^^^^^^^^^^^^^^^^^^^^^ ---------------- recursive without indirection
   |
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
   |
14 |     struct ExplicitlyPadded(Box<ExplicitlyPadded>);
   |                             ++++                +

error[E0391]: cycle detected when computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded`
  |
  = note: ...which immediately requires computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` again
  = note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, assert::Context, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

thread 'rustc' panicked at compiler/rustc_transmute/src/layout/tree.rs:202:24:
not implemented: Cycle
stack backtrace:
   0:     0x7f44f4f69cfc - std::backtrace_rs::backtrace::libunwind::trace::hf337e9a1b2eefec7
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f44f4f69cfc - std::backtrace_rs::backtrace::trace_unsynchronized::hd403e7c33ea47db5
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f44f4f69cfc - std::sys_common::backtrace::_print_fmt::hb82fff7b01334105
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f44f4f69cfc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbef0c62239df8317
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f44f4fcbef0 - core::fmt::rt::Argument::fmt::h3a98781498209cfb
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/core/src/fmt/rt.rs:142:9
   5:     0x7f44f4fcbef0 - core::fmt::write::h99e91fba6b08deab
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f44f4f5dc1f - std::io::Write::write_fmt::he13b638451da3657
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/io/mod.rs:1763:15
   7:     0x7f44f4f69ae4 - std::sys_common::backtrace::_print::hbde38cb8fe94ee2d
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f44f4f69ae4 - std::sys_common::backtrace::print::h65eb3e10b81811f1
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f44f4f6c777 - std::panicking::default_hook::{{closure}}::hd25239f22521c22b
  10:     0x7f44f4f6c4df - std::panicking::default_hook::hff58cd128fac3a73
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/panicking.rs:292:9
  11:     0x7f44f7ad9c30 - std[114aeea37183646d]::panicking::update_hook::<alloc[3407882df4067ddc]::boxed::Box<rustc_driver_impl[4a240edf19cfe501]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f44f4f6ceb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd4e46d91a21e0a2f
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/alloc/src/boxed.rs:2021:9
  13:     0x7f44f4f6ceb8 - std::panicking::rust_panic_with_hook::hc42c4990ce4accb0
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/panicking.rs:783:13
  14:     0x7f44f4f6cc0e - std::panicking::begin_panic_handler::{{closure}}::h259e895efabde9cf
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/panicking.rs:657:13
  15:     0x7f44f4f6a1c6 - std::sys_common::backtrace::__rust_end_short_backtrace::hdc0b762c5f2d3290
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f44f4f6c972 - rust_begin_unwind
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/panicking.rs:645:5
  17:     0x7f44f4fc8615 - core::panicking::panic_fmt::hf2677c1e3f814967
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/core/src/panicking.rs:72:14
  18:     0x7f44f85187be - <rustc_transmute[2c16d89708a25746]::layout::tree::rustc::Err as core[e1aaa68dbbc63f77]::convert::From<&rustc_middle[f8698e1d8382d76c]::ty::layout::LayoutError>>::from
  19:     0x7f44f8519216 - <rustc_transmute[2c16d89708a25746]::layout::tree::Tree<rustc_transmute[2c16d89708a25746]::layout::rustc::Def, rustc_transmute[2c16d89708a25746]::layout::rustc::Ref>>::from_ty
  20:     0x7f44f851c4f7 - <rustc_transmute[2c16d89708a25746]::rustc::TransmuteTypeEnv>::is_transmutable
  21:     0x7f44f9627b16 - <rustc_trait_selection[2f80e02d5b7ffcda]::traits::select::SelectionContext>::confirm_candidate
  22:     0x7f44f960bd56 - <rustc_trait_selection[2f80e02d5b7ffcda]::traits::select::SelectionContext>::evaluate_candidate
  23:     0x7f44f93c8d6b - <rustc_trait_selection[2f80e02d5b7ffcda]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  24:     0x7f44f93c231c - <rustc_trait_selection[2f80e02d5b7ffcda]::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection[2f80e02d5b7ffcda]::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>
  25:     0x7f44f8e7a3c6 - rustc_traits[ca87abc2a558096c]::evaluate_obligation::evaluate_obligation
  26:     0x7f44f8e79e20 - rustc_query_impl[92b020c0f41871dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[92b020c0f41871dc]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f8698e1d8382d76c]::query::erase::Erased<[u8; 2usize]>>
  27:     0x7f44f8e797f8 - rustc_query_system[2501f8730129aa9c]::query::plumbing::try_execute_query::<rustc_query_impl[92b020c0f41871dc]::DynamicConfig<rustc_query_system[2501f8730129aa9c]::query::caches::DefaultCache<rustc_type_ir[84234e71f859f58e]::canonical::Canonical<rustc_middle[f8698e1d8382d76c]::ty::context::TyCtxt, rustc_middle[f8698e1d8382d76c]::ty::ParamEnvAnd<rustc_middle[f8698e1d8382d76c]::ty::Predicate>>, rustc_middle[f8698e1d8382d76c]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[92b020c0f41871dc]::plumbing::QueryCtxt, false>
  28:     0x7f44f8e794df - rustc_query_impl[92b020c0f41871dc]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f44f5f9e184 - <rustc_trait_selection[2f80e02d5b7ffcda]::traits::fulfill::FulfillProcessor as rustc_data_structures[22f3e173f4dc4ddb]::obligation_forest::ObligationProcessor>::process_obligation
  30:     0x7f44f8c11055 - <rustc_data_structures[22f3e173f4dc4ddb]::obligation_forest::ObligationForest<rustc_trait_selection[2f80e02d5b7ffcda]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[2f80e02d5b7ffcda]::traits::fulfill::FulfillProcessor>
  31:     0x7f44f95d5fe1 - <rustc_hir_typeck[4d3bbc2cd4689c0f]::fn_ctxt::FnCtxt>::check_argument_types
  32:     0x7f44f95ce6da - <rustc_hir_typeck[4d3bbc2cd4689c0f]::fn_ctxt::FnCtxt>::check_call
  33:     0x7f44f96a8794 - <rustc_hir_typeck[4d3bbc2cd4689c0f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  34:     0x7f44f90f49d9 - <rustc_hir_typeck[4d3bbc2cd4689c0f]::fn_ctxt::FnCtxt>::check_block_with_expected
  35:     0x7f44f96a88e9 - <rustc_hir_typeck[4d3bbc2cd4689c0f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7f44f941b119 - rustc_hir_typeck[4d3bbc2cd4689c0f]::check::check_fn
  37:     0x7f44f8f29c0a - rustc_hir_typeck[4d3bbc2cd4689c0f]::typeck
  38:     0x7f44f8f2907d - rustc_query_impl[92b020c0f41871dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[92b020c0f41871dc]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f8698e1d8382d76c]::query::erase::Erased<[u8; 8usize]>>
  39:     0x7f44f8d1006c - rustc_query_system[2501f8730129aa9c]::query::plumbing::try_execute_query::<rustc_query_impl[92b020c0f41871dc]::DynamicConfig<rustc_query_system[2501f8730129aa9c]::query::caches::VecCache<rustc_span[9b73632204a5702]::def_id::LocalDefId, rustc_middle[f8698e1d8382d76c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[92b020c0f41871dc]::plumbing::QueryCtxt, false>
  40:     0x7f44f8d0fd50 - rustc_query_impl[92b020c0f41871dc]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f44f90c28d9 - rustc_hir_analysis[48c9c6619aead8a8]::check_crate
  42:     0x7f44f91b7116 - rustc_interface[65dc9bd9189cd136]::passes::analysis
  43:     0x7f44f91b6b35 - rustc_query_impl[92b020c0f41871dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[92b020c0f41871dc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f8698e1d8382d76c]::query::erase::Erased<[u8; 1usize]>>
  44:     0x7f44f9708ba6 - rustc_query_system[2501f8730129aa9c]::query::plumbing::try_execute_query::<rustc_query_impl[92b020c0f41871dc]::DynamicConfig<rustc_query_system[2501f8730129aa9c]::query::caches::SingleCache<rustc_middle[f8698e1d8382d76c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[92b020c0f41871dc]::plumbing::QueryCtxt, false>
  45:     0x7f44f97089d5 - rustc_query_impl[92b020c0f41871dc]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f44f982ba86 - rustc_interface[65dc9bd9189cd136]::interface::run_compiler::<core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>, rustc_driver_impl[4a240edf19cfe501]::run_compiler::{closure#1}>::{closure#0}
  47:     0x7f44f9827e35 - std[114aeea37183646d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[65dc9bd9189cd136]::util::run_in_thread_with_globals<rustc_interface[65dc9bd9189cd136]::interface::run_compiler<core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>, rustc_driver_impl[4a240edf19cfe501]::run_compiler::{closure#1}>::{closure#0}, core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>>
  48:     0x7f44f9827c8d - <<std[114aeea37183646d]::thread::Builder>::spawn_unchecked_<rustc_interface[65dc9bd9189cd136]::util::run_in_thread_with_globals<rustc_interface[65dc9bd9189cd136]::interface::run_compiler<core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>, rustc_driver_impl[4a240edf19cfe501]::run_compiler::{closure#1}>::{closure#0}, core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e1aaa68dbbc63f77]::result::Result<(), rustc_span[9b73632204a5702]::ErrorGuaranteed>>::{closure#1} as core[e1aaa68dbbc63f77]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f44f4f77c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h05e145a7807cc5b2
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/alloc/src/boxed.rs:2007:9
  50:     0x7f44f4f77c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9003b8eee91ef1fa
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/alloc/src/boxed.rs:2007:9
  51:     0x7f44f4f77c25 - std::sys::unix::thread::Thread::new::thread_start::h277cb4377eb8d1f1
                               at /rustc/11cd1f00268061dff447bc0df3d679b35d460875/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7f44f4d419eb - <unknown>
  53:     0x7f44f4dc57cc - <unknown>
  54:                0x0 - <unknown>

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: rustc 1.75.0-nightly (11cd1f002 2023-11-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, assert::Context, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
#1 [typeck] type-checking `should_pad_explicitly_packed_field`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0072, E0391, E0601, E0658.
For more information about an error, try `rustc --explain E0072`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Nov 1, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 1, 2023
@matthiaskrgr
Copy link
Member Author

a56bd2b / #116849 ping @oli-obk 😁

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 1, 2023
@oli-obk oli-obk self-assigned this Jan 9, 2024
@bors bors closed this as completed in 4571ef9 Jan 10, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 10, 2024
Rollup merge of rust-lang#119772 - oli-obk:whackamole, r=compiler-errors

Fix an ICE that occurs after an error has already been reported

fixes rust-lang#117491

cc `@jswrenn`
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