diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index b8a29a9a08f43..f7bd4a4f48c73 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -524,7 +524,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { gate_all!(contracts_internals, "contract internal machinery is for internal use only"); gate_all!(where_clause_attrs, "attributes in `where` clause are unstable"); gate_all!(super_let, "`super let` is experimental"); - gate_all!(frontmatter, "frontmatters are experimental"); gate_all!(coroutines, "coroutine syntax is experimental"); if !visitor.features.never_patterns() { diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 364a1202b05c2..2e843ad8c2c05 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -223,6 +223,8 @@ declare_features! ( (accepted, fn_must_use, "1.27.0", Some(43302)), /// Allows capturing variables in scope using format_args! (accepted, format_args_capture, "1.58.0", Some(67984)), + /// Frontmatter `---` blocks for use by external tools. + (accepted, frontmatter, "CURRENT_RUSTC_VERSION", Some(136889)), /// Infer generic args for both consts and types. (accepted, generic_arg_infer, "1.89.0", Some(85077)), /// Allows associated types to be generic, e.g., `type Foo;` (RFC 1598). diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 8397cd294e0a9..0711bfa7fdaf1 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -518,8 +518,6 @@ declare_features! ( (incomplete, fn_delegation, "1.76.0", Some(118212)), /// Allows impls for the Freeze trait. (internal, freeze_impls, "1.78.0", Some(121675)), - /// Frontmatter `---` blocks for use by external tools. - (unstable, frontmatter, "1.88.0", Some(136889)), /// Allows defining gen blocks and `gen fn`. (unstable, gen_blocks, "1.75.0", Some(117078)), /// Allows non-trivial generic constants which have to have wfness manually propagated to callers diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 51019db7c00e4..c33569736f9a1 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -15,7 +15,7 @@ use rustc_session::lint::builtin::{ TEXT_DIRECTION_CODEPOINT_IN_COMMENT, TEXT_DIRECTION_CODEPOINT_IN_LITERAL, }; use rustc_session::parse::ParseSess; -use rustc_span::{BytePos, Pos, Span, Symbol, sym}; +use rustc_span::{BytePos, Pos, Span, Symbol}; use tracing::debug; use crate::errors; @@ -626,7 +626,6 @@ impl<'psess, 'src> Lexer<'psess, 'src> { let last_line_start_pos = frontmatter_opening_end_pos + BytePos(last_line_start as u32); let frontmatter_span = self.mk_sp(frontmatter_opening_pos, self.pos); - self.psess.gated_spans.gate(sym::frontmatter, frontmatter_span); if !last_line_trimmed.starts_with("---") { let label_span = self.mk_sp(frontmatter_opening_pos, frontmatter_opening_end_pos); diff --git a/src/doc/style-guide/src/README.md b/src/doc/style-guide/src/README.md index c3788c97ae69a..448c951c9be4a 100644 --- a/src/doc/style-guide/src/README.md +++ b/src/doc/style-guide/src/README.md @@ -218,6 +218,38 @@ given: ### [Types](types.md) +### Frontmatter + +There should be no blank lines between the frontmatter and either the start of the file or a shebang. +There can be zero or one line between the frontmatter and any following content. + +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 +content, with a minimum of 3 to be recognized as frontmatter delimiters). +If an infostring is present after the opening fence, there should be one space separating them. +The frontmatter fence lines should not have trailing whitespace. + +Examples: + +```rust +#!/usr/bin/env cargo +--- +[dependencies] +regex = "1" +--- + +fn main() {} +``` + +```rust +#!/usr/bin/env cargo +--- cargo +[dependencies] +regex = "1" +--- + +fn main() {} +``` + ### Comments The following guidelines for comments are recommendations only, a mechanical diff --git a/src/doc/style-guide/src/nightly.md b/src/doc/style-guide/src/nightly.md index 608dbd37192a3..66e7fa3c9f89c 100644 --- a/src/doc/style-guide/src/nightly.md +++ b/src/doc/style-guide/src/nightly.md @@ -5,29 +5,3 @@ This chapter documents style and formatting for nightly-only syntax. The rest of 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. 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. - -### Frontmatter - -*Location: Placed before comments and attributes in the [root](index.html).* - -*Tracking issue: [#136889](https://github.com/rust-lang/rust/issues/136889)* - -*Feature gate: `frontmatter`* - -There should be no blank lines between the frontmatter and either the start of the file or a shebang. -There can be zero or one line between the frontmatter and any following content. - -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 -content, with a minimum of 3 to be recognized as frontmatter delimiters). -If an infostring is present after the opening fence, there should be one space separating them. -The frontmatter fence lines should not have trailing whitespace. - -```rust -#!/usr/bin/env cargo ---- cargo -[dependencies] -regex = "1" ---- - -fn main() {} -``` diff --git a/src/doc/unstable-book/src/language-features/frontmatter.md b/src/doc/unstable-book/src/language-features/frontmatter.md deleted file mode 100644 index 1d5b4feb6ac13..0000000000000 --- a/src/doc/unstable-book/src/language-features/frontmatter.md +++ /dev/null @@ -1,25 +0,0 @@ -# `frontmatter` - -The tracking issue for this feature is: [#136889] - ------- - -The `frontmatter` feature allows an extra metadata block at the top of files for consumption by -external tools. For example, it can be used by [`cargo-script`] files to specify dependencies. - -```rust -#!/usr/bin/env -S cargo -Zscript ---- -[dependencies] -libc = "0.2.172" ---- -#![feature(frontmatter)] -# mod libc { pub type c_int = i32; } - -fn main() { - let x: libc::c_int = 1i32; -} -``` - -[#136889]: https://github.com/rust-lang/rust/issues/136889 -[`cargo-script`]: https://rust-lang.github.io/rfcs/3502-cargo-script.html diff --git a/tests/ui/README.md b/tests/ui/README.md index 3b28ef694dd30..ae92fa95844d9 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -613,7 +613,7 @@ Anything to do with loops and `for`, `loop` and `while` keywords to express them ## `tests/ui/frontmatter/` -Tests for `#![feature(frontmatter)]`. See [Tracking Issue for `frontmatter` #136889](https://github.com/rust-lang/rust/issues/136889). +Tests for Cargo Script's frontmatter. ## `tests/ui/fully-qualified-type/` diff --git a/tests/ui/feature-gates/feature-gate-frontmatter.rs b/tests/ui/feature-gates/feature-gate-frontmatter.rs deleted file mode 100644 index 58e1f57eec025..0000000000000 --- a/tests/ui/feature-gates/feature-gate-frontmatter.rs +++ /dev/null @@ -1,5 +0,0 @@ ----cargo -//~^ ERROR: frontmatters are experimental ---- - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-frontmatter.stderr b/tests/ui/feature-gates/feature-gate-frontmatter.stderr deleted file mode 100644 index 57d38db8e76a9..0000000000000 --- a/tests/ui/feature-gates/feature-gate-frontmatter.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0658]: frontmatters are experimental - --> $DIR/feature-gate-frontmatter.rs:1:1 - | -LL | / ---cargo -LL | | -LL | | --- - | |___^ - | - = note: see issue #136889 for more information - = help: add `#![feature(frontmatter)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/frontmatter/dot-in-infostring-leading.rs b/tests/ui/frontmatter/dot-in-infostring-leading.rs index 0d3d699644e9c..80f6b0724cfc9 100644 --- a/tests/ui/frontmatter/dot-in-infostring-leading.rs +++ b/tests/ui/frontmatter/dot-in-infostring-leading.rs @@ -4,6 +4,4 @@ // infostrings cannot have leading dots -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/dot-in-infostring-non-leading.rs b/tests/ui/frontmatter/dot-in-infostring-non-leading.rs index a4d17bb6e813a..f26ac39ad4b68 100644 --- a/tests/ui/frontmatter/dot-in-infostring-non-leading.rs +++ b/tests/ui/frontmatter/dot-in-infostring-non-leading.rs @@ -4,6 +4,4 @@ // infostrings can contain dots as long as a dot isn't the first character. //@ check-pass -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/escape.rs b/tests/ui/frontmatter/escape.rs index 0e6f064607e82..2892eb77d82f3 100644 --- a/tests/ui/frontmatter/escape.rs +++ b/tests/ui/frontmatter/escape.rs @@ -9,6 +9,4 @@ // This test checks that longer dashes for opening and closing can be used to // escape sequences such as three dashes inside the frontmatter block. -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/extra-after-end.rs b/tests/ui/frontmatter/extra-after-end.rs index de2cf4cc85efd..ab17c218d37ce 100644 --- a/tests/ui/frontmatter/extra-after-end.rs +++ b/tests/ui/frontmatter/extra-after-end.rs @@ -2,6 +2,4 @@ ---cargo //~^ ERROR: extra characters after frontmatter close are not allowed -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-after-tokens.rs b/tests/ui/frontmatter/frontmatter-after-tokens.rs index 6683991dc4af4..86d5f45753eb3 100644 --- a/tests/ui/frontmatter/frontmatter-after-tokens.rs +++ b/tests/ui/frontmatter/frontmatter-after-tokens.rs @@ -1,10 +1,8 @@ -#![feature(frontmatter)] +// frontmatters must be at the start of a file. This test ensures that. --- //~^ ERROR: expected item, found `-` // FIXME(frontmatter): make this diagnostic better --- -// frontmatters must be at the start of a file. This test ensures that. - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-contains-whitespace.rs b/tests/ui/frontmatter/frontmatter-contains-whitespace.rs index 11df822f793cf..bf4dcad8c0915 100644 --- a/tests/ui/frontmatter/frontmatter-contains-whitespace.rs +++ b/tests/ui/frontmatter/frontmatter-contains-whitespace.rs @@ -17,6 +17,4 @@ package.description = """ // Ensure the frontmatter can contain any whitespace -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-crlf.rs b/tests/ui/frontmatter/frontmatter-crlf.rs index b46cc9ddbb0e0..000d08965eab5 100644 --- a/tests/ui/frontmatter/frontmatter-crlf.rs +++ b/tests/ui/frontmatter/frontmatter-crlf.rs @@ -9,6 +9,4 @@ clap = "4" // crlf line endings should be accepted -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs b/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs index 985b1cfe9884f..f3059ef7dad6b 100644 --- a/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs +++ b/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs @@ -5,6 +5,4 @@ x ---🚧️ // Regression test for #141483 //@check-pass -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs b/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs index 3d5fb4538720b..9aebf14fc4106 100644 --- a/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs +++ b/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs @@ -6,6 +6,4 @@ x ---y // non-whitespace character preceding them. //@check-pass -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-non-lexible-tokens.rs b/tests/ui/frontmatter/frontmatter-non-lexible-tokens.rs index ea042edef06b2..b3c2db07537e8 100644 --- a/tests/ui/frontmatter/frontmatter-non-lexible-tokens.rs +++ b/tests/ui/frontmatter/frontmatter-non-lexible-tokens.rs @@ -4,8 +4,6 @@ //@ check-pass -#![feature(frontmatter)] - // check that frontmatter blocks can have tokens that are otherwise not accepted by // the lexer as Rust code. diff --git a/tests/ui/frontmatter/frontmatter-whitespace-1.rs b/tests/ui/frontmatter/frontmatter-whitespace-1.rs index 3b7f762d26ea3..7345b16f945b8 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-1.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-1.rs @@ -1,9 +1,7 @@ --- //~^ ERROR: invalid preceding whitespace for frontmatter opening -//~^^ ERROR: unclosed frontmatter --- - -#![feature(frontmatter)] +//~^ ERROR: invalid preceding whitespace for frontmatter close // check that whitespaces should not precede the frontmatter opening or close. diff --git a/tests/ui/frontmatter/frontmatter-whitespace-1.stderr b/tests/ui/frontmatter/frontmatter-whitespace-1.stderr index f16788fa39929..37ece27acb225 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-1.stderr +++ b/tests/ui/frontmatter/frontmatter-whitespace-1.stderr @@ -10,21 +10,17 @@ note: frontmatter opening should not be preceded by whitespace LL | --- | ^^ -error: unclosed frontmatter - --> $DIR/frontmatter-whitespace-1.rs:1:3 +error: invalid preceding whitespace for frontmatter close + --> $DIR/frontmatter-whitespace-1.rs:3:1 | -LL | / --- -LL | | -LL | | -LL | | --- -LL | | - | |_^ +LL | --- + | ^^^^^ | -note: frontmatter opening here was not closed - --> $DIR/frontmatter-whitespace-1.rs:1:3 +note: frontmatter close should not be preceded by whitespace + --> $DIR/frontmatter-whitespace-1.rs:3:1 | LL | --- - | ^^^ + | ^^ error: aborting due to 2 previous errors diff --git a/tests/ui/frontmatter/frontmatter-whitespace-2.rs b/tests/ui/frontmatter/frontmatter-whitespace-2.rs index 7a28e5c1b85a6..763d6155feca0 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-2.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-2.rs @@ -1,14 +1,12 @@ ---cargo -//~^ ERROR: unclosed frontmatter //@ compile-flags: --crate-type lib -#![feature(frontmatter)] - fn foo(x: i32) -> i32 { ---x - //~^ WARNING: use of a double negation [double_negations] -} + //~^ ERROR: invalid preceding whitespace for frontmatter close + //~| ERROR: extra characters after frontmatter close are not allowed +} //~ ERROR: unexpected closing delimiter: `}` // this test is for the weird case that valid Rust code can have three dashes // within them and get treated as a frontmatter close. diff --git a/tests/ui/frontmatter/frontmatter-whitespace-2.stderr b/tests/ui/frontmatter/frontmatter-whitespace-2.stderr index 2ae63cdc6fe48..ddaa7a01b9eeb 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-2.stderr +++ b/tests/ui/frontmatter/frontmatter-whitespace-2.stderr @@ -1,30 +1,26 @@ -error: unclosed frontmatter - --> $DIR/frontmatter-whitespace-2.rs:1:1 +error: invalid preceding whitespace for frontmatter close + --> $DIR/frontmatter-whitespace-2.rs:6:1 | -LL | / ---cargo -... | -LL | | - | |_^ +LL | ---x + | ^^^^^^^^ | -note: frontmatter opening here was not closed - --> $DIR/frontmatter-whitespace-2.rs:1:1 +note: frontmatter close should not be preceded by whitespace + --> $DIR/frontmatter-whitespace-2.rs:6:1 | -LL | ---cargo - | ^^^ +LL | ---x + | ^^^^ -warning: use of a double negation - --> $DIR/frontmatter-whitespace-2.rs:9:6 +error: extra characters after frontmatter close are not allowed + --> $DIR/frontmatter-whitespace-2.rs:6:1 | LL | ---x - | ^^^ - | - = note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages - = note: use `-= 1` if you meant to decrement the value - = note: `#[warn(double_negations)]` on by default -help: add parentheses for clarity + | ^^^^^^^^ + +error: unexpected closing delimiter: `}` + --> $DIR/frontmatter-whitespace-2.rs:9:1 | -LL | --(-x) - | + + +LL | } + | ^ unexpected closing delimiter -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 3 previous errors diff --git a/tests/ui/frontmatter/frontmatter-whitespace-3.rs b/tests/ui/frontmatter/frontmatter-whitespace-3.rs index 6580514fba2d2..a19f54934dd40 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-3.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-3.rs @@ -12,6 +12,4 @@ // ignore-tidy-leading-newlines // ignore-tidy-tab -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-whitespace-4.rs b/tests/ui/frontmatter/frontmatter-whitespace-4.rs index 1e7c5556647b0..4567a8c91afdc 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-4.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-4.rs @@ -5,6 +5,4 @@ // ignore-tidy-tab // A frontmatter infostring can have leading whitespace. -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/hyphen-in-infostring-leading.rs b/tests/ui/frontmatter/hyphen-in-infostring-leading.rs index 8652fd76ad5ce..e9f69e11c6571 100644 --- a/tests/ui/frontmatter/hyphen-in-infostring-leading.rs +++ b/tests/ui/frontmatter/hyphen-in-infostring-leading.rs @@ -4,6 +4,4 @@ // infostrings cannot have leading hyphens -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/hyphen-in-infostring-non-leading.rs b/tests/ui/frontmatter/hyphen-in-infostring-non-leading.rs index 35e7b96ff875b..44d61d956fc25 100644 --- a/tests/ui/frontmatter/hyphen-in-infostring-non-leading.rs +++ b/tests/ui/frontmatter/hyphen-in-infostring-non-leading.rs @@ -4,6 +4,4 @@ // infostrings can contain hyphens as long as a hyphen isn't the first character. //@ check-pass -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/include-in-item-ctxt.rs b/tests/ui/frontmatter/include-in-item-ctxt.rs index c8455bc49abd2..36df48c4751f0 100644 --- a/tests/ui/frontmatter/include-in-item-ctxt.rs +++ b/tests/ui/frontmatter/include-in-item-ctxt.rs @@ -1,8 +1,6 @@ // Ensure that in item ctxts we can `include` files that contain frontmatter. //@ check-pass -#![feature(frontmatter)] - include!("auxiliary/lib.rs"); fn main() { diff --git a/tests/ui/frontmatter/infostring-fail.rs b/tests/ui/frontmatter/infostring-fail.rs index 91542f62f1a50..64edbb9710a3c 100644 --- a/tests/ui/frontmatter/infostring-fail.rs +++ b/tests/ui/frontmatter/infostring-fail.rs @@ -4,6 +4,4 @@ // infostrings can only be a single identifier. -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/mismatch-1.rs b/tests/ui/frontmatter/mismatch-1.rs index 37e2b0af6b187..5c99dc0eca061 100644 --- a/tests/ui/frontmatter/mismatch-1.rs +++ b/tests/ui/frontmatter/mismatch-1.rs @@ -5,6 +5,4 @@ // there must be the same number of dashes for both the opening and the close // of the frontmatter. -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/mismatch-2.rs b/tests/ui/frontmatter/mismatch-2.rs index 422abe1d6bc99..5112012d1c1f7 100644 --- a/tests/ui/frontmatter/mismatch-2.rs +++ b/tests/ui/frontmatter/mismatch-2.rs @@ -3,6 +3,4 @@ ---cargo //~^ ERROR: extra characters after frontmatter close are not allowed -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/multifrontmatter-2.rs b/tests/ui/frontmatter/multifrontmatter-2.rs index 8e5b45a0bf75f..0bbd3c3d34fb5 100644 --- a/tests/ui/frontmatter/multifrontmatter-2.rs +++ b/tests/ui/frontmatter/multifrontmatter-2.rs @@ -7,6 +7,4 @@ // hyphens only need to be escaped when at the start of a line //@ check-pass -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/multifrontmatter.rs b/tests/ui/frontmatter/multifrontmatter.rs index f3afa47bd3832..f099bf7ca2b6d 100644 --- a/tests/ui/frontmatter/multifrontmatter.rs +++ b/tests/ui/frontmatter/multifrontmatter.rs @@ -8,6 +8,4 @@ // test that we do not parse another frontmatter block after the first one. -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/shebang.rs b/tests/ui/frontmatter/shebang.rs index abd983f219bdd..994e9c8b3127e 100644 --- a/tests/ui/frontmatter/shebang.rs +++ b/tests/ui/frontmatter/shebang.rs @@ -8,6 +8,4 @@ clap = "4" // Shebangs on a file can precede a frontmatter. -#![feature(frontmatter)] - -fn main () {} +fn main() {} diff --git a/tests/ui/frontmatter/unclosed-1.rs b/tests/ui/frontmatter/unclosed-1.rs index d8b52b3e69c7c..f572cd87bbf7d 100644 --- a/tests/ui/frontmatter/unclosed-1.rs +++ b/tests/ui/frontmatter/unclosed-1.rs @@ -5,6 +5,4 @@ // close. There should not be a "missing `main` function" error as the rest // are properly parsed. -#![feature(frontmatter)] - -fn main() {} +fn main() {} //~ ERROR: `main` function not found in crate `unclosed_1` [E0601] diff --git a/tests/ui/frontmatter/unclosed-1.stderr b/tests/ui/frontmatter/unclosed-1.stderr index 04031d128398c..4cc82199c7379 100644 --- a/tests/ui/frontmatter/unclosed-1.stderr +++ b/tests/ui/frontmatter/unclosed-1.stderr @@ -3,8 +3,8 @@ error: unclosed frontmatter | LL | / ----cargo ... | -LL | | - | |_^ +LL | | fn main() {} + | |_________________________________________________________________________________^ | note: frontmatter opening here was not closed --> $DIR/unclosed-1.rs:1:1 @@ -12,5 +12,12 @@ note: frontmatter opening here was not closed LL | ----cargo | ^^^^ -error: aborting due to 1 previous error +error[E0601]: `main` function not found in crate `unclosed_1` + --> $DIR/unclosed-1.rs:8:82 + | +LL | fn main() {} + | ^ consider adding a `main` function to `$DIR/unclosed-1.rs` + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0601`. diff --git a/tests/ui/frontmatter/unclosed-2.rs b/tests/ui/frontmatter/unclosed-2.rs index add266dce5b0a..2e30bca4bab66 100644 --- a/tests/ui/frontmatter/unclosed-2.rs +++ b/tests/ui/frontmatter/unclosed-2.rs @@ -1,6 +1,5 @@ ----cargo //~^ ERROR: unclosed frontmatter -//~| ERROR: frontmatters are experimental //@ compile-flags: --crate-type lib @@ -8,8 +7,6 @@ // the dashes quoted will not be used for recovery and the entire file // should be treated as within the frontmatter block. - #![feature(frontmatter)] - fn foo() -> &str { "----" } diff --git a/tests/ui/frontmatter/unclosed-2.stderr b/tests/ui/frontmatter/unclosed-2.stderr index 0a4022c1557b7..51e680a8f6e9a 100644 --- a/tests/ui/frontmatter/unclosed-2.stderr +++ b/tests/ui/frontmatter/unclosed-2.stderr @@ -13,19 +13,5 @@ note: frontmatter opening here was not closed LL | ----cargo | ^^^^ -error[E0658]: frontmatters are experimental - --> $DIR/unclosed-2.rs:1:1 - | -LL | / ----cargo -... | -LL | | "----" -LL | | } - | |__^ - | - = note: see issue #136889 for more information - = help: add `#![feature(frontmatter)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/frontmatter/unclosed-3.rs b/tests/ui/frontmatter/unclosed-3.rs index 75f3fbda675ce..85e69b6da4f8f 100644 --- a/tests/ui/frontmatter/unclosed-3.rs +++ b/tests/ui/frontmatter/unclosed-3.rs @@ -6,8 +6,6 @@ // Unfortunate recovery situation. Not really preventable with improving the // recovery strategy, but this type of code is rare enough already. - #![feature(frontmatter)] - fn foo(x: i32) -> i32 { ---x //~^ ERROR: invalid preceding whitespace for frontmatter close diff --git a/tests/ui/frontmatter/unclosed-3.stderr b/tests/ui/frontmatter/unclosed-3.stderr index cd69cb0004080..cc9e41139bc3d 100644 --- a/tests/ui/frontmatter/unclosed-3.stderr +++ b/tests/ui/frontmatter/unclosed-3.stderr @@ -1,11 +1,11 @@ error: invalid preceding whitespace for frontmatter close - --> $DIR/unclosed-3.rs:12:1 + --> $DIR/unclosed-3.rs:10:1 | LL | ---x | ^^^^^^^^ | note: frontmatter close should not be preceded by whitespace - --> $DIR/unclosed-3.rs:12:1 + --> $DIR/unclosed-3.rs:10:1 | LL | ---x | ^^^^ @@ -26,13 +26,13 @@ LL | | ---x | ...while the close has 3 dashes error: extra characters after frontmatter close are not allowed - --> $DIR/unclosed-3.rs:12:1 + --> $DIR/unclosed-3.rs:10:1 | LL | ---x | ^^^^^^^^ error: unexpected closing delimiter: `}` - --> $DIR/unclosed-3.rs:15:1 + --> $DIR/unclosed-3.rs:13:1 | LL | } | ^ unexpected closing delimiter diff --git a/tests/ui/frontmatter/unclosed-4.rs b/tests/ui/frontmatter/unclosed-4.rs index 41f6461db634d..3c2864ef2deba 100644 --- a/tests/ui/frontmatter/unclosed-4.rs +++ b/tests/ui/frontmatter/unclosed-4.rs @@ -4,6 +4,4 @@ //! Similarly, a module-level content should allow for recovery as well (as //! per unclosed-1.rs) -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/unclosed-5.rs b/tests/ui/frontmatter/unclosed-5.rs index 9abbcfff94c76..7f9c66d9a0779 100644 --- a/tests/ui/frontmatter/unclosed-5.rs +++ b/tests/ui/frontmatter/unclosed-5.rs @@ -1,6 +1,5 @@ ----cargo //~^ ERROR: unclosed frontmatter -//~| ERROR: frontmatters are experimental // Similarly, a use statement should allow for recovery as well (as // per unclosed-1.rs) diff --git a/tests/ui/frontmatter/unclosed-5.stderr b/tests/ui/frontmatter/unclosed-5.stderr index e904014a175a5..597ad87cabac1 100644 --- a/tests/ui/frontmatter/unclosed-5.stderr +++ b/tests/ui/frontmatter/unclosed-5.stderr @@ -12,18 +12,5 @@ note: frontmatter opening here was not closed LL | ----cargo | ^^^^ -error[E0658]: frontmatters are experimental - --> $DIR/unclosed-5.rs:1:1 - | -LL | / ----cargo -... | -LL | | - | |_^ - | - = note: see issue #136889 for more information - = help: add `#![feature(frontmatter)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/frontmatter/unclosed-6.rs b/tests/ui/frontmatter/unclosed-6.rs index ea8d4702f6307..9ce7b44a579a7 100644 --- a/tests/ui/frontmatter/unclosed-6.rs +++ b/tests/ui/frontmatter/unclosed-6.rs @@ -1,12 +1,10 @@ --- -//~^ ERROR unclosed frontmatter 🦀--- --- +//~^ ERROR invalid preceding whitespace for frontmatter close // This test checks the location of the --- recovered by the parser is not // incorrectly tracked during the less fortunate recovery case and multiple // candidates are found, as seen with #146847 -#![feature(frontmatter)] - fn main() {} diff --git a/tests/ui/frontmatter/unclosed-6.stderr b/tests/ui/frontmatter/unclosed-6.stderr index 01a13e87268c7..773223dc0be4d 100644 --- a/tests/ui/frontmatter/unclosed-6.stderr +++ b/tests/ui/frontmatter/unclosed-6.stderr @@ -1,19 +1,14 @@ -error: unclosed frontmatter - --> $DIR/unclosed-6.rs:1:1 +error: invalid preceding whitespace for frontmatter close + --> $DIR/unclosed-6.rs:3:1 | -LL | / --- -LL | | -LL | | 🦀--- -LL | | --- -... | -LL | | - | |_^ +LL | --- + | ^^^^ | -note: frontmatter opening here was not closed - --> $DIR/unclosed-6.rs:1:1 +note: frontmatter close should not be preceded by whitespace + --> $DIR/unclosed-6.rs:3:1 | -LL | --- - | ^^^ +LL | --- + | ^ error: aborting due to 1 previous error diff --git a/tests/ui/unpretty/frontmatter.rs b/tests/ui/unpretty/frontmatter.rs index 1971808e2a866..5dfff6d8a7799 100644 --- a/tests/ui/unpretty/frontmatter.rs +++ b/tests/ui/unpretty/frontmatter.rs @@ -4,7 +4,5 @@ //@ compile-flags: -Zunpretty=normal //@ check-pass -#![feature(frontmatter)] - fn main() { } diff --git a/tests/ui/unpretty/frontmatter.stdout b/tests/ui/unpretty/frontmatter.stdout index 2ccbb1b258255..05bb098f1006b 100644 --- a/tests/ui/unpretty/frontmatter.stdout +++ b/tests/ui/unpretty/frontmatter.stdout @@ -4,6 +4,4 @@ //@ compile-flags: -Zunpretty=normal //@ check-pass -#![feature(frontmatter)] - fn main() {}