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: trivial bounds : Failed to normalize Alias(Projection #125509

Closed
matthiaskrgr opened this issue May 24, 2024 · 1 comment · Fixed by #125513
Closed

ICE: trivial bounds : Failed to normalize Alias(Projection #125509

matthiaskrgr opened this issue May 24, 2024 · 1 comment · Fixed by #125513
Assignees
Labels
C-bug Category: This is a bug. F-trivial_bounds `#![feature(trivial_bounds)]` 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):

#![feature(trivial_bounds)]

trait Foo {
    type Assoc;
}

struct Bar;

pub struct Baz2(<Bar as Foo>::Assoc)
where
    Bar: Foo;

original:

#![feature(trivial_bounds)]

trait Foo {
    type Assoc;
}

struct Bar;

// This needs to be public
pub struct Baz2(<Bar as Foo>::Assoc)
where
    Bar: Foo;

Version information

rustc 1.80.0-nightly (9e297bf54 2024-05-24)
binary: rustc
commit-hash: 9e297bf54d31eb3b30067208ff9af4416945a2ed
commit-date: 2024-05-24
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Clink-dead-code=true --crate-type=lib

Program output

warning: trait `Foo` is more private than the item `Baz2`
 --> /tmp/icemaker_global_tempdir.4xrwmRtFbuqW/rustc_testrunner_tmpdir_reporting.93HtWgLolT6g/mvce.rs:9:1
  |
9 | pub struct Baz2(<Bar as Foo>::Assoc)
  | ^^^^^^^^^^^^^^^ struct `Baz2` is reachable at visibility `pub`
  |
note: but trait `Foo` is only usable at visibility `pub(crate)`
 --> /tmp/icemaker_global_tempdir.4xrwmRtFbuqW/rustc_testrunner_tmpdir_reporting.93HtWgLolT6g/mvce.rs:3:1
  |
3 | trait Foo {
  | ^^^^^^^^^
  = note: `#[warn(private_bounds)]` on by default

warning: type `Bar` is more private than the item `Baz2`
 --> /tmp/icemaker_global_tempdir.4xrwmRtFbuqW/rustc_testrunner_tmpdir_reporting.93HtWgLolT6g/mvce.rs:9:1
  |
9 | pub struct Baz2(<Bar as Foo>::Assoc)
  | ^^^^^^^^^^^^^^^ struct `Baz2` is reachable at visibility `pub`
  |
note: but type `Bar` is only usable at visibility `pub(crate)`
 --> /tmp/icemaker_global_tempdir.4xrwmRtFbuqW/rustc_testrunner_tmpdir_reporting.93HtWgLolT6g/mvce.rs:7:1
  |
7 | struct Bar;
  | ^^^^^^^^^^

warning: trait bound Bar: Foo does not depend on any type or lifetime parameters
  --> /tmp/icemaker_global_tempdir.4xrwmRtFbuqW/rustc_testrunner_tmpdir_reporting.93HtWgLolT6g/mvce.rs:11:10
   |
11 |     Bar: Foo;
   |          ^^^
   |
   = note: `#[warn(trivial_bounds)]` on by default

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:168:90: Failed to normalize Alias(Projection, AliasTy { args: [Bar], def_id: DefId(0:4 ~ mvce[4caf]::Foo::Assoc) }), maybe try to call `try_normalize_erasing_regions` instead

thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:168:90:
Box<dyn Any>
stack backtrace:
   0:     0x774fcbb53a15 - std::backtrace_rs::backtrace::libunwind::trace::h01616864447d7b30
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x774fcbb53a15 - std::backtrace_rs::backtrace::trace_unsynchronized::haf2505f1cce46362
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x774fcbb53a15 - std::sys_common::backtrace::_print_fmt::h194ca41cc100de5c
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x774fcbb53a15 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0cdf3b9de85168c4
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x774fcbba2aeb - core::fmt::rt::Argument::fmt::h4873b1048d9b82db
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/core/src/fmt/rt.rs:165:63
   5:     0x774fcbba2aeb - core::fmt::write::ha4c74c323a0d086c
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/core/src/fmt/mod.rs:1172:21
   6:     0x774fcbb4876f - std::io::Write::write_fmt::h294ecab9c2433d17
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/io/mod.rs:1835:15
   7:     0x774fcbb537ee - std::sys_common::backtrace::_print::h667dd447a835cd2b
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x774fcbb537ee - std::sys_common::backtrace::print::hd059cf329bebd7b7
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x774fcbb56219 - std::panicking::default_hook::{{closure}}::hcda624442cb26ab2
  10:     0x774fcbb55fba - std::panicking::default_hook::h1433a4b0280b10c1
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/panicking.rs:298:9
  11:     0x774fc85122d0 - std[4333a286c4712977]::panicking::update_hook::<alloc[a099cd952f2fafa7]::boxed::Box<rustc_driver_impl[112c1aa6bb2c54d8]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x774fcbb5694b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7bfd229c9579d378
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/alloc/src/boxed.rs:2077:9
  13:     0x774fcbb5694b - std::panicking::rust_panic_with_hook::hbbff73039be21b12
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/panicking.rs:799:13
  14:     0x774fc8542a54 - std[4333a286c4712977]::panicking::begin_panic::<rustc_errors[f387cce510502d5c]::ExplicitBug>::{closure#0}
  15:     0x774fc853f806 - std[4333a286c4712977]::sys_common::backtrace::__rust_end_short_backtrace::<std[4333a286c4712977]::panicking::begin_panic<rustc_errors[f387cce510502d5c]::ExplicitBug>::{closure#0}, !>
  16:     0x774fc853f4e6 - std[4333a286c4712977]::panicking::begin_panic::<rustc_errors[f387cce510502d5c]::ExplicitBug>
  17:     0x774fc854bff1 - <rustc_errors[f387cce510502d5c]::diagnostic::BugAbort as rustc_errors[f387cce510502d5c]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x774fc8a1b5bc - rustc_middle[26d2dffd48681262]::util::bug::opt_span_bug_fmt::<rustc_span[8c88142470715f14]::span_encoding::Span>::{closure#0}
  19:     0x774fc89ff8ca - rustc_middle[26d2dffd48681262]::ty::context::tls::with_opt::<rustc_middle[26d2dffd48681262]::util::bug::opt_span_bug_fmt<rustc_span[8c88142470715f14]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x774fc89ff74b - rustc_middle[26d2dffd48681262]::ty::context::tls::with_context_opt::<rustc_middle[26d2dffd48681262]::ty::context::tls::with_opt<rustc_middle[26d2dffd48681262]::util::bug::opt_span_bug_fmt<rustc_span[8c88142470715f14]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x774fc6d1de50 - rustc_middle[26d2dffd48681262]::util::bug::bug_fmt
  22:     0x774fc9bcb38e - <rustc_middle[26d2dffd48681262]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[b04476de6e20fddb]::fold::TypeFolder<rustc_middle[26d2dffd48681262]::ty::context::TyCtxt>>::fold_ty
  23:     0x774fc9d53ebf - <rustc_mir_dataflow[d4e4c9f9220e762e]::elaborate_drops::DropCtxt<rustc_mir_transform[3d3aa049f14cff04]::shim::DropShimElaborator>>::move_paths_for_fields
  24:     0x774fca1975e4 - <rustc_mir_dataflow[d4e4c9f9220e762e]::elaborate_drops::DropCtxt<rustc_mir_transform[3d3aa049f14cff04]::shim::DropShimElaborator>>::elaborate_drop
  25:     0x774fca1932f5 - rustc_mir_transform[3d3aa049f14cff04]::shim::make_shim
  26:     0x774fca192e2f - rustc_query_impl[3d654a2da272ff0b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3d654a2da272ff0b]::query_impl::mir_shims::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 8usize]>>
  27:     0x774fca192de3 - <rustc_query_impl[3d654a2da272ff0b]::query_impl::mir_shims::dynamic_query::{closure#2} as core[1cb6646e799f6e04]::ops::function::FnOnce<(rustc_middle[26d2dffd48681262]::ty::context::TyCtxt, rustc_middle[26d2dffd48681262]::ty::instance::InstanceDef)>>::call_once
  28:     0x774fc9b7d30f - rustc_query_system[a2213591f7f99b46]::query::plumbing::try_execute_query::<rustc_query_impl[3d654a2da272ff0b]::DynamicConfig<rustc_query_system[a2213591f7f99b46]::query::caches::DefaultCache<rustc_middle[26d2dffd48681262]::ty::instance::InstanceDef, rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3d654a2da272ff0b]::plumbing::QueryCtxt, false>
  29:     0x774fc9b7d079 - rustc_query_impl[3d654a2da272ff0b]::query_impl::mir_shims::get_query_non_incr::__rust_end_short_backtrace
  30:     0x774fc9c978a6 - <rustc_middle[26d2dffd48681262]::ty::context::TyCtxt>::instance_mir
  31:     0x774fca58939a - rustc_monomorphize[e95a442b79ec2197]::collector::collect_items_rec::{closure#0}
  32:     0x774fc994e8a4 - rustc_monomorphize[e95a442b79ec2197]::collector::collect_items_rec
  33:     0x774fc9baf855 - rustc_monomorphize[e95a442b79ec2197]::partitioning::collect_and_partition_mono_items
  34:     0x774fc9baeeac - rustc_query_impl[3d654a2da272ff0b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3d654a2da272ff0b]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 24usize]>>
  35:     0x774fc9baee91 - <rustc_query_impl[3d654a2da272ff0b]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[1cb6646e799f6e04]::ops::function::FnOnce<(rustc_middle[26d2dffd48681262]::ty::context::TyCtxt, ())>>::call_once
  36:     0x774fca5c9b48 - rustc_query_system[a2213591f7f99b46]::query::plumbing::try_execute_query::<rustc_query_impl[3d654a2da272ff0b]::DynamicConfig<rustc_query_system[a2213591f7f99b46]::query::caches::SingleCache<rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[3d654a2da272ff0b]::plumbing::QueryCtxt, false>
  37:     0x774fca5c9861 - rustc_query_impl[3d654a2da272ff0b]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  38:     0x774fca1b69d7 - rustc_codegen_ssa[75b07872eef639cb]::back::symbol_export::exported_symbols_provider_local
  39:     0x774fc999e4f3 - rustc_query_impl[3d654a2da272ff0b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3d654a2da272ff0b]::query_impl::exported_symbols::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 16usize]>>
  40:     0x774fc999e4c9 - <rustc_query_impl[3d654a2da272ff0b]::query_impl::exported_symbols::dynamic_query::{closure#2} as core[1cb6646e799f6e04]::ops::function::FnOnce<(rustc_middle[26d2dffd48681262]::ty::context::TyCtxt, rustc_span[8c88142470715f14]::def_id::CrateNum)>>::call_once
  41:     0x774fca3ef0a6 - rustc_query_system[a2213591f7f99b46]::query::plumbing::try_execute_query::<rustc_query_impl[3d654a2da272ff0b]::DynamicConfig<rustc_query_system[a2213591f7f99b46]::query::caches::VecCache<rustc_span[8c88142470715f14]::def_id::CrateNum, rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[3d654a2da272ff0b]::plumbing::QueryCtxt, false>
  42:     0x774fca3eecab - rustc_query_impl[3d654a2da272ff0b]::query_impl::exported_symbols::get_query_non_incr::__rust_end_short_backtrace
  43:     0x774fca3ee9ec - rustc_middle[26d2dffd48681262]::query::plumbing::query_get_at::<rustc_query_system[a2213591f7f99b46]::query::caches::VecCache<rustc_span[8c88142470715f14]::def_id::CrateNum, rustc_middle[26d2dffd48681262]::query::erase::Erased<[u8; 16usize]>>>
  44:     0x774fca84c772 - <rustc_metadata[c274c5c9a9e00f99]::rmeta::encoder::EncodeContext>::encode_crate_root
  45:     0x774fca83f858 - rustc_metadata[c274c5c9a9e00f99]::rmeta::encoder::encode_metadata
  46:     0x774fca635232 - rustc_metadata[c274c5c9a9e00f99]::fs::encode_and_write_metadata
  47:     0x774fca633cda - rustc_interface[9ff7c37c0a2ad37a]::passes::start_codegen
  48:     0x774fca63341c - <rustc_interface[9ff7c37c0a2ad37a]::queries::Queries>::codegen_and_build_linker
  49:     0x774fca3cf06e - rustc_interface[9ff7c37c0a2ad37a]::interface::run_compiler::<core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>, rustc_driver_impl[112c1aa6bb2c54d8]::run_compiler::{closure#0}>::{closure#1}
  50:     0x774fca3bab67 - std[4333a286c4712977]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9ff7c37c0a2ad37a]::util::run_in_thread_with_globals<rustc_interface[9ff7c37c0a2ad37a]::util::run_in_thread_pool_with_globals<rustc_interface[9ff7c37c0a2ad37a]::interface::run_compiler<core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>, rustc_driver_impl[112c1aa6bb2c54d8]::run_compiler::{closure#0}>::{closure#1}, core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>>::{closure#0}, core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>>
  51:     0x774fca3ba92a - <<std[4333a286c4712977]::thread::Builder>::spawn_unchecked_<rustc_interface[9ff7c37c0a2ad37a]::util::run_in_thread_with_globals<rustc_interface[9ff7c37c0a2ad37a]::util::run_in_thread_pool_with_globals<rustc_interface[9ff7c37c0a2ad37a]::interface::run_compiler<core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>, rustc_driver_impl[112c1aa6bb2c54d8]::run_compiler::{closure#0}>::{closure#1}, core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>>::{closure#0}, core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1cb6646e799f6e04]::result::Result<(), rustc_span[8c88142470715f14]::ErrorGuaranteed>>::{closure#2} as core[1cb6646e799f6e04]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:     0x774fcbb6072b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4e53d953a4689d25
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/alloc/src/boxed.rs:2063:9
  53:     0x774fcbb6072b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb1f69d21a251f1d9
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/alloc/src/boxed.rs:2063:9
  54:     0x774fcbb6072b - std::sys::pal::unix::thread::Thread::new::thread_start::h03f22bbd669825b9
                               at /rustc/9e297bf54d31eb3b30067208ff9af4416945a2ed/library/std/src/sys/pal/unix/thread.rs:108:17
  55:     0x774fcb8fe1cf - <unknown>
  56:     0x774fcb97f6ec - <unknown>
  57:                0x0 - <unknown>

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.80.0-nightly (9e297bf54 2024-05-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C link-dead-code=true --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_shims] generating MIR shim for `core::ptr::drop_in_place`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 3 warnings emitted


@rustbot label +F-trivial_bounds

@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 May 24, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-trivial_bounds `#![feature(trivial_bounds)]` labels May 24, 2024
@matthiaskrgr
Copy link
Member Author

cc @compiler-errors this is the one that still crashes from #125394

@compiler-errors compiler-errors self-assigned this May 24, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 24, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue May 25, 2024
…=jackh726

Don't eagerly monomorphize drop for types that are impossible to instantiate

Self-explanatory title I think

Fixes rust-lang#125509
workingjubilee added a commit to workingjubilee/rustc that referenced this issue May 25, 2024
…=jackh726

Don't eagerly monomorphize drop for types that are impossible to instantiate

Self-explanatory title I think

Fixes rust-lang#125509
@bors bors closed this as completed in 3fc8fe0 May 25, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 25, 2024
Rollup merge of rust-lang#125513 - compiler-errors:impossible-drop, r=jackh726

Don't eagerly monomorphize drop for types that are impossible to instantiate

Self-explanatory title I think

Fixes rust-lang#125509
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. F-trivial_bounds `#![feature(trivial_bounds)]` 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