Skip to content

Tracking Issue for frontmatter #136889

Open
Open
@epage

Description

@epage

This is a tracking issue for the RFC "frontmatter" (rust-lang/rfcs#3503).
The feature gate for the issue is #![feature(frontmatter)].

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps

Test coverage prior to stabilization

In the following, the RFC text in its accepted form will be referred to as the "accepted text".

  • (Before stabilization) we should add a run-make test that exercises how cargo and rustc works together w.r.t. frontmatter, depending on what the final cooperation scheme we end up using.
  • (Before stabilization) we should add a positive smoke test to check that rustfix is able to account for frontmatters (or properly ignore), i.e. //@ run-rustfix.

Unresolved Questions

  • What level of quality of error messages is a blocker for stabilization? See also Add unstable frontmatter support #137193 (comment)
    • In Implement RFC 3503: frontmatters #140035, the initial (compiler) impl already tries to provide diagnostics for the most common erroneous usages.
    • However, it might be worth refining how the diagnostics responsibility of reporting invalid frontmatters get shared between $tools <-> rustc.
  • How does frontmatter interact with -Zunpretty? See discussions in Add unstable frontmatter support #137193 (comment).
  • How will various tools (rust-analyzer, rustfmt, cargo, clippy) handle frontmatter (and interop w/ rustc)? Will parsing support (or ability to ignore frontmatter) be a stabilization blocker (re. toolchain UX)? For all of them, for a subset of the tools?
  • Should frontmatter be outright banned in doctests? Consider these examples: Implement RFC 3503: frontmatters #140035 (comment).
  • (Needs explicit design decision prior to stabilization) Should whitespace be permitted between the starting dashes and the infostring? E.g. would --- cargo be accepted? In Implement RFC 3503: frontmatters #140035 and the accepted text, whitespace between starting dashes and the infostring is permitted.

Implementation history

Initial implementations

(Significant) changes since the RFC was accepted

Frontmatter opener vs infostring starting with - character grammar ambiguity

The accepted text has a grammar ambiguity in the case where the infostring starts with a -.

  • The same - character is used to delimit the frontmatter "opener" ---.
  • The opener can have more than 3 - characters to support escaping nesting of ---s within the frontmatter.
  • However, infostrings described in the accepted text can also begin with -, making it ambiguous as to whether it's a 3-- opener + --starting infostring, or if it is a 4-- opener + infostring.

Remedy: we can require the infostring to begin with Unicode XID_Start, then permit subsequently characters in the set { XID_Continue, . }. I.e. (illustrative)

- infostring = term *
- term       = { all characters - ( whitespace | ',' ) }
+ infostring = XID_Start , { (XID_Continue | '.') } * ;

See discussions at #140035 (comment).

Illustrative grammar

#140035 (comment) (with start and end dashes >3 - characters and must match in - count):

frontmatter_start = dashes , { whitespace } * , infostring , { whitespace } * , '\n' ;
frontmatter_end = dashes , { whitespace } * , '\n' ;
infostring = XID_Start , { (XID_Continue | '.') } * ;
dashes = "---" , { '-' } * ;

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-frontmatter`#![feature(frontmatter)]`S-tracking-unimplementedStatus: The feature has not been implemented.T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc 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