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 while inferring the type of a static LazyLock #131912

Closed
V-Fries opened this issue Oct 19, 2024 · 1 comment
Closed

ICE while inferring the type of a static LazyLock #131912

V-Fries opened this issue Oct 19, 2024 · 1 comment
Labels
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.

Comments

@V-Fries
Copy link

V-Fries commented Oct 19, 2024

Code

use std::sync::LazyLock;

static TEST = LazyLock::new(|| 42);

fn main() {}

Meta

rustc --version --verbose:

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-apple-darwin
release: 1.81.0
LLVM version: 18.1.7

The bug could not be reproduced in the nightly build

Error output

error: missing type for `static` item
 --> src/main.rs:3:11
  |
3 | static FOO = LazyLock::new(|| 42);
  |           ^
  |
note: however, the inferred type `LazyLock<i32, {closure@main.rs:3:28}>` cannot be named
 --> src/main.rs:3:14
  |
3 | static FOO = LazyLock::new(|| 42);
  |              ^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/validity.rs:741:21:
assertion `left == right` failed
  left: Mut
 right: Not
Backtrace

   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustc_ast_ir::Mutability, rustc_ast_ir::Mutability>
   4: rustc_const_eval::interpret::validity::mutability::<rustc_const_eval::const_eval::machine::CompileTimeMachine>
   5: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_value
   6: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_field
   7: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_value
   8: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_field
   9: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_value
  10: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_field
  11: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_value
  12: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_field
  13: <rustc_const_eval::interpret::validity::ValidityVisitor<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<rustc_const_eval::const_eva
l::machine::CompileTimeMachine>>::visit_value
  14: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::validate_operand_internal
  15: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
      [... omitted 2 frames ...]
  16: rustc_hir_analysis::check_crate
  17: rustc_interface::passes::run_required_analyses
  18: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  19: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closu
re#1}::{closure#5}>
  20: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}

@V-Fries V-Fries 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 Oct 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 19, 2024
@workingjubilee
Copy link
Member

It does not reproduce on nightly because it is fixed.

Duplicate of #124164

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2024
@workingjubilee workingjubilee removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 19, 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) ❄️ 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

3 participants