Skip to content

Introduction of frontmatter was a theoretical breaking change (via TokenStream::from_str) #145520

@fmease

Description

@fmease

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::TokenStream>();
        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
 --> b.rs:1:1
  |
1 | a::ck!();
  | ^^^^^^^^
  |
  = note: frontmatter infostrings must be a single identifier immediately following the opening
  = note: this error originates in the macro `a::ck` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unclosed frontmatter
 --> b.rs:1:1
  |
1 | a::ck!();
  | ^^^^^^^^
  |
note: frontmatter opening here was not closed
 --> b.rs:1:1
  |
1 | a::ck!();
  | ^^^^^^^^
  = note: this error originates in the macro `a::ck` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: frontmatters are experimental
 --> b.rs:1:1
  |
1 | a::ck!();
  | ^^^^^^^^
  |
  = note: see issue #136889 <https://github.com/rust-lang/rust/issues/136889> for more information
  = note: this error originates in the macro `a::ck` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.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