Skip to content

ICE: type mismatch when copying! with no feature provided #124552

Closed
@cushionbadak

Description

@cushionbadak

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

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 30, 2024
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 30, 2024
cushionbadak

cushionbadak commented on Apr 30, 2024

@cushionbadak
Author

bisects to #121087

searched nightlies: from nightly-2024-01-01 to nightly-2024-04-30
regressed nightly: nightly-2024-02-21
searched commit range: 3246e79...bb59453
regressed commit: cce6a6e

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-apple-darwin
Reproduce with:

cargo bisect-rustc --script=rustc --start=2024-01-01 --end=2024-04-30 --preserve --regress=ice -- r_7A4EF4620B2BDD7720B5AEE6CE4584307D5131538726D4919292E63C73428A66.rs 
added
S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
on May 9, 2024
added
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on May 13, 2024
oli-obk

oli-obk commented on May 22, 2024

@oli-obk
Contributor

The following already reproduces on 1.77 stable

struct B;

struct Foo {
    b: u32,
    b: B,
}

const BAR: Foo = Foo { b: B };

const _:[();{
BAR;
    0
}] = [];

fn main() {}
added 2 commits that reference this issue on Jun 5, 2024

Rollup merge of rust-lang#126045 - olafes:master, r=compiler-errors

ec6a80f

Rollup merge of rust-lang#126045 - olafes:master, r=compiler-errors

3121a5c
added a commit that references this issue on Jun 6, 2024
5e8707b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-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

      Participants

      @oli-obk@matthiaskrgr@cushionbadak@jieyouxu@rustbot

      Issue actions

        ICE: `type mismatch when copying!` with no feature provided · Issue #124552 · rust-lang/rust