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

Inline const block is not always an expression #82750

Closed
DutchGhost opened this issue Mar 4, 2021 · 1 comment
Closed

Inline const block is not always an expression #82750

DutchGhost opened this issue Mar 4, 2021 · 1 comment
Labels
F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Mar 4, 2021

The following code:

#![feature(inline_const)]

fn main() {
    dbg!(const {});
}

fails to compile, producing this error message:

error: no rules expected the token `const`
 --> src/main.rs:4:10
  |
4 |     dbg!(const {});
  |          ^^^^^ no rules expected this token in macro call

However, if the entire const {} is placed in yet another {} block, it just works:

#![feature(inline_const)]

fn main() {
  dbg!({ const {} });
}
@JohnTitor JohnTitor added F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 4, 2021
@petrochenkov
Copy link
Contributor

Closing as a duplicate of #84155 (which is newer, but has some discussion).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) 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