Introduction of frontmatter was a theoretical breaking change (via Literal::from_str) (original) (raw)

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

Reproducer

#[proc_macro]
pub fn ck(x: proc_macro::TokenStream) -> proc_macro::TokenStream {
_ = "---".parse::<proc_macro::Literal>();
x
}

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`.