rust/tests/ui/lint/unused/unused-parens-for-stmt-expr-attributes-issue-129833.rs
surechen 1e8d6d1ec3 Make unused_parens's suggestion considering expr's attributes
For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`, the suggestion's span should contains the attributes, or the suggestion will remove them.

fixes #129833
2024-10-12 09:32:25 +08:00

16 lines
460 B
Rust

//@ run-rustfix
// Check the `unused_parens` suggestion for paren_expr with attributes.
// The suggestion should retain attributes in the front.
#![feature(stmt_expr_attributes)]
#![deny(unused_parens)]
pub fn foo() -> impl Fn() {
let _ = (#[inline] #[allow(dead_code)] || println!("Hello!")); //~ERROR unnecessary parentheses
(#[inline] #[allow(dead_code)] || println!("Hello!")) //~ERROR unnecessary parentheses
}
fn main() {
let _ = foo();
}