Closed
Description
Code
(reduced)
struct B;
struct Foo {
b: u32,
b: B,
}
static BAR: Foo = Foo { b: B };
fn main() {}
Original Code
// Verifies that static items can't be moved
struct B;
struct Foo {
pub(crate) b: u32,
b: B,
}
static BAR: Foo = Foo { , b: B };
fn test(f: Foo) {
let _val: &'static _ = &(i32::MIN/(0-1));
}
fn main() {
test(BAR); //~ ERROR cannot move out of static item
}
Meta
rustc --version --verbose
:
rustc 1.79.0-nightly (0ad927c0c 2024-03-21)
binary: rustc
commit-hash: 0ad927c0c07b65fc0dae37105e09c877c87c296a
commit-date: 2024-03-21
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2
Command
rustc
Error output
error[E0124]: field `b` is already declared
--> r_7A4EF4620B2BDD7720B5AEE6CE4584307D5131538726D4919292E63C73428A66.rs:5:5
|
4 | b: u32,
| ------ `b` first declared here
5 | b: B,
| ^^^^ field already declared
error: internal compiler error: compiler/rustc_const_eval/src/interpret/place.rs:849:13: type mismatch when copying!
src: B,
dest: u32
--> r_7A4EF4620B2BDD7720B5AEE6CE4584307D5131538726D4919292E63C73428A66.rs:8:19
|
8 | static BAR: Foo = Foo { b: B };
| ^^^^^^^^^^^^
Backtrace
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/place.rs:849:13:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: <rustc_errors::DiagCtxt>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
7: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeInterpreter>>::copy_op_no_validate::<rustc_const_eval::interpret::operand::OpTy, rustc_const_eval::interpret::place::PlaceTy>
8: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeInterpreter>>::statement
9: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
10: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
11: rustc_hir_analysis::check_crate
12: rustc_interface::passes::analysis
[... omitted 1 frame ...]
13: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
14: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: it seems that this compiler `1.79.0-nightly (0ad927c0c 2024-03-21)` is outdated, a newer nightly should have been released in the mean time
|
= note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
= note: if the problem still persists, 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 attach the file at `/Users/jb/Desktop/tmp/0428_files/rustc-ice-2024-04-30T08_38_48-56156.txt` to your bug report
query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `BAR`
#1 [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 E0124`.
Note
- ice:
type mismatch when copying
#120016 has the same ICE location, but this one doesn't require any feature to make ICE. - ICE-loc:
compiler/rustc_const_eval/src/interpret/place.rs:849:13
rust/compiler/rustc_const_eval/src/interpret/place.rs
Lines 848 to 855 in 0ad927c
- Original ICE-triggering code is mutated from test-file
tests/ui/static/static-items-cant-move.rs
rust/tests/ui/static/static-items-cant-move.rs
Lines 5 to 10 in 0ad927c
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.