Fix allow attribute, items from macros in items_after_statements

This commit is contained in:
Alex Macleod 2023-03-24 15:29:30 +00:00
parent 00e9372987
commit b13f99c7e7
4 changed files with 37 additions and 19 deletions

View file

@ -51,3 +51,20 @@ fn semicolon() {
let _ = S::new(3);
}
fn item_from_macro() {
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
};
}
let _ = 1;
static_assert_size!(u32, 4);
}
fn allow_attribute() {
let _ = 1;
#[allow(clippy::items_after_statements)]
const _: usize = 1;
}

View file

@ -1,5 +1,5 @@
error: adding items after statements is confusing, since items exist from the start of the scope
--> $DIR/item_after_statement.rs:13:5
--> $DIR/items_after_statement.rs:13:5
|
LL | / fn foo() {
LL | | println!("foo");
@ -9,7 +9,7 @@ LL | | }
= note: `-D clippy::items-after-statements` implied by `-D warnings`
error: adding items after statements is confusing, since items exist from the start of the scope
--> $DIR/item_after_statement.rs:20:5
--> $DIR/items_after_statement.rs:20:5
|
LL | / fn foo() {
LL | | println!("foo");
@ -17,7 +17,7 @@ LL | | }
| |_____^
error: adding items after statements is confusing, since items exist from the start of the scope
--> $DIR/item_after_statement.rs:33:13
--> $DIR/items_after_statement.rs:33:13
|
LL | / fn say_something() {
LL | | println!("something");