Skip to content

Introduction of frontmatter was a theoretical breaking change (via Literal::from_str) #146132

@fmease

Description

@fmease

See also #145520 and #145945.
This is basically (the fixed) #145520 but with TokenStream replaced with Literal inside .parse().

Reproducer

  • rustc a.rs --crate-type proc-macro --extern proc_macro where a.rs:
    #[proc_macro]
    pub fn ck(x: proc_macro::TokenStream) -> proc_macro::TokenStream {
        _ = "---".parse::<proc_macro::Literal>();
        x
    }
  • rustc b.rs --crate-type lib --extern a -L. where b.rs:
    a::ck!();

In 1.87 and earlier, this used to compile just fine. However, since 1.88 (more precisely since PR #140035) this fails with:

error: invalid infostring for frontmatter
 --> <proc-macro source code>:1:4
  |
1 | ---
  |    ^
  |
  = note: frontmatter infostrings must be a single identifier immediately following the opening

error: unclosed frontmatter
 --> <proc-macro source code>:1:1
  |
1 | ---
  | ^^^
  |
note: frontmatter opening here was not closed
 --> <proc-macro source code>:1:1
  |
1 | ---
  | ^^^

error[E0658]: frontmatters are experimental
 --> <proc-macro source code>:1:1
  |
1 | ---
  | ^^^
  |
  = note: see issue #136889 <https://github.com/rust-lang/rust/issues/136889> for more information
  = help: add `#![feature(frontmatter)]` to the crate attributes to enable
  = note: this compiler was built on 2025-09-02; consider upgrading it if it is out of date

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.

Metadata

Metadata

Assignees

Labels

A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.F-frontmatter`#![feature(frontmatter)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions