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: Got a scalar pair where a scalar was expected #127299

Open
Naserume opened this issue Jul 4, 2024 · 1 comment
Open

ICE: Got a scalar pair where a scalar was expected #127299

Naserume opened this issue Jul 4, 2024 · 1 comment
Assignees
Labels
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

@Naserume
Copy link

Naserume commented Jul 4, 2024

Code

trait Qux {
    fn bar() -> i32;
}

pub struct Lint {
    pub desc: &'static Qux,
}

static FOO: &Lint = &Lint { desc: "desc" };

fn main() {}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (6292b2af6 2024-07-02)
binary: rustc
commit-hash: 6292b2af620dbd771ebb687c3a93c69ba8f97268
commit-date: 2024-07-02
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

warning: trait objects without an explicit `dyn` are deprecated
  --> ./7F1DF.rs:13:24
   |
13 |     pub desc: &'static Qux,
   |                        ^^^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
   = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
   |
13 |     pub desc: &'static dyn Qux,
   |                        +++

error[E0038]: the trait `Qux` cannot be made into an object
  --> ./7F1DF.rs:13:24
   |
13 |     pub desc: &'static Qux,
   |                        ^^^ `Qux` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> ./7F1DF.rs:2:8
   |
1  | trait Qux {
   |       --- this trait cannot be made into an object...
2  |     fn bar() -> i32;
   |        ^^^ ...because associated function `bar` has no `self` parameter
help: consider turning `bar` into a method by giving it a `&self` argument
   |
2  |     fn bar(&self) -> i32;
   |            +++++
help: alternatively, consider constraining `bar` so it does not apply to trait objects
   |
2  |     fn bar() -> i32 where Self: Sized;
   |                     +++++++++++++++++

error[E0277]: `(dyn Qux + 'static)` cannot be shared between threads safely
  --> ./7F1DF.rs:16:13
   |
16 | static FOO: &Lint = &Lint { desc: "desc" };
   |             ^^^^^ `(dyn Qux + 'static)` cannot be shared between threads safely
   |
   = help: within `&'static Lint`, the trait `Sync` is not implemented for `(dyn Qux + 'static)`, which is required by `&'static Lint: Sync`
   = note: required because it appears within the type `&'static (dyn Qux + 'static)`
note: required because it appears within the type `Lint`
  --> ./7F1DF.rs:12:12
   |
12 | pub struct Lint {
   |            ^^^^
   = note: required because it appears within the type `&'static Lint`
   = note: shared static variables must have a type that implements `Sync`

error[E0038]: the trait `Qux` cannot be made into an object
  --> ./7F1DF.rs:16:35
   |
16 | static FOO: &Lint = &Lint { desc: "desc" };
   |                                   ^^^^^^ `Qux` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> ./7F1DF.rs:2:8
   |
1  | trait Qux {
   |       --- this trait cannot be made into an object...
2  |     fn bar() -> i32;
   |        ^^^ ...because associated function `bar` has no `self` parameter
   = note: required for the cast from `&'static str` to `&'static (dyn Qux + 'static)`
help: consider turning `bar` into a method by giving it a `&self` argument
   |
2  |     fn bar(&self) -> i32;
   |            +++++
help: alternatively, consider constraining `bar` so it does not apply to trait objects
   |
2  |     fn bar() -> i32 where Self: Sized;
   |                     +++++++++++++++++

Backtrace

error: internal compiler error: compiler/rustc_const_eval/src/interpret/operand.rs:85:42: Got a scalar pair where a scalar was expected

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operand.rs:85:42:
Box<dyn Any>
stack backtrace:
   0:        0x1029f2d93 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9393e218f71d31cf
   1:        0x102a3e17b - core::fmt::write::h1271a75a7bae980c
   2:        0x1029e8c3e - std::io::Write::write_fmt::h8270e961acbabe61
   3:        0x1029f2b81 - std::sys::backtrace::print::h04e4916ebe343f6e
   4:        0x1029f5959 - std::panicking::default_hook::{{closure}}::hc9df26d29e0f9e5a
   5:        0x1029f56da - std::panicking::default_hook::h1026261fa8b9d0a8
   6:        0x10bcdd0ac - std[26270defc80edaa9]::panicking::update_hook::<alloc[98df03226deedbda]::boxed::Box<rustc_driver_impl[708b2ec565622c48]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x1029f6699 - std::panicking::rust_panic_with_hook::hf72d729757d375cc
   8:        0x10bd51347 - std[26270defc80edaa9]::panicking::begin_panic::<rustc_errors[d689bc684dcf46ea]::ExplicitBug>::{closure#0}
   9:        0x10bd3d189 - std[26270defc80edaa9]::sys::backtrace::__rust_end_short_backtrace::<std[26270defc80edaa9]::panicking::begin_panic<rustc_errors[d689bc684dcf46ea]::ExplicitBug>::{closure#0}, !>
  10:        0x11076e199 - std[26270defc80edaa9]::panicking::begin_panic::<rustc_errors[d689bc684dcf46ea]::ExplicitBug>
  11:        0x10bd63486 - <rustc_errors[d689bc684dcf46ea]::diagnostic::BugAbort as rustc_errors[d689bc684dcf46ea]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x10ca066a5 - rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt::<rustc_span[2de937bbddea0bd8]::span_encoding::Span>::{closure#0}
  13:        0x10c9bd967 - rustc_middle[8094f41c293b336b]::ty::context::tls::with_opt::<rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt<rustc_span[2de937bbddea0bd8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x10c9bd405 - rustc_middle[8094f41c293b336b]::ty::context::tls::with_context_opt::<rustc_middle[8094f41c293b336b]::ty::context::tls::with_opt<rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt<rustc_span[2de937bbddea0bd8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x1108311cb - rustc_middle[8094f41c293b336b]::util::bug::bug_fmt
  16:        0x10bc36d21 - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::read_scalar::<rustc_const_eval[396cbee6e07433a6]::interpret::operand::OpTy>
  17:        0x10bc36d50 - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::read_pointer::<rustc_const_eval[396cbee6e07433a6]::interpret::operand::OpTy>
  18:        0x10bc1b9de - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::unsize_into_ptr
  19:        0x10bc4612c - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::statement
  20:        0x10bc62ed8 - rustc_const_eval[396cbee6e07433a6]::const_eval::eval_queries::eval_to_allocation_raw_provider
  21:        0x10d39aaec - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>
  22:        0x10d34fbae - <rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>)>>::call_once
  23:        0x10d1b3c0d - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  24:        0x10d3c59dc - rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  25:        0x10bb93752 - rustc_middle[8094f41c293b336b]::query::plumbing::query_get_at::<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>>
  26:        0x10bc5f700 - rustc_const_eval[396cbee6e07433a6]::const_eval::eval_queries::eval_to_const_value_raw_provider
  27:        0x10d39b48c - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>
  28:        0x10d35501e - <rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>)>>::call_once
  29:        0x10d1b3c0d - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  30:        0x10d3c628c - rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  31:        0x10ca1df16 - rustc_middle[8094f41c293b336b]::query::plumbing::query_get_at::<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>>
  32:        0x10ca220ce - <rustc_middle[8094f41c293b336b]::ty::context::TyCtxt>::const_eval_global_id
  33:        0x10ca219ed - <rustc_middle[8094f41c293b336b]::ty::context::TyCtxt>::const_eval_resolve
  34:        0x10bc389bb - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::eval_operand
  35:        0x10bc451b6 - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::statement
  36:        0x10bc6189b - rustc_const_eval[396cbee6e07433a6]::const_eval::eval_queries::eval_static_initializer_provider
  37:        0x10d39b412 - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 16usize]>>
  38:        0x10d35459e - <rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_static_initializer::dynamic_query::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_span[2de937bbddea0bd8]::def_id::DefId)>>::call_once
  39:        0x10d158319 - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefIdCache<rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  40:        0x10d3c5ded - rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_static_initializer::get_query_non_incr::__rust_end_short_backtrace
  41:        0x10bf56cbb - <rustc_middle[8094f41c293b336b]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[af0a509199b1bc4b]::check_crate::{closure#3}>::{closure#0}
  42:        0x10c0ac0ec - rustc_hir_analysis[af0a509199b1bc4b]::check_crate
  43:        0x10c653df7 - rustc_interface[eab3c32d3b591e25]::passes::run_required_analyses
  44:        0x10c6563a0 - rustc_interface[eab3c32d3b591e25]::passes::analysis
  45:        0x10d39d4ec - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 1usize]>>
  46:        0x10d17bfbe - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::SingleCache<rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  47:        0x10d3a7a47 - rustc_query_impl[36fa5edae9172c7f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  48:        0x10bc86857 - <rustc_interface[eab3c32d3b591e25]::queries::QueryResult<&rustc_middle[8094f41c293b336b]::ty::context::GlobalCtxt>>::enter::<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  49:        0x10bce4465 - rustc_interface[eab3c32d3b591e25]::interface::run_compiler::<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}
  50:        0x10bccaee1 - std[26270defc80edaa9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_with_globals<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_pool_with_globals<rustc_interface[eab3c32d3b591e25]::interface::run_compiler<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>
  51:        0x10bceaff6 - <<std[26270defc80edaa9]::thread::Builder>::spawn_unchecked_<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_with_globals<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_pool_with_globals<rustc_interface[eab3c32d3b591e25]::interface::run_compiler<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:        0x1029ff83b - std::sys::pal::unix::thread::Thread::new::thread_start::hfcd29f6cc9954faa
  53:     0x7ff801f5318b - __pthread_start

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/240701-nightly/rustc-ice-2024-07-04T05_30_36-80768.txt` to your bug report

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `FOO::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `FOO::promoted[0]`
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.

Note

Ice location

#[inline]
#[cfg_attr(debug_assertions, track_caller)] // only in debug builds due to perf (see #98980)
pub fn to_scalar(self) -> Scalar<Prov> {
match self {
Immediate::Scalar(val) => val,
Immediate::ScalarPair(..) => bug!("Got a scalar pair where a scalar was expected"),
Immediate::Uninit => bug!("Got uninit where a scalar was expected"),
}
}

@Naserume Naserume 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 Jul 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 4, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 5, 2024
@GrigorenkoPV
Copy link
Contributor

searched nightlies: from nightly-2023-04-15 to nightly-2024-07-02
regressed nightly: nightly-2024-07-02
searched commit range: 6868c83...cf2df68
regressed commit: 7b21c18 (#126996, cc @oli-obk)

@oli-obk oli-obk self-assigned this Jul 6, 2024
@oli-obk oli-obk removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Status: Todo
Development

No branches or pull requests

5 participants