Skip to content

ICE: Size::sub: 0 - 1 would result in negative size #133056

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet:

pub enum ApiError {}
pub struct TokioError {
    source: ApiError,
}
pub enum Error {
    Api { b: bool },
    Ethereum,
    Tokio { source: TokioError },
}

mod assert {
    use std::mem::TransmuteFrom;

    pub fn is_transmutable<Src, Dst>()
    where
        Dst: TransmuteFrom<Src>,
    {
    }
}

fn test() {
    type Dst = Error;
    assert::is_transmutable::<Src, Dst>();
}

Version information

rustc 1.84.0-nightly (c82e0dff8 2024-11-14)
binary: rustc
commit-hash: c82e0dff84f922274c3060f09b5ae78d5dbf5c49
commit-date: 2024-11-14
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

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

Program output

error[E0412]: cannot find type `Src` in this scope
  --> /tmp/icemaker_global_tempdir.GBBrkujq9Fd6/rustc_testrunner_tmpdir_reporting.UhcNDAgP0tXJ/mvce.rs:23:31
   |
23 |     assert::is_transmutable::<Src, Dst>();
   |                               ^^^ not found in this scope
   |
help: you might be missing a type parameter
   |
21 | fn test<Src>() {
   |        +++++

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

error[E0658]: use of unstable library feature `transmutability`
  --> /tmp/icemaker_global_tempdir.GBBrkujq9Fd6/rustc_testrunner_tmpdir_reporting.UhcNDAgP0tXJ/mvce.rs:12:9
   |
12 |     use std::mem::TransmuteFrom;
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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
   = note: this compiler was built on 2024-11-14; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `transmutability`
  --> /tmp/icemaker_global_tempdir.GBBrkujq9Fd6/rustc_testrunner_tmpdir_reporting.UhcNDAgP0tXJ/mvce.rs:16:14
   |
16 |         Dst: TransmuteFrom<Src>,
   |              ^^^^^^^^^^^^^^^^^^
   |
   = 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
   = note: this compiler was built on 2024-11-14; consider upgrading it if it is out of date

thread 'rustc' panicked at /rustc/c82e0dff84f922274c3060f09b5ae78d5dbf5c49/compiler/rustc_abi/src/lib.rs:607:13:
Size::sub: 0 - 1 would result in negative size
stack backtrace:
   0:     0x7cdade65fd4a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2adc1a6ccad5ebd6
   1:     0x7cdadee0448a - core::fmt::write::ha04e70fc5d881ab5
   2:     0x7cdadfe373d1 - std::io::Write::write_fmt::hd5436bc11a487b2b
   3:     0x7cdade65fba2 - std::sys::backtrace::BacktraceLock::print::hf9ae481fe0b64c2e
   4:     0x7cdade6620a6 - std::panicking::default_hook::{{closure}}::hff5be5187ad1861e
   5:     0x7cdade661ef0 - std::panicking::default_hook::h6cddc3759d3da86b
   6:     0x7cdadd6e7581 - std[863895b03377d1a5]::panicking::update_hook::<alloc[f2797b84b7beae29]::boxed::Box<rustc_driver_impl[e3633d415ec0d695]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7cdade6627b8 - std::panicking::rust_panic_with_hook::hca4f897be66010e4
   8:     0x7cdade66258a - std::panicking::begin_panic_handler::{{closure}}::h03f4fa9b08b95134
   9:     0x7cdade6601f9 - std::sys::backtrace::__rust_end_short_backtrace::h500b829202f5ce6e
  10:     0x7cdade66224c - rust_begin_unwind
  11:     0x7cdadb0de020 - core::panicking::panic_fmt::hc35c295fc7ab222f
  12:     0x7cdade59ece6 - <rustc_transmute[faaefdf4ee3dc53a]::layout::tree::Tree<rustc_transmute[faaefdf4ee3dc53a]::layout::rustc::Def, rustc_transmute[faaefdf4ee3dc53a]::layout::rustc::Ref>>::from_variant
  13:     0x7cdade59e439 - <rustc_transmute[faaefdf4ee3dc53a]::layout::tree::Tree<rustc_transmute[faaefdf4ee3dc53a]::layout::rustc::Def, rustc_transmute[faaefdf4ee3dc53a]::layout::rustc::Ref>>::from_enum::{closure#0}
  14:     0x7cdade59d663 - <rustc_transmute[faaefdf4ee3dc53a]::layout::tree::Tree<rustc_transmute[faaefdf4ee3dc53a]::layout::rustc::Def, rustc_transmute[faaefdf4ee3dc53a]::layout::rustc::Ref>>::from_enum
  15:     0x7cdade5a1fb7 - <rustc_transmute[faaefdf4ee3dc53a]::rustc::TransmuteTypeEnv>::is_transmutable
  16:     0x7cdadf81e6ea - <rustc_trait_selection[4be8e437e7f9364a]::traits::select::SelectionContext>::confirm_candidate
  17:     0x7cdadf80c401 - <rustc_trait_selection[4be8e437e7f9364a]::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  18:     0x7cdadf80e3af - <rustc_trait_selection[4be8e437e7f9364a]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  19:     0x7cdadeec6674 - <rustc_trait_selection[4be8e437e7f9364a]::traits::select::SelectionContext>::evaluate_root_obligation
  20:     0x7cdadeec4d4c - rustc_traits[f9b89e85a8f66b9e]::evaluate_obligation::evaluate_obligation
  21:     0x7cdadeec4829 - rustc_query_impl[6186f0c3e1276bff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6186f0c3e1276bff]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[65ee48d2c6d8ec4d]::query::erase::Erased<[u8; 2usize]>>
  22:     0x7cdadeec3aff - rustc_query_system[9d44b227f7e0ff7f]::query::plumbing::try_execute_query::<rustc_query_impl[6186f0c3e1276bff]::DynamicConfig<rustc_query_system[9d44b227f7e0ff7f]::query::caches::DefaultCache<rustc_type_ir[6b4bb04b83874af]::canonical::CanonicalQueryInput<rustc_middle[65ee48d2c6d8ec4d]::ty::context::TyCtxt, rustc_middle[65ee48d2c6d8ec4d]::ty::ParamEnvAnd<rustc_middle[65ee48d2c6d8ec4d]::ty::predicate::Predicate>>, rustc_middle[65ee48d2c6d8ec4d]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[6186f0c3e1276bff]::plumbing::QueryCtxt, false>
  23:     0x7cdadeec3727 - rustc_query_impl[6186f0c3e1276bff]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7cdadfac6339 - <rustc_trait_selection[4be8e437e7f9364a]::traits::fulfill::FulfillProcessor as rustc_data_structures[c5905adad0155b82]::obligation_forest::ObligationProcessor>::process_obligation
  25:     0x7cdadee108ed - <rustc_data_structures[c5905adad0155b82]::obligation_forest::ObligationForest<rustc_trait_selection[4be8e437e7f9364a]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[4be8e437e7f9364a]::traits::fulfill::FulfillProcessor>
  26:     0x7cdadb51cec3 - <rustc_hir_typeck[4599e8faa01bc81]::fn_ctxt::FnCtxt>::confirm_builtin_call
  27:     0x7cdadfb6fc98 - <rustc_hir_typeck[4599e8faa01bc81]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7cdadfb6a1f5 - <rustc_hir_typeck[4599e8faa01bc81]::fn_ctxt::FnCtxt>::check_expr_block
  29:     0x7cdadfb7057a - <rustc_hir_typeck[4599e8faa01bc81]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7cdadf050740 - rustc_hir_typeck[4599e8faa01bc81]::check::check_fn
  31:     0x7cdadf0461ac - rustc_hir_typeck[4599e8faa01bc81]::typeck
  32:     0x7cdadf045b53 - rustc_query_impl[6186f0c3e1276bff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6186f0c3e1276bff]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[65ee48d2c6d8ec4d]::query::erase::Erased<[u8; 8usize]>>
  33:     0x7cdadf22a141 - rustc_query_system[9d44b227f7e0ff7f]::query::plumbing::try_execute_query::<rustc_query_impl[6186f0c3e1276bff]::DynamicConfig<rustc_query_system[9d44b227f7e0ff7f]::query::caches::VecCache<rustc_span[fb642a8bb558ae04]::def_id::LocalDefId, rustc_middle[65ee48d2c6d8ec4d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[6186f0c3e1276bff]::plumbing::QueryCtxt, false>
  34:     0x7cdadf22880d - rustc_query_impl[6186f0c3e1276bff]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7cdadf228487 - <rustc_middle[65ee48d2c6d8ec4d]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[fa41a08a2a011325]::check_crate::{closure#4}>::{closure#0}
  36:     0x7cdadf22644f - rustc_hir_analysis[fa41a08a2a011325]::check_crate
  37:     0x7cdadf2f930a - rustc_interface[e545adac085767f3]::passes::run_required_analyses
  38:     0x7cdadfc59e9e - rustc_interface[e545adac085767f3]::passes::analysis
  39:     0x7cdadfc59e6f - rustc_query_impl[6186f0c3e1276bff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6186f0c3e1276bff]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[65ee48d2c6d8ec4d]::query::erase::Erased<[u8; 1usize]>>
  40:     0x7cdadfe0466e - rustc_query_system[9d44b227f7e0ff7f]::query::plumbing::try_execute_query::<rustc_query_impl[6186f0c3e1276bff]::DynamicConfig<rustc_query_system[9d44b227f7e0ff7f]::query::caches::SingleCache<rustc_middle[65ee48d2c6d8ec4d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6186f0c3e1276bff]::plumbing::QueryCtxt, false>
  41:     0x7cdadfe0434e - rustc_query_impl[6186f0c3e1276bff]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7cdadfcba3fa - rustc_interface[e545adac085767f3]::interface::run_compiler::<core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>, rustc_driver_impl[e3633d415ec0d695]::run_compiler::{closure#0}>::{closure#1}
  43:     0x7cdadfd93c50 - std[863895b03377d1a5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e545adac085767f3]::util::run_in_thread_with_globals<rustc_interface[e545adac085767f3]::util::run_in_thread_pool_with_globals<rustc_interface[e545adac085767f3]::interface::run_compiler<core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>, rustc_driver_impl[e3633d415ec0d695]::run_compiler::{closure#0}>::{closure#1}, core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>>::{closure#0}, core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>>
  44:     0x7cdadfd9406b - <<std[863895b03377d1a5]::thread::Builder>::spawn_unchecked_<rustc_interface[e545adac085767f3]::util::run_in_thread_with_globals<rustc_interface[e545adac085767f3]::util::run_in_thread_pool_with_globals<rustc_interface[e545adac085767f3]::interface::run_compiler<core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>, rustc_driver_impl[e3633d415ec0d695]::run_compiler::{closure#0}>::{closure#1}, core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>>::{closure#0}, core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[743d4ac3bfe516ce]::result::Result<(), rustc_span[fb642a8bb558ae04]::ErrorGuaranteed>>::{closure#1} as core[743d4ac3bfe516ce]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7cdadfd94b39 - std::sys::pal::unix::thread::Thread::new::thread_start::h9771eb904dccac80
  46:     0x7cdae15cf39d - <unknown>
  47:     0x7cdae165449c - <unknown>
  48:                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: please make sure that you have updated to the latest nightly

note: rustc 1.84.0-nightly (c82e0dff8 2024-11-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `Error: core::mem::transmutability::TransmuteFrom<{type error}, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
#1 [typeck] type-checking `test`
end of query stack
error: aborting due to 4 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-transmutability`#![feature(transmutability)]`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