Skip to content

Inline const block is not always an expression #82750

Closed
@DutchGhost

Description

@DutchGhost

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 {} });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions