Skip to content

ICE: dyn !Sized #144241

Open
Open

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
type _0 = dyn !Sized;

original:

// Test that `dyn ?Sized` (i.e., a trait object with only a maybe buond) is not allowed.

type _0 = dyn !Sized;
//~^ ERROR at least one trait is required for an object type [E0224]
//~| ERROR relaxed bounds are not permitted in trait object types

fn main() {}

Version information

rustc 1.90.0-nightly (e05ab47e6 2025-07-21)
binary: rustc
commit-hash: e05ab47e6c418fb2b9faa2eae9a7e70c65c98eaa
commit-date: 2025-07-21
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

Possibly related line of code:

// We achieve a stable ordering by walking over the unsubstituted principal
// trait ref.
let mut ordered_associated_types = vec![];
if let Some((principal_trait, ref spans)) = principal_trait {
let principal_trait = principal_trait.map_bound(|trait_pred| {
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
trait_pred.trait_ref
});
for ClauseWithSupertraitSpan { clause, supertrait_span } in traits::elaborate(
tcx,
[ClauseWithSupertraitSpan::new(

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

error: negative bounds are not supported
 --> /tmp/icemaker_global_tempdir.Ism9jqXZadUU/rustc_testrunner_tmpdir_reporting.E7C0NMbYkVD9/mvce.rs:1:15
  |
1 | type _0 = dyn !Sized;
  |               ^

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.Ism9jqXZadUU/rustc_testrunner_tmpdir_reporting.E7C0NMbYkVD9/mvce.rs:1:22
  |
1 | type _0 = dyn !Sized;
  |                      ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Ism9jqXZadUU/rustc_testrunner_tmpdir_reporting.E7C0NMbYkVD9/mvce.rs`


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs:164:17:
assertion `left == right` failed
  left: Negative
 right: Positive
stack backtrace:
   0:     0x7d548f1aed13 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h085efbd236febcbd
   1:     0x7d548fa02cf7 - core::fmt::write::hdec995910d7cb82c
   2:     0x7d548f1a4983 - std::io::Write::write_fmt::hdeaf768f2514aca6
   3:     0x7d548f1aeb72 - std::sys::backtrace::BacktraceLock::print::h21329d1cea89715b
   4:     0x7d548f1b2617 - std::panicking::default_hook::{{closure}}::h2b9a0773f7d3658d
   5:     0x7d548f1b217b - std::panicking::default_hook::h6914ecce7597b75d
   6:     0x7d548e23ce53 - std[c460a2864e85620a]::panicking::update_hook::<alloc[e5e1e0fb3e88a69e]::boxed::Box<rustc_driver_impl[5cdc508988eda417]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7d548f1b2e5e - std::panicking::rust_panic_with_hook::hda79d560b2103b22
   8:     0x7d548f1b2b5a - std::panicking::begin_panic_handler::{{closure}}::h11e64d6275db65a6
   9:     0x7d548f1af1e9 - std::sys::backtrace::__rust_end_short_backtrace::heaac04fc129e000e
  10:     0x7d548f1b283d - __rustc[8435b3fdf207ac82]::rust_begin_unwind
  11:     0x7d548b8caf90 - core::panicking::panic_fmt::h00265bbaa0446d87
  12:     0x7d548dc12d47 - core::panicking::assert_failed_inner::ha50e6f2acfdbea53
  13:     0x7d548eefe55f - core[66948c5bc5ff115d]::panicking::assert_failed::<rustc_type_ir[206b20cbc4cc23b8]::predicate::PredicatePolarity, rustc_type_ir[206b20cbc4cc23b8]::predicate::PredicatePolarity>
  14:     0x7d5490957bee - <dyn rustc_hir_analysis[7dd98ded1e59e61f]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty
  15:     0x7d54903913ae - <dyn rustc_hir_analysis[7dd98ded1e59e61f]::hir_ty_lowering::HirTyLowerer>::lower_ty
  16:     0x7d54903a198d - rustc_hir_analysis[7dd98ded1e59e61f]::collect::type_of::type_of
  17:     0x7d548fa1936c - rustc_query_impl[e2149f423b14ff5d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e2149f423b14ff5d]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 8usize]>>
  18:     0x7d548fa18025 - rustc_query_system[4d6471456bd701ae]::query::plumbing::try_execute_query::<rustc_query_impl[e2149f423b14ff5d]::DynamicConfig<rustc_query_system[4d6471456bd701ae]::query::caches::DefIdCache<rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e2149f423b14ff5d]::plumbing::QueryCtxt, false>
  19:     0x7d548fa17bdd - rustc_query_impl[e2149f423b14ff5d]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7d54908be0ea - rustc_hir_analysis[7dd98ded1e59e61f]::check::check::check_item_type
  21:     0x7d54908b7e35 - rustc_hir_analysis[7dd98ded1e59e61f]::check::wfcheck::check_well_formed
  22:     0x7d54908b7e17 - rustc_query_impl[e2149f423b14ff5d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e2149f423b14ff5d]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 1usize]>>
  23:     0x7d54908b764c - rustc_query_system[4d6471456bd701ae]::query::plumbing::try_execute_query::<rustc_query_impl[e2149f423b14ff5d]::DynamicConfig<rustc_data_structures[8223ad205e246b01]::vec_cache::VecCache<rustc_span[854d2ff5fa944bc2]::def_id::LocalDefId, rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[4d6471456bd701ae]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e2149f423b14ff5d]::plumbing::QueryCtxt, false>
  24:     0x7d54908b7182 - rustc_query_impl[e2149f423b14ff5d]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7d54908b48a3 - rustc_hir_analysis[7dd98ded1e59e61f]::check::wfcheck::check_type_wf
  26:     0x7d54908b47b9 - rustc_query_impl[e2149f423b14ff5d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e2149f423b14ff5d]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 1usize]>>
  27:     0x7d5490adbe3c - rustc_query_system[4d6471456bd701ae]::query::plumbing::try_execute_query::<rustc_query_impl[e2149f423b14ff5d]::DynamicConfig<rustc_query_system[4d6471456bd701ae]::query::caches::SingleCache<rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e2149f423b14ff5d]::plumbing::QueryCtxt, false>
  28:     0x7d5490adbc36 - rustc_query_impl[e2149f423b14ff5d]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7d54900e509b - rustc_hir_analysis[7dd98ded1e59e61f]::check_crate
  30:     0x7d54900e9dc4 - rustc_interface[21031aeca52a62ab]::passes::analysis
  31:     0x7d54900e9a87 - rustc_query_impl[e2149f423b14ff5d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e2149f423b14ff5d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7d5490add5bc - rustc_query_system[4d6471456bd701ae]::query::plumbing::try_execute_query::<rustc_query_impl[e2149f423b14ff5d]::DynamicConfig<rustc_query_system[4d6471456bd701ae]::query::caches::SingleCache<rustc_middle[966becd38e69f903]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e2149f423b14ff5d]::plumbing::QueryCtxt, false>
  33:     0x7d5490add184 - rustc_query_impl[e2149f423b14ff5d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7d5490d55d4b - rustc_interface[21031aeca52a62ab]::passes::create_and_enter_global_ctxt::<core[66948c5bc5ff115d]::option::Option<rustc_interface[21031aeca52a62ab]::queries::Linker>, rustc_driver_impl[5cdc508988eda417]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  35:     0x7d5490d4389e - rustc_interface[21031aeca52a62ab]::interface::run_compiler::<(), rustc_driver_impl[5cdc508988eda417]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7d5490c0e4b8 - std[c460a2864e85620a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[21031aeca52a62ab]::util::run_in_thread_with_globals<rustc_interface[21031aeca52a62ab]::util::run_in_thread_pool_with_globals<rustc_interface[21031aeca52a62ab]::interface::run_compiler<(), rustc_driver_impl[5cdc508988eda417]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7d5490c0e196 - <<std[c460a2864e85620a]::thread::Builder>::spawn_unchecked_<rustc_interface[21031aeca52a62ab]::util::run_in_thread_with_globals<rustc_interface[21031aeca52a62ab]::util::run_in_thread_pool_with_globals<rustc_interface[21031aeca52a62ab]::interface::run_compiler<(), rustc_driver_impl[5cdc508988eda417]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[66948c5bc5ff115d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7d5490c1413d - std::sys::pal::unix::thread::Thread::new::thread_start::h2841d6229de09b0b
  39:     0x7d548a4a57eb - <unknown>
  40:     0x7d548a52918c - <unknown>
  41:                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.90.0-nightly (e05ab47e6 2025-07-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [type_of] expanding type alias `_0`
#1 [check_well_formed] checking that `_0` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

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

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Jul 21, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 21, 2025
  3. matthiaskrgr commented on Jul 21, 2025

    @matthiaskrgr
    MemberAuthor
  4. self-assigned this
    on Jul 21, 2025
  5. added
    A-dyn-traitArea: trait objects, vtable layout
    P-lowLow priority
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    A-dyn-compatibilityArea: Dyn compatibility (formerly: object safety)
    on Jul 21, 2025
  6. fmease commented on Aug 26, 2025

    @fmease
    Member

    (Before my PR, dyn !Trait was simply reinterpreted as dyn Trait dropping the ! which is silently wrong; now we actually trigger an assert which is good, it just means we need to properly reject them beforehand (since we don't support negative existential trait bounds))

  7. fmease commented on Dec 28, 2025

    @fmease
    Member

    People seem to be stumbling upon this organically (e.g., #150466); therefore dropping P-low

  8. matthiaskrgr commented on Jul 29, 2026

    @matthiaskrgr
    MemberAuthor

    The original example if fixed but we can still hit this via fn main() { | b : dyn ? Sized + !Send | {} } for example

  9. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    on Aug 16, 2026
  10. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-HIR-ty-loweringArea: HIR ty lowering (HIR → middle::ty IR)A-dyn-traitArea: trait objects, vtable layoutC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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