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: type mismatch when copying! with no feature provided #124552

Open
cushionbadak opened this issue Apr 30, 2024 · 1 comment
Open

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

cushionbadak opened this issue Apr 30, 2024 · 1 comment
Labels
A-const-eval Area: constant evaluation (mir interpretation) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

cushionbadak commented Apr 30, 2024

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

@cushionbadak cushionbadak added C-bug Category: This is a bug. 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. labels Apr 30, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 30, 2024
@cushionbadak
Copy link
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 

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label May 9, 2024
@jieyouxu jieyouxu added A-const-eval Area: constant evaluation (mir interpretation) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: constant evaluation (mir interpretation) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants