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

Wrong error when trying to write to static in a static initializer #51251

Closed
oli-obk opened this issue May 31, 2018 · 0 comments · Fixed by #56070
Closed

Wrong error when trying to write to static in a static initializer #51251

oli-obk opened this issue May 31, 2018 · 0 comments · Fixed by #56070
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented May 31, 2018

http://play.rust-lang.org/?gist=d719594f15f35f8be13987e2f722d1ab&version=nightly&mode=debug

#![feature(const_let)]

static mut FOO: usize = unsafe {
    FOO = 42;
    5
};

fn main() {
}

results in

error[E0658]: statements in statics are unstable (see issue #48821)
 --> src/main.rs:4:5
  |
4 |     FOO = 42;
  |     ^^^^^^^^
  |
  = help: add #![feature(const_let)] to the crate attributes to enable

even though the feature gate is active (it should still error, but with a more targeted error message)

@oli-obk oli-obk added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. A-const-eval Area: Constant evaluation (MIR interpretation) labels May 31, 2018
bors added a commit that referenced this issue Nov 26, 2018
Allow assignments in const contexts

fixes #54098
fixes #51251
fixes #52613
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) A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant