ICE when reifying function pointers to copy / copy_nonoverlapping using an if #84297
Closed
Description
opened on Apr 18, 2021
This happens on nightly only, I included a bisection at the bottom. (But it doesn't seem as if the bisected commit is the direct cause of this).
It only ICE's if you assign the result to a variable, assigning it to _
or not at all doesn't ICE.
The bisection for using core::intrinsics::copy
is the same.
Code
fn main() {
let _unused = if true {
core::ptr::copy::<i32>
} else {
core::ptr::copy_nonoverlapping::<i32>
};
}
Meta
rustc --version --verbose
:
rustc 1.53.0-nightly (b0c818c5e 2021-04-16)
binary: rustc
commit-hash: b0c818c5e0fa37251d9fda2f656bf1041a2e1e1d
commit-date: 2021-04-16
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
Error output
error: internal compiler error: compiler/rustc_mir/src/monomorphize/collector.rs:809:17: Instance { def: Intrinsic(DefId(2:1659 ~ core[ec89]::intrinsics::#1::copy)), substs: [i32] } being reified
thread 'rustc' panicked at 'Box<Any>', /rustc/b0c818c5e0fa37251d9fda2f656bf1041a2e1e1d/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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.53.0-nightly (b0c818c5e 2021-04-16) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error
error: could not compile `scratch`
To learn more, run the command again with --verbose.
Backtrace
Compiling scratch v0.1.0 (/tmp/scratchl90UMMXXQ)
error: internal compiler error: compiler/rustc_mir/src/monomorphize/collector.rs:809:17: Instance { def: Intrinsic(DefId(2:1659 ~ core[ec89]::intrinsics::#1::copy)), substs: [i32] } being reified
thread 'rustc' panicked at 'Box<Any>', /rustc/b0c818c5e0fa37251d9fda2f656bf1041a2e1e1d/library/std/src/panic.rs:59:5
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::bug
3: rustc_errors::Handler::bug
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_mir::monomorphize::collector::visit_instance_use
8: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_rvalue
9: rustc_mir::monomorphize::collector::collect_neighbours
10: rustc_mir::monomorphize::collector::collect_items_rec
11: rustc_session::utils::<impl rustc_session::session::Session>::time
12: rustc_mir::monomorphize::collector::collect_crate_mono_items
13: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
14: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::collect_and_partition_mono_items>::compute
15: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
17: rustc_data_structures::stack::ensure_sufficient_stack
18: rustc_query_system::query::plumbing::force_query_with_job
19: rustc_query_system::query::plumbing::get_query_impl
20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
21: rustc_codegen_ssa::base::codegen_crate
22: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
23: rustc_interface::passes::QueryContext::enter
24: rustc_interface::queries::Queries::ongoing_codegen
25: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
26: rustc_span::with_source_map
27: rustc_interface::interface::create_compiler_and_run
28: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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.53.0-nightly (b0c818c5e 2021-04-16) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error
error: could not compile `scratch`
To learn more, run the command again with --verbose.
Bisection
searched nightlies: from nightly-2021-01-01 to nightly-2021-04-18
regressed nightly: nightly-2021-02-14
searched commits: from 3f5aee2 to 8e54a21
regressed commit: 8e54a21
bisected with cargo-bisect-rustc v0.6.0
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --test-dir=. --start=2021-01-01 --end=2021-04-18 --preserve
Activity