-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Silent failure of std::sync::Once when in const variable #132028
Copy link
Copy link
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code playground link:
The problem is that my Once is in a
constand not astatic. However, I would expect a compile error or a runtime error instead of broken behavior here. The same behavior is exhibited instd::sync::LazyLockand probablystd::sync::OnceLock, due to using a Once internally.Thanks for considering this!
Meta
Checked on 1.82.0 and on nightly.