[ICE]: Broken MIR in drop glue with specialization #107228
Closed
Description
This requires -Zvalidate-mir
Code
#![feature(specialization)]
pub(crate) trait SpecTrait {
type Assoc;
}
impl<C> SpecTrait for C {
default type Assoc = Vec<Self>;
}
pub(crate) struct AssocWrap<C: SpecTrait> {
_assoc: C::Assoc,
}
fn instantiate<C: SpecTrait>() -> AssocWrap<C> {
loop {}
}
pub fn trigger() {
instantiate::<()>();
}
Affected release channels
- Previous Stable
- Current Stable
- Current Beta
- Current Nightly
Rust Version
rustc 1.69.0-nightly (5e37043d6 2023-01-22)
binary: rustc
commit-hash: 5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d
commit-date: 2023-01-22
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
Current error output
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: broken MIR in DropGlue(DefId(2:2154 ~ core[df84]::ptr::drop_in_place), Some(AssocWrap<()>)) (before pass AddMovesForPackedDrops) at bb4[0]:
Field projection `(*_1).field[0]` specified type `std::vec::Vec<()>`, but actual type is `<() as SpecTrait>::Assoc`
Backtrace
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> aa.rs:1:12
|
1 | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: broken MIR in DropGlue(DefId(2:2154 ~ core[df84]::ptr::drop_in_place), Some(AssocWrap<()>)) (before pass AddMovesForPackedDrops) at bb4[0]:
Field projection `(*_1).field[0]` specified type `std::vec::Vec<()>`, but actual type is `<() as SpecTrait>::Assoc`
--> /home/nilsh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:490:1
|
490 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
2: <rustc_const_eval::transform::validate::TypeChecker>::fail::<alloc::string::String>
3: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_place
4: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_terminator
5: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
6: rustc_mir_transform::pass_manager::validate_body
7: rustc_mir_transform::pass_manager::run_passes_inner
8: rustc_mir_transform::shim::make_shim
9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_shims, rustc_query_impl::plumbing::QueryCtxt>
10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_shims
11: <rustc_middle::ty::context::TyCtxt>::instance_mir
12: rustc_monomorphize::collector::collect_neighbours
13: rustc_monomorphize::collector::collect_items_rec
14: rustc_monomorphize::collector::collect_items_rec
15: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
16: rustc_monomorphize::collector::collect_crate_mono_items
17: rustc_monomorphize::partitioning::collect_and_partition_mono_items
18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::collect_and_partition_mono_items, rustc_query_impl::plumbing::QueryCtxt>
19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
20: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::exported_symbols, rustc_query_impl::plumbing::QueryCtxt>
22: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::exported_symbols, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
23: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
24: rustc_metadata::rmeta::encoder::encode_metadata_impl
25: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
26: rustc_metadata::rmeta::encoder::encode_metadata
27: rustc_metadata::fs::encode_and_write_metadata
28: rustc_interface::passes::start_codegen
29: <rustc_interface::queries::Queries>::ongoing_codegen
30: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
31: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
32: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
33: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/alloc/src/boxed.rs:1988:9
35: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/alloc/src/boxed.rs:1988:9
36: std::sys::unix::thread::Thread::new::thread_start
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/std/src/sys/unix/thread.rs:108:17
37: start_thread
at ./nptl/./nptl/pthread_create.c:442:8
38: clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
error: internal compiler error: broken MIR in DropGlue(DefId(2:2154 ~ core[df84]::ptr::drop_in_place), Some(AssocWrap<()>)) (before pass AddMovesForPackedDrops) at bb5[0]:
Field projection `(*_1).field[0]` specified type `std::vec::Vec<()>`, but actual type is `<() as SpecTrait>::Assoc`
--> /home/nilsh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:490:1
|
490 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
2: <rustc_const_eval::transform::validate::TypeChecker>::fail::<alloc::string::String>
3: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_place
4: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_terminator
5: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
6: rustc_mir_transform::pass_manager::validate_body
7: rustc_mir_transform::pass_manager::run_passes_inner
8: rustc_mir_transform::shim::make_shim
9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_shims, rustc_query_impl::plumbing::QueryCtxt>
10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_shims
11: <rustc_middle::ty::context::TyCtxt>::instance_mir
12: rustc_monomorphize::collector::collect_neighbours
13: rustc_monomorphize::collector::collect_items_rec
14: rustc_monomorphize::collector::collect_items_rec
15: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
16: rustc_monomorphize::collector::collect_crate_mono_items
17: rustc_monomorphize::partitioning::collect_and_partition_mono_items
18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::collect_and_partition_mono_items, rustc_query_impl::plumbing::QueryCtxt>
19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
20: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::exported_symbols, rustc_query_impl::plumbing::QueryCtxt>
22: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::exported_symbols, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
23: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
24: rustc_metadata::rmeta::encoder::encode_metadata_impl
25: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
26: rustc_metadata::rmeta::encoder::encode_metadata
27: rustc_metadata::fs::encode_and_write_metadata
28: rustc_interface::passes::start_codegen
29: <rustc_interface::queries::Queries>::ongoing_codegen
30: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
31: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
32: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
33: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/alloc/src/boxed.rs:1988:9
35: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/alloc/src/boxed.rs:1988:9
36: std::sys::unix::thread::Thread::new::thread_start
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/std/src/sys/unix/thread.rs:108:17
37: start_thread
at ./nptl/./nptl/pthread_create.c:442:8
38: clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
......
error: internal compiler error: broken MIR in DropGlue(DefId(2:2154 ~ core[df84]::ptr::drop_in_place), Some(AssocWrap<()>)) (after pass AbortUnwindingCalls) at bb0[0]:
Field projection `(*_1).field[0]` specified type `std::vec::Vec<()>`, but actual type is `<() as SpecTrait>::Assoc`
--> /home/nilsh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:490:1
|
490 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
2: <rustc_const_eval::transform::validate::TypeChecker>::fail::<alloc::string::String>
3: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_place
4: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_terminator
5: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
6: rustc_mir_transform::pass_manager::validate_body
7: rustc_mir_transform::pass_manager::run_passes_inner
8: rustc_mir_transform::shim::make_shim
9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_shims, rustc_query_impl::plumbing::QueryCtxt>
10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_shims
11: <rustc_middle::ty::context::TyCtxt>::instance_mir
12: rustc_monomorphize::collector::collect_neighbours
13: rustc_monomorphize::collector::collect_items_rec
14: rustc_monomorphize::collector::collect_items_rec
15: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
16: rustc_monomorphize::collector::collect_crate_mono_items
17: rustc_monomorphize::partitioning::collect_and_partition_mono_items
18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::collect_and_partition_mono_items, rustc_query_impl::plumbing::QueryCtxt>
19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
20: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::exported_symbols, rustc_query_impl::plumbing::QueryCtxt>
22: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::exported_symbols, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
23: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
24: rustc_metadata::rmeta::encoder::encode_metadata_impl
25: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
26: rustc_metadata::rmeta::encoder::encode_metadata
27: rustc_metadata::fs::encode_and_write_metadata
28: rustc_interface::passes::start_codegen
29: <rustc_interface::queries::Queries>::ongoing_codegen
30: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
31: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
32: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
33: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/alloc/src/boxed.rs:1988:9
35: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/alloc/src/boxed.rs:1988:9
36: std::sys::unix::thread::Thread::new::thread_start
at /rustc/5e37043d63bfe2f3be8fa5a05b07d6c0dad5775d/library/std/src/sys/unix/thread.rs:108:17
37: start_thread
at ./nptl/./nptl/pthread_create.c:442:8
38: clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
note: 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.69.0-nightly (5e37043d6 2023-01-22) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -Z validate-mir
query stack during panic:
end of query stack
Anything else?
This requires -Zvalidate-mir
!
Minimized out of #107051
Metadata
Assignees
Labels
Area: Trait impl specializationCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.`#![feature(specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.