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 with const let #52613

Closed
rizakrko opened this issue Jul 22, 2018 · 0 comments · Fixed by #56070
Closed

Wrong error with const let #52613

rizakrko opened this issue Jul 22, 2018 · 0 comments · Fixed by #56070
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@rizakrko
Copy link
Contributor

I tried this code:

#![feature(const_fn)]
#![feature(const_let)]
struct S {
    state: u32,
}

impl S {
    const fn foo(&mut self, x: u32) {
        self.state = x;
    }
}

fn main() {}

And got

error[E0658]: statements in constant functions are unstable (see issue #48821)
 --> src/main.rs:9:9
  |
9 |         self.state = x;
  |         ^^^^^^^^^^^^^^
  |
  = help: add #![feature(const_let)] to the crate attributes to enable

Similar to #51251

Meta

rustc --version --verbose:

rustc 1.29.0-nightly (874dec25e 2018-07-21)
binary: rustc
commit-hash: 874dec25ed4c08d36f17d396b6872ca50313fc8e
commit-date: 2018-07-21
host: x86_64-unknown-linux-gnu
release: 1.29.0-nightly
LLVM version: 7.0

@oli-obk oli-obk added A-diagnostics Area: Messages for errors, warnings, and lints A-const-fn C-bug Category: This is a bug. A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) labels Jul 22, 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, covers all const contexts (static, const fn, ...) 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.

2 participants