From 5ad7c397b5130e25e8609aaee4c5e46610be5113 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Thu, 11 Apr 2024 16:11:14 +0000 Subject: [PATCH] tests: add tests for doc comments on expressions --- .../feature-gate-stmt_expr_attributes.rs | 11 +++++++++ .../feature-gate-stmt_expr_attributes.stderr | 24 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs index f213e8933bf57..85c08ec035eb3 100644 --- a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs +++ b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs @@ -1,4 +1,15 @@ const X: i32 = #[allow(dead_code)] 8; //~^ ERROR attributes on expressions are experimental +const Y: i32 = + /// foo +//~^ ERROR attributes on expressions are experimental + 8; + +const Z: i32 = { + //! foo +//~^ ERROR attributes on expressions are experimental + 8 +}; + fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr index 67fdae030c04e..6cca068072254 100644 --- a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr +++ b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr @@ -8,6 +8,28 @@ LL | const X: i32 = #[allow(dead_code)] 8; = help: add `#![feature(stmt_expr_attributes)]` 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 +error[E0658]: attributes on expressions are experimental + --> $DIR/feature-gate-stmt_expr_attributes.rs:5:5 + | +LL | /// foo + | ^^^^^^^ + | + = note: see issue #15701 for more information + = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = help: `///` is for documentation comments. For a plain comment, use `//`. + +error[E0658]: attributes on expressions are experimental + --> $DIR/feature-gate-stmt_expr_attributes.rs:10:5 + | +LL | //! foo + | ^^^^^^^ + | + = note: see issue #15701 for more information + = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = help: `///` is for documentation comments. For a plain comment, use `//`. + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`.