Skip to content

Commit bf5e8bf

Browse files
committed
Stabilize Frontmatter
1 parent 6906167 commit bf5e8bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+91
-223
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
524524
gate_all!(contracts_internals, "contract internal machinery is for internal use only");
525525
gate_all!(where_clause_attrs, "attributes in `where` clause are unstable");
526526
gate_all!(super_let, "`super let` is experimental");
527-
gate_all!(frontmatter, "frontmatters are experimental");
528527
gate_all!(coroutines, "coroutine syntax is experimental");
529528

530529
if !visitor.features.never_patterns() {

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ declare_features! (
223223
(accepted, fn_must_use, "1.27.0", Some(43302)),
224224
/// Allows capturing variables in scope using format_args!
225225
(accepted, format_args_capture, "1.58.0", Some(67984)),
226+
/// Frontmatter `---` blocks for use by external tools.
227+
(accepted, frontmatter, "CURRENT_RUSTC_VERSION", Some(136889)),
226228
/// Infer generic args for both consts and types.
227229
(accepted, generic_arg_infer, "1.89.0", Some(85077)),
228230
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,6 @@ declare_features! (
518518
(incomplete, fn_delegation, "1.76.0", Some(118212)),
519519
/// Allows impls for the Freeze trait.
520520
(internal, freeze_impls, "1.78.0", Some(121675)),
521-
/// Frontmatter `---` blocks for use by external tools.
522-
(unstable, frontmatter, "1.88.0", Some(136889)),
523521
/// Allows defining gen blocks and `gen fn`.
524522
(unstable, gen_blocks, "1.75.0", Some(117078)),
525523
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_session::lint::builtin::{
1515
TEXT_DIRECTION_CODEPOINT_IN_COMMENT, TEXT_DIRECTION_CODEPOINT_IN_LITERAL,
1616
};
1717
use rustc_session::parse::ParseSess;
18-
use rustc_span::{BytePos, Pos, Span, Symbol, sym};
18+
use rustc_span::{BytePos, Pos, Span, Symbol};
1919
use tracing::debug;
2020

2121
use crate::errors;
@@ -626,7 +626,6 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
626626
let last_line_start_pos = frontmatter_opening_end_pos + BytePos(last_line_start as u32);
627627

628628
let frontmatter_span = self.mk_sp(frontmatter_opening_pos, self.pos);
629-
self.psess.gated_spans.gate(sym::frontmatter, frontmatter_span);
630629

631630
if !last_line_trimmed.starts_with("---") {
632631
let label_span = self.mk_sp(frontmatter_opening_pos, frontmatter_opening_end_pos);

src/doc/style-guide/src/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,38 @@ given:
218218

219219
### [Types](types.md)
220220

221+
### Frontmatter
222+
223+
There should be no blank lines between the frontmatter and either the start of the file or a shebang.
224+
There can be zero or one line between the frontmatter and any following content.
225+
226+
The frontmatter fences should use the minimum number of dashes necessary for the contained content (one more than the longest series of initial dashes in the
227+
content, with a minimum of 3 to be recognized as frontmatter delimiters).
228+
If an infostring is present after the opening fence, there should be one space separating them.
229+
The frontmatter fence lines should not have trailing whitespace.
230+
231+
Examples:
232+
233+
```rust
234+
#!/usr/bin/env cargo
235+
---
236+
[dependencies]
237+
regex = "1"
238+
---
239+
240+
fn main() {}
241+
```
242+
243+
```rust
244+
#!/usr/bin/env cargo
245+
--- cargo
246+
[dependencies]
247+
regex = "1"
248+
---
249+
250+
fn main() {}
251+
```
252+
221253
### Comments
222254

223255
The following guidelines for comments are recommendations only, a mechanical

src/doc/style-guide/src/nightly.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,3 @@ This chapter documents style and formatting for nightly-only syntax. The rest of
55
Style and formatting for nightly-only syntax should be removed from this chapter and integrated into the appropriate sections of the style guide at the time of stabilization.
66

77
There is no guarantee of the stability of this chapter in contrast to the rest of the style guide. Refer to the style team policy for nightly formatting procedure regarding breaking changes to this chapter.
8-
9-
### Frontmatter
10-
11-
*Location: Placed before comments and attributes in the [root](index.html).*
12-
13-
*Tracking issue: [#136889](https://github.com/rust-lang/rust/issues/136889)*
14-
15-
*Feature gate: `frontmatter`*
16-
17-
There should be no blank lines between the frontmatter and either the start of the file or a shebang.
18-
There can be zero or one line between the frontmatter and any following content.
19-
20-
The frontmatter fences should use the minimum number of dashes necessary for the contained content (one more than the longest series of initial dashes in the
21-
content, with a minimum of 3 to be recognized as frontmatter delimiters).
22-
If an infostring is present after the opening fence, there should be one space separating them.
23-
The frontmatter fence lines should not have trailing whitespace.
24-
25-
```rust
26-
#!/usr/bin/env cargo
27-
--- cargo
28-
[dependencies]
29-
regex = "1"
30-
---
31-
32-
fn main() {}
33-
```

src/doc/unstable-book/src/language-features/frontmatter.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/ui/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ Anything to do with loops and `for`, `loop` and `while` keywords to express them
613613

614614
## `tests/ui/frontmatter/`
615615

616-
Tests for `#![feature(frontmatter)]`. See [Tracking Issue for `frontmatter` #136889](https://github.com/rust-lang/rust/issues/136889).
616+
Tests for Cargo Script's frontmatter.
617617

618618
## `tests/ui/fully-qualified-type/`
619619

tests/ui/feature-gates/feature-gate-frontmatter.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-frontmatter.stderr

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)