Skip to content

ICE: dyn !Sized #144241

@matthiaskrgr

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`.

Metadata

Metadata

Assignees

Labels

A-dyn-traitArea: trait objects, vtable layoutC-bugCategory: This is a bug.F-negative_bounds`#![feature(negative_bounds)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-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