From 2043790c3a6c0fed33c27acb5d91da52903a8e1d Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 27 May 2026 16:04:59 +0200 Subject: [PATCH] `#[expect]` is an attribute valid for outer style --- compiler/rustc_ast/src/ast.rs | 1 + tests/ui/parser/const-block-items/inner-attr.stderr | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index af8ad425507c..682ba78cddc5 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -3497,6 +3497,7 @@ pub fn is_valid_for_outer_style(&self) -> bool { || self.path == sym::warn || self.path == sym::allow || self.path == sym::deny + || self.path == sym::expect } } diff --git a/tests/ui/parser/const-block-items/inner-attr.stderr b/tests/ui/parser/const-block-items/inner-attr.stderr index e0a70566332c..8cd5d1487b08 100644 --- a/tests/ui/parser/const-block-items/inner-attr.stderr +++ b/tests/ui/parser/const-block-items/inner-attr.stderr @@ -8,6 +8,11 @@ LL | fn main() {} | ------------ the inner attribute doesn't annotate this function | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files +help: to annotate the function, change the attribute from inner to outer style + | +LL - #![expect(unused)] +LL + #[expect(unused)] + | error: aborting due to 1 previous error