From d03ae8ba6ba0ec4f9c67f1982db8467d231fb646 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sun, 16 Feb 2025 15:38:07 +0000 Subject: [PATCH] `ui_test` annotation cleanup --- tests/ui/asm_syntax_not_x86.rs | 6 +- tests/ui/attrs.rs | 5 +- tests/ui/attrs.stderr | 4 +- tests/ui/crashes/ice-5835.fixed | 10 + tests/ui/crashes/ice-5835.rs | 5 +- tests/ui/crashes/ice-5835.stderr | 20 +- tests/ui/doc/unbalanced_ticks.rs | 25 +-- tests/ui/doc/unbalanced_ticks.stderr | 174 ++++++++---------- tests/ui/doc_link_with_quotes.rs | 1 - tests/ui/doc_link_with_quotes.stderr | 4 +- .../ui/empty_line_after/doc_comments.1.fixed | 23 +-- .../ui/empty_line_after/doc_comments.2.fixed | 50 +++-- tests/ui/empty_line_after/doc_comments.rs | 23 +-- tests/ui/empty_line_after/doc_comments.stderr | 67 +++---- .../auxiliary/submodule.rs | 2 - .../ui/mixed_attributes_style/global_allow.rs | 5 +- .../global_allow.stderr | 20 -- .../mixed_attributes_style/mod_declaration.rs | 1 - .../mod_declaration.stderr | 22 +-- tests/ui/suspicious_else_formatting.rs | 3 +- tests/ui/suspicious_else_formatting.stderr | 16 +- tests/ui/unneeded_struct_pattern.fixed | 39 +++- tests/ui/unneeded_struct_pattern.rs | 24 ++- tests/ui/unneeded_struct_pattern.stderr | 146 ++++++++++----- 24 files changed, 340 insertions(+), 355 deletions(-) create mode 100644 tests/ui/crashes/ice-5835.fixed delete mode 100644 tests/ui/mixed_attributes_style/global_allow.stderr diff --git a/tests/ui/asm_syntax_not_x86.rs b/tests/ui/asm_syntax_not_x86.rs index 91fde12680cc..edcd5247f18c 100644 --- a/tests/ui/asm_syntax_not_x86.rs +++ b/tests/ui/asm_syntax_not_x86.rs @@ -1,5 +1,6 @@ //@ignore-target: i686 x86 //@needs-asm-support +//@check-pass #[warn(clippy::inline_asm_x86_intel_syntax)] #[warn(clippy::inline_asm_x86_att_syntax)] @@ -8,17 +9,12 @@ mod dont_warn { pub(super) unsafe fn use_asm() { asm!(""); - //~^ inline_asm_x86_intel_syntax asm!("", options()); - //~^ inline_asm_x86_intel_syntax asm!("", options(nostack)); - //~^ inline_asm_x86_intel_syntax } global_asm!(""); - //~^ inline_asm_x86_intel_syntax global_asm!("", options()); - //~^ inline_asm_x86_intel_syntax } fn main() { diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index 583a0ada437d..f60c71837d5e 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -1,10 +1,9 @@ #![warn(clippy::inline_always, clippy::deprecated_semver)] -#![allow(clippy::assertions_on_constants, clippy::empty_line_after_outer_attr)] +#![allow(clippy::assertions_on_constants)] #![allow(clippy::missing_docs_in_private_items, clippy::panic, clippy::unreachable)] #[inline(always)] //~^ inline_always - fn test_attr_lint() { assert!(true) } @@ -26,12 +25,10 @@ fn empty_and_false_positive_stmt() { #[deprecated(since = "forever")] //~^ deprecated_semver - pub const SOME_CONST: u8 = 42; #[deprecated(since = "1")] //~^ deprecated_semver - pub const ANOTHER_CONST: u8 = 23; #[deprecated(since = "0.1.1")] diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index a7fdceaba6f3..85b318cc0fdb 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,5 +1,5 @@ error: the since field must contain a semver-compliant version - --> tests/ui/attrs.rs:27:14 + --> tests/ui/attrs.rs:26:14 | LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #[deprecated(since = "forever")] = help: to override `-D warnings` add `#[allow(clippy::deprecated_semver)]` error: the since field must contain a semver-compliant version - --> tests/ui/attrs.rs:32:14 + --> tests/ui/attrs.rs:30:14 | LL | #[deprecated(since = "1")] | ^^^^^^^^^^^ diff --git a/tests/ui/crashes/ice-5835.fixed b/tests/ui/crashes/ice-5835.fixed new file mode 100644 index 000000000000..e9c24b8e9f09 --- /dev/null +++ b/tests/ui/crashes/ice-5835.fixed @@ -0,0 +1,10 @@ +#[rustfmt::skip] +pub struct Foo { + //~v tabs_in_doc_comments + /// 位 + /// ^ Do not remove this tab character. + /// It was required to trigger the ICE. + pub bar: u8, +} + +fn main() {} diff --git a/tests/ui/crashes/ice-5835.rs b/tests/ui/crashes/ice-5835.rs index 149ba4786181..99858f45933e 100644 --- a/tests/ui/crashes/ice-5835.rs +++ b/tests/ui/crashes/ice-5835.rs @@ -1,10 +1,7 @@ #[rustfmt::skip] pub struct Foo { + //~v tabs_in_doc_comments /// 位 - //~^ tabs_in_doc_comments - //~| empty_line_after_doc_comments - - /// ^ Do not remove this tab character. /// It was required to trigger the ICE. pub bar: u8, diff --git a/tests/ui/crashes/ice-5835.stderr b/tests/ui/crashes/ice-5835.stderr index b342b43d0416..4ef91e4116b2 100644 --- a/tests/ui/crashes/ice-5835.stderr +++ b/tests/ui/crashes/ice-5835.stderr @@ -1,5 +1,5 @@ error: using tabs in doc comments is not recommended - --> tests/ui/crashes/ice-5835.rs:3:10 + --> tests/ui/crashes/ice-5835.rs:4:10 | LL | /// 位 | ^^^^ help: consider using four spaces per tab @@ -7,21 +7,5 @@ LL | /// 位 = note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]` -error: empty lines after doc comment - --> tests/ui/crashes/ice-5835.rs:3:5 - | -LL | / /// 位 -... | -LL | | - | |_^ - | - = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]` - = help: if the empty lines are unintentional remove them -help: if the doc comment should not document `bar` comment it out - | -LL | // /// 位 - | ++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/doc/unbalanced_ticks.rs b/tests/ui/doc/unbalanced_ticks.rs index 8adbb1f7f714..e8cfe44a6789 100644 --- a/tests/ui/doc/unbalanced_ticks.rs +++ b/tests/ui/doc/unbalanced_ticks.rs @@ -5,22 +5,20 @@ #![warn(clippy::doc_markdown)] /// This is a doc comment with `unbalanced_tick marks and several words that -//~^ empty_line_after_doc_comments - +//~^ doc_markdown /// should be `encompassed_by` tick marks because they `contain_underscores`. /// Because of the initial `unbalanced_tick` pair, the error message is /// very `confusing_and_misleading`. fn main() {} /// This paragraph has `unbalanced_tick marks and should stop_linting. -//~^ empty_line_after_doc_comments - +//~^ doc_markdown /// /// This paragraph is fine and should_be linted normally. - +//~^ doc_markdown /// /// Double unbalanced backtick from ``here to here` should lint. - +//~^ doc_markdown /// /// Double balanced back ticks ``start end`` is fine. fn multiple_paragraphs() {} @@ -34,16 +32,15 @@ fn in_code_block() {} /// # `Fine` /// /// ## not_fine -//~^ empty_line_after_doc_comments - +//~^ doc_markdown /// /// ### `unbalanced - +//~^ doc_markdown /// /// - This `item has unbalanced tick marks - +//~^ doc_markdown /// - This item needs backticks_here - +//~^ doc_markdown fn other_markdown() {} #[rustfmt::skip] @@ -54,8 +51,7 @@ fn other_markdown() {} fn issue_7421() {} /// ` -//~^ empty_line_after_doc_comments - +//~^ doc_markdown fn escape_0() {} /// Escaped \` backticks don't count. @@ -65,8 +61,7 @@ fn escape_1() {} fn escape_2() {} /// Escaped \` ` backticks don't count, but unescaped backticks do. -//~^ empty_line_after_doc_comments - +//~^ doc_markdown fn escape_3() {} /// Backslashes ` \` within code blocks don't count. diff --git a/tests/ui/doc/unbalanced_ticks.stderr b/tests/ui/doc/unbalanced_ticks.stderr index 563d86376481..50324010e97f 100644 --- a/tests/ui/doc/unbalanced_ticks.stderr +++ b/tests/ui/doc/unbalanced_ticks.stderr @@ -1,112 +1,98 @@ -error: empty line after doc comment - --> tests/ui/doc/unbalanced_ticks.rs:7:1 +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:7:5 | -LL | / /// This is a doc comment with `unbalanced_tick marks and several words that +LL | /// This is a doc comment with `unbalanced_tick marks and several words that + | _____^ LL | | -LL | | - | |_^ -... -LL | fn main() {} - | --------- the comment documents this function - | - = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]` - = help: if the empty line is unintentional remove it -help: if the doc comment should not document `main` comment it out - | -LL | // /// This is a doc comment with `unbalanced_tick marks and several words that - | ++ +LL | | /// should be `encompassed_by` tick marks because they `contain_underscores`. +LL | | /// Because of the initial `unbalanced_tick` pair, the error message is +LL | | /// very `confusing_and_misleading`. + | |____________________________________^ + | + = help: a backtick may be missing a pair + = note: `-D clippy::doc-markdown` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` -error: empty lines after doc comment - --> tests/ui/doc/unbalanced_ticks.rs:15:1 +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:14:5 | -LL | / /// This paragraph has `unbalanced_tick marks and should stop_linting. -LL | | -LL | | -LL | | /// -... | -LL | | /// Double unbalanced backtick from ``here to here` should lint. -LL | | - | |_^ -... -LL | fn multiple_paragraphs() {} - | ------------------------ the comment documents this function - | - = help: if the empty lines are unintentional remove them -help: if the doc comment should not document `multiple_paragraphs` comment it out - | -LL ~ // /// This paragraph has `unbalanced_tick marks and should stop_linting. -LL | -LL | -LL ~ // /// -LL ~ // /// This paragraph is fine and should_be linted normally. -LL | -LL ~ // /// -LL ~ // /// Double unbalanced backtick from ``here to here` should lint. +LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = help: a backtick may be missing a pair -error: empty lines after doc comment - --> tests/ui/doc/unbalanced_ticks.rs:36:1 +error: item in documentation is missing backticks + --> tests/ui/doc/unbalanced_ticks.rs:17:32 | -LL | / /// ## not_fine -LL | | -LL | | -LL | | /// -... | -LL | | /// - This item needs backticks_here -LL | | - | |_^ -LL | fn other_markdown() {} - | ------------------- the comment documents this function - | - = help: if the empty lines are unintentional remove them -help: if the doc comment should not document `other_markdown` comment it out - | -LL ~ // /// # `Fine` -LL ~ // /// -LL ~ // /// ## not_fine -LL | -LL | -LL ~ // /// -LL ~ // /// ### `unbalanced -LL | -LL ~ // /// -LL ~ // /// - This `item has unbalanced tick marks -LL | -LL ~ // /// - This item needs backticks_here +LL | /// This paragraph is fine and should_be linted normally. + | ^^^^^^^^^ | +help: try + | +LL | /// This paragraph is fine and `should_be` linted normally. + | ~~~~~~~~~~~ -error: empty line after doc comment - --> tests/ui/doc/unbalanced_ticks.rs:56:1 +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:20:5 | -LL | / /// ` -LL | | -LL | | - | |_^ -LL | fn escape_0() {} - | ------------- the comment documents this function +LL | /// Double unbalanced backtick from ``here to here` should lint. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: if the empty line is unintentional remove it -help: if the doc comment should not document `escape_0` comment it out + = help: a backtick may be missing a pair + +error: item in documentation is missing backticks + --> tests/ui/doc/unbalanced_ticks.rs:34:8 | -LL | // /// ` - | ++ +LL | /// ## not_fine + | ^^^^^^^^ + | +help: try + | +LL | /// ## `not_fine` + | ~~~~~~~~~~ -error: empty line after doc comment - --> tests/ui/doc/unbalanced_ticks.rs:67:1 +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:37:5 | -LL | / /// Escaped \` ` backticks don't count, but unescaped backticks do. -LL | | -LL | | - | |_^ -LL | fn escape_3() {} - | ------------- the comment documents this function +LL | /// ### `unbalanced + | ^^^^^^^^^^^^^^^ + | + = help: a backtick may be missing a pair + +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:40:5 + | +LL | /// - This `item has unbalanced tick marks + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: a backtick may be missing a pair + +error: item in documentation is missing backticks + --> tests/ui/doc/unbalanced_ticks.rs:42:23 + | +LL | /// - This item needs backticks_here + | ^^^^^^^^^^^^^^ + | +help: try + | +LL | /// - This item needs `backticks_here` + | ~~~~~~~~~~~~~~~~ + +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:53:5 + | +LL | /// ` + | ^ + | + = help: a backtick may be missing a pair + +error: backticks are unbalanced + --> tests/ui/doc/unbalanced_ticks.rs:63:5 | - = help: if the empty line is unintentional remove it -help: if the doc comment should not document `escape_3` comment it out +LL | /// Escaped \` ` backticks don't count, but unescaped backticks do. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | // /// Escaped \` ` backticks don't count, but unescaped backticks do. - | ++ + = help: a backtick may be missing a pair -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors diff --git a/tests/ui/doc_link_with_quotes.rs b/tests/ui/doc_link_with_quotes.rs index e2614e6b4318..0c0e273da6db 100644 --- a/tests/ui/doc_link_with_quotes.rs +++ b/tests/ui/doc_link_with_quotes.rs @@ -1,5 +1,4 @@ #![warn(clippy::doc_link_with_quotes)] -#![allow(clippy::empty_line_after_doc_comments)] fn main() { foo() diff --git a/tests/ui/doc_link_with_quotes.stderr b/tests/ui/doc_link_with_quotes.stderr index 1c1d8e0ffd52..47c60390310c 100644 --- a/tests/ui/doc_link_with_quotes.stderr +++ b/tests/ui/doc_link_with_quotes.stderr @@ -1,5 +1,5 @@ error: possible intra-doc link using quotes instead of backticks - --> tests/ui/doc_link_with_quotes.rs:8:12 + --> tests/ui/doc_link_with_quotes.rs:7:12 | LL | /// Calls ['bar'] uselessly | ^^^^^ @@ -8,7 +8,7 @@ LL | /// Calls ['bar'] uselessly = help: to override `-D warnings` add `#[allow(clippy::doc_link_with_quotes)]` error: possible intra-doc link using quotes instead of backticks - --> tests/ui/doc_link_with_quotes.rs:14:12 + --> tests/ui/doc_link_with_quotes.rs:13:12 | LL | /// Calls ["bar"] uselessly | ^^^^^ diff --git a/tests/ui/empty_line_after/doc_comments.1.fixed b/tests/ui/empty_line_after/doc_comments.1.fixed index c1a15f47ba10..fd6a94b6a80c 100644 --- a/tests/ui/empty_line_after/doc_comments.1.fixed +++ b/tests/ui/empty_line_after/doc_comments.1.fixed @@ -1,17 +1,16 @@ #![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)] +//~vvv empty_line_after_doc_comments /// Meant to be an /// inner doc comment /// for the crate -//~^ empty_line_after_doc_comments fn first_in_crate() {} mod m { - + //~vvv empty_line_after_doc_comments /// Meant to be an /// inner doc comment /// for the module - //~^ empty_line_after_doc_comments fn first_in_module() {} } @@ -22,14 +21,14 @@ mod some_mod { fn some_noop() {} } + //~v empty_line_after_doc_comments /// # Indented - //~^ empty_line_after_doc_comments /// Blank line fn indented() {} } +//~v empty_line_after_doc_comments /// This should produce a warning -//~^ empty_line_after_doc_comments fn with_doc_and_newline() {} // This should *NOT* produce a warning @@ -37,8 +36,8 @@ fn with_doc_and_newline() {} /// some comment fn with_no_newline_and_comment() {} +//~v empty_line_after_doc_comments /// This doc comment should produce a warning -//~^ empty_line_after_doc_comments /** This is also a doc comment and is part of the warning */ #[allow(non_camel_case_types)] @@ -47,15 +46,14 @@ fn with_no_newline_and_comment() {} fn three_attributes() {} mod misattributed { - + //~v empty_line_after_doc_comments /// docs for `old_code` - //~^ empty_line_after_doc_comments // fn old_code() {} fn new_code() {} + //~vv empty_line_after_doc_comments /// Docs /// for OldA - //~^ empty_line_after_doc_comments // struct OldA; /// Docs /// for OldB @@ -67,25 +65,24 @@ mod misattributed { } mod block_comments { - + //~v empty_line_after_doc_comments /** * Meant to be inner doc comment */ - //~^^^ empty_line_after_doc_comments fn first_in_module() {} + //~v empty_line_after_doc_comments /** * Docs for `old_code` */ - //~^^^ empty_line_after_doc_comments /* fn old_code() {} */ /** * Docs for `new_code` */ fn new_code() {} + //~v empty_line_after_doc_comments /// Docs for `old_code2` - //~^ empty_line_after_doc_comments /* fn old_code2() {} */ /// Docs for `new_code2` fn new_code2() {} diff --git a/tests/ui/empty_line_after/doc_comments.2.fixed b/tests/ui/empty_line_after/doc_comments.2.fixed index abec7b54c632..7a57dcd92332 100644 --- a/tests/ui/empty_line_after/doc_comments.2.fixed +++ b/tests/ui/empty_line_after/doc_comments.2.fixed @@ -1,18 +1,17 @@ #![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)] -// /// Meant to be an -// /// inner doc comment -// /// for the crate -//~^ empty_line_after_doc_comments +//~vvv empty_line_after_doc_comments +//! Meant to be an +//! inner doc comment +//! for the crate fn first_in_crate() {} mod m { - - // /// Meant to be an - // /// inner doc comment - // /// for the module - //~^ empty_line_after_doc_comments + //~vvv empty_line_after_doc_comments + //! Meant to be an + //! inner doc comment + //! for the module fn first_in_module() {} } @@ -24,16 +23,15 @@ mod some_mod { fn some_noop() {} } - // /// # Indented - //~^ empty_line_after_doc_comments - + //~v empty_line_after_doc_comments + /// # Indented + /// /// Blank line fn indented() {} } -// /// This should produce a warning -//~^ empty_line_after_doc_comments - +//~v empty_line_after_doc_comments +/// This should produce a warning fn with_doc_and_newline() {} // This should *NOT* produce a warning @@ -41,28 +39,25 @@ fn with_doc_and_newline() {} /// some comment fn with_no_newline_and_comment() {} -// /// This doc comment should produce a warning -//~^ empty_line_after_doc_comments - -/* This is also a doc comment and is part of the warning +//~v empty_line_after_doc_comments +/// This doc comment should produce a warning +/** This is also a doc comment and is part of the warning */ - #[allow(non_camel_case_types)] #[allow(missing_docs)] #[allow(dead_code)] fn three_attributes() {} mod misattributed { - + //~v empty_line_after_doc_comments // /// docs for `old_code` - //~^ empty_line_after_doc_comments // fn old_code() {} fn new_code() {} + //~vv empty_line_after_doc_comments // /// Docs // /// for OldA - //~^ empty_line_after_doc_comments // struct OldA; // /// Docs @@ -76,18 +71,17 @@ mod misattributed { } mod block_comments { - - /* + //~v empty_line_after_doc_comments + /*! * Meant to be inner doc comment */ - //~^^^ empty_line_after_doc_comments fn first_in_module() {} + //~v empty_line_after_doc_comments /* * Docs for `old_code` */ - //~^^^ empty_line_after_doc_comments /* fn old_code() {} */ /** @@ -95,8 +89,8 @@ mod block_comments { */ fn new_code() {} + //~v empty_line_after_doc_comments // /// Docs for `old_code2` - //~^ empty_line_after_doc_comments /* fn old_code2() {} */ /// Docs for `new_code2` diff --git a/tests/ui/empty_line_after/doc_comments.rs b/tests/ui/empty_line_after/doc_comments.rs index d225768f6125..1da761a5c3d5 100644 --- a/tests/ui/empty_line_after/doc_comments.rs +++ b/tests/ui/empty_line_after/doc_comments.rs @@ -1,18 +1,17 @@ #![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)] +//~vvv empty_line_after_doc_comments /// Meant to be an /// inner doc comment /// for the crate -//~^ empty_line_after_doc_comments fn first_in_crate() {} mod m { - + //~vvv empty_line_after_doc_comments /// Meant to be an /// inner doc comment /// for the module - //~^ empty_line_after_doc_comments fn first_in_module() {} } @@ -24,15 +23,15 @@ mod some_mod { fn some_noop() {} } + //~v empty_line_after_doc_comments /// # Indented - //~^ empty_line_after_doc_comments /// Blank line fn indented() {} } +//~v empty_line_after_doc_comments /// This should produce a warning -//~^ empty_line_after_doc_comments fn with_doc_and_newline() {} @@ -41,8 +40,8 @@ fn with_doc_and_newline() {} /// some comment fn with_no_newline_and_comment() {} +//~v empty_line_after_doc_comments /// This doc comment should produce a warning -//~^ empty_line_after_doc_comments /** This is also a doc comment and is part of the warning */ @@ -53,16 +52,15 @@ fn with_no_newline_and_comment() {} fn three_attributes() {} mod misattributed { - + //~v empty_line_after_doc_comments /// docs for `old_code` - //~^ empty_line_after_doc_comments // fn old_code() {} fn new_code() {} + //~vv empty_line_after_doc_comments /// Docs /// for OldA - //~^ empty_line_after_doc_comments // struct OldA; /// Docs @@ -76,18 +74,17 @@ mod misattributed { } mod block_comments { - + //~v empty_line_after_doc_comments /** * Meant to be inner doc comment */ - //~^^^ empty_line_after_doc_comments fn first_in_module() {} + //~v empty_line_after_doc_comments /** * Docs for `old_code` */ - //~^^^ empty_line_after_doc_comments /* fn old_code() {} */ /** @@ -95,8 +92,8 @@ mod block_comments { */ fn new_code() {} + //~v empty_line_after_doc_comments /// Docs for `old_code2` - //~^ empty_line_after_doc_comments /* fn old_code2() {} */ /// Docs for `new_code2` diff --git a/tests/ui/empty_line_after/doc_comments.stderr b/tests/ui/empty_line_after/doc_comments.stderr index 9b627e8df1ff..c5d5f3d37594 100644 --- a/tests/ui/empty_line_after/doc_comments.stderr +++ b/tests/ui/empty_line_after/doc_comments.stderr @@ -1,8 +1,7 @@ error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:5:1 + --> tests/ui/empty_line_after/doc_comments.rs:6:1 | LL | / /// for the crate -LL | | LL | | | |_^ LL | fn first_in_crate() {} @@ -11,36 +10,34 @@ LL | fn first_in_crate() {} = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]` = help: if the empty line is unintentional remove it -help: if the doc comment should not document `first_in_crate` comment it out +help: if the comment should document the crate use an inner doc comment | -LL ~ // /// Meant to be an -LL ~ // /// inner doc comment -LL ~ // /// for the crate +LL ~ //! Meant to be an +LL ~ //! inner doc comment +LL ~ //! for the crate | error: empty line after doc comment --> tests/ui/empty_line_after/doc_comments.rs:14:5 | LL | / /// for the module -LL | | LL | | | |_^ LL | fn first_in_module() {} | -------------------- the comment documents this function | = help: if the empty line is unintentional remove it -help: if the doc comment should not document `first_in_module` comment it out +help: if the comment should document the parent module use an inner doc comment | -LL ~ // /// Meant to be an -LL ~ // /// inner doc comment -LL ~ // /// for the module +LL ~ //! Meant to be an +LL ~ //! inner doc comment +LL ~ //! for the module | error: empty line after doc comment --> tests/ui/empty_line_after/doc_comments.rs:27:5 | LL | / /// # Indented -LL | | LL | | | |_^ LL | /// Blank line @@ -48,33 +45,27 @@ LL | fn indented() {} | ------------- the comment documents this function | = help: if the empty line is unintentional remove it -help: if the doc comment should not document `indented` comment it out +help: if the documentation should include the empty line include it in the comment + | +LL | /// | -LL | // /// # Indented - | ++ error: empty line after doc comment --> tests/ui/empty_line_after/doc_comments.rs:34:1 | LL | / /// This should produce a warning -LL | | LL | | | |_^ LL | fn with_doc_and_newline() {} | ------------------------- the comment documents this function | = help: if the empty line is unintentional remove it -help: if the doc comment should not document `with_doc_and_newline` comment it out - | -LL | // /// This should produce a warning - | ++ error: empty lines after doc comment --> tests/ui/empty_line_after/doc_comments.rs:44:1 | LL | / /// This doc comment should produce a warning LL | | -LL | | LL | | /** This is also a doc comment and is part of the warning LL | | */ LL | | @@ -84,19 +75,12 @@ LL | fn three_attributes() {} | --------------------- the comment documents this function | = help: if the empty lines are unintentional remove them -help: if the doc comment should not document `three_attributes` comment it out - | -LL ~ // /// This doc comment should produce a warning -LL | -LL | -LL ~ /* This is also a doc comment and is part of the warning - | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:57:5 + --> tests/ui/empty_line_after/doc_comments.rs:56:5 | LL | / /// docs for `old_code` -... | +LL | | // fn old_code() {} LL | | | |_^ LL | fn new_code() {} @@ -109,9 +93,12 @@ LL | // /// docs for `old_code` | ++ error: empty lines after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:64:5 + --> tests/ui/empty_line_after/doc_comments.rs:63:5 | LL | / /// for OldA +LL | | // struct OldA; +LL | | +LL | | /// Docs ... | LL | | | |_^ @@ -124,7 +111,6 @@ help: if the doc comment should not document `Multiple` comment it out | LL ~ // /// Docs LL ~ // /// for OldA -LL | LL | // struct OldA; LL | LL ~ // /// Docs @@ -132,31 +118,29 @@ LL ~ // /// for OldB | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:80:5 + --> tests/ui/empty_line_after/doc_comments.rs:78:5 | LL | / /** LL | | * Meant to be inner doc comment LL | | */ -LL | | LL | | | |_^ LL | fn first_in_module() {} | -------------------- the comment documents this function | = help: if the empty line is unintentional remove it -help: if the doc comment should not document `first_in_module` comment it out - | -LL - /** -LL + /* +help: if the comment should document the parent module use an inner doc comment | +LL | /*! + | ~ error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:87:5 + --> tests/ui/empty_line_after/doc_comments.rs:85:5 | LL | / /** LL | | * Docs for `old_code` LL | | */ -... | +LL | | /* fn old_code() {} */ LL | | | |_^ ... @@ -171,10 +155,9 @@ LL + /* | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:98:5 + --> tests/ui/empty_line_after/doc_comments.rs:96:5 | LL | / /// Docs for `old_code2` -LL | | LL | | /* fn old_code2() {} */ LL | | | |_^ diff --git a/tests/ui/mixed_attributes_style/auxiliary/submodule.rs b/tests/ui/mixed_attributes_style/auxiliary/submodule.rs index 61615c5d3a64..43d22940415f 100644 --- a/tests/ui/mixed_attributes_style/auxiliary/submodule.rs +++ b/tests/ui/mixed_attributes_style/auxiliary/submodule.rs @@ -3,8 +3,6 @@ #![allow(dead_code)] #[allow(unused)] -//~^ mixed_attributes_style - mod foo { #![allow(dead_code)] } diff --git a/tests/ui/mixed_attributes_style/global_allow.rs b/tests/ui/mixed_attributes_style/global_allow.rs index c68a5462afea..19a45e720a60 100644 --- a/tests/ui/mixed_attributes_style/global_allow.rs +++ b/tests/ui/mixed_attributes_style/global_allow.rs @@ -1,6 +1,5 @@ -//@error-in-other-file: -//@no-rustfix -// issue 12436 +// https://github.com/rust-lang/rust-clippy/issues/12436 +//@check-pass #![allow(clippy::mixed_attributes_style)] #[path = "auxiliary/submodule.rs"] diff --git a/tests/ui/mixed_attributes_style/global_allow.stderr b/tests/ui/mixed_attributes_style/global_allow.stderr deleted file mode 100644 index 5fc1d2ac0c3e..000000000000 --- a/tests/ui/mixed_attributes_style/global_allow.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: empty line after outer attribute - --> tests/ui/mixed_attributes_style/auxiliary/submodule.rs:5:1 - | -LL | / #[allow(unused)] -LL | | -LL | | - | |_^ -LL | mod foo { - | ------- the attribute applies to this module - | - = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]` - = help: if the empty line is unintentional remove it -help: if the attribute should apply to the parent module use an inner attribute - | -LL | #![allow(unused)] - | + - -error: aborting due to 1 previous error - diff --git a/tests/ui/mixed_attributes_style/mod_declaration.rs b/tests/ui/mixed_attributes_style/mod_declaration.rs index f2aad9a21e99..8cef6a80048a 100644 --- a/tests/ui/mixed_attributes_style/mod_declaration.rs +++ b/tests/ui/mixed_attributes_style/mod_declaration.rs @@ -1,4 +1,3 @@ -//@error-in-other-file: empty line after outer attribute //@error-in-other-file: item has both inner and outer attributes //@no-rustfix #[path = "auxiliary/submodule.rs"] // don't lint. diff --git a/tests/ui/mixed_attributes_style/mod_declaration.stderr b/tests/ui/mixed_attributes_style/mod_declaration.stderr index 13ec97fbc1af..1239742a05b7 100644 --- a/tests/ui/mixed_attributes_style/mod_declaration.stderr +++ b/tests/ui/mixed_attributes_style/mod_declaration.stderr @@ -2,8 +2,6 @@ error: item has both inner and outer attributes --> tests/ui/mixed_attributes_style/auxiliary/submodule.rs:5:1 | LL | / #[allow(unused)] -LL | | -LL | | LL | | mod foo { LL | | #![allow(dead_code)] | |________________________^ @@ -11,23 +9,5 @@ LL | | #![allow(dead_code)] = note: `-D clippy::mixed-attributes-style` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::mixed_attributes_style)]` -error: empty line after outer attribute - --> tests/ui/mixed_attributes_style/auxiliary/submodule.rs:5:1 - | -LL | / #[allow(unused)] -LL | | -LL | | - | |_^ -LL | mod foo { - | ------- the attribute applies to this module - | - = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]` - = help: if the empty line is unintentional remove it -help: if the attribute should apply to the parent module use an inner attribute - | -LL | #![allow(unused)] - | + - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/suspicious_else_formatting.rs b/tests/ui/suspicious_else_formatting.rs index 7e57684bd437..28a3b551116d 100644 --- a/tests/ui/suspicious_else_formatting.rs +++ b/tests/ui/suspicious_else_formatting.rs @@ -99,10 +99,11 @@ fn main() { // Almost Allman style braces. Lint these. if foo() { } + else { - } + //~^^^^^ suspicious_else_formatting if foo() { } diff --git a/tests/ui/suspicious_else_formatting.stderr b/tests/ui/suspicious_else_formatting.stderr index cf2788b67d07..affd20b22d9c 100644 --- a/tests/ui/suspicious_else_formatting.stderr +++ b/tests/ui/suspicious_else_formatting.stderr @@ -64,7 +64,19 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else {..}` but the formatting might hide it - --> tests/ui/suspicious_else_formatting.rs:108:6 + --> tests/ui/suspicious_else_formatting.rs:101:6 + | +LL | } + | ______^ +LL | | +LL | | else +LL | | { + | |____^ + | + = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` + +error: this is an `else {..}` but the formatting might hide it + --> tests/ui/suspicious_else_formatting.rs:109:6 | LL | } | ______^ @@ -75,5 +87,5 @@ LL | | { | = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors diff --git a/tests/ui/unneeded_struct_pattern.fixed b/tests/ui/unneeded_struct_pattern.fixed index 1fcaa29c51f0..665ab98913be 100644 --- a/tests/ui/unneeded_struct_pattern.fixed +++ b/tests/ui/unneeded_struct_pattern.fixed @@ -2,8 +2,7 @@ #![allow( clippy::manual_unwrap_or_default, clippy::manual_unwrap_or, - clippy::redundant_pattern_matching, - clippy::no_effect + clippy::redundant_pattern_matching )] #![warn(clippy::unneeded_struct_pattern)] @@ -65,19 +64,30 @@ fn main() { match Custom::Init { Custom::HasFields { field: value } => value, Custom::HasBracketsNoFields {} => 0, + Custom::NoBrackets => 0, //~ unneeded_struct_pattern + Custom::NoBracketsNonExhaustive => 0, //~ unneeded_struct_pattern _ => 0, }; match Custom::Init { Custom::HasFields { field: value } => value, Custom::HasBracketsNoFields { .. } => 0, + Custom::NoBrackets => 0, //~ unneeded_struct_pattern + Custom::NoBracketsNonExhaustive => 0, //~ unneeded_struct_pattern _ => 0, }; - 0; - //~^^^ match_single_binding + match Custom::Init { + Custom::NoBrackets if true => 0, //~ unneeded_struct_pattern + _ => 0, + }; - 0; + match Custom::Init { + Custom::NoBrackets | Custom::NoBracketsNonExhaustive => 0, + //~^ unneeded_struct_pattern + //~| unneeded_struct_pattern + _ => 0, + }; if let Custom::HasFields { field: value } = Custom::Init { noop(); @@ -121,6 +131,7 @@ fn main() { let Custom::HasBracketsNoFields { .. } = Custom::Init else { panic!() }; + let Custom::NoBrackets = Custom::Init else { panic!() }; //~ unneeded_struct_pattern let Custom::NoBrackets = Custom::Init else { //~^ unneeded_struct_pattern @@ -138,6 +149,12 @@ fn main() { enum Refutable { Variant, } + + fn pat_in_fn_param_1(Refutable::Variant: Refutable) {} //~ unneeded_struct_pattern + fn pat_in_fn_param_2(Refutable::Variant: Refutable) {} //~ unneeded_struct_pattern + + for Refutable::Variant in [] {} //~ unneeded_struct_pattern + for Refutable::Variant in [] {} //~ unneeded_struct_pattern } fn external_crate() { @@ -149,9 +166,17 @@ fn external_crate() { _ => 0, }; - 0; + match ExhaustiveUnit { + // Exhaustive variant + ExhaustiveUnit => 0, //~ unneeded_struct_pattern + _ => 0, + }; - 0; + match ExhaustiveUnit { + // Exhaustive variant + ExhaustiveUnit => 0, //~ unneeded_struct_pattern + _ => 0, + }; match ExhaustiveUnit { ExhaustiveUnit => 0, diff --git a/tests/ui/unneeded_struct_pattern.rs b/tests/ui/unneeded_struct_pattern.rs index e51311afd5f8..7cadb6c7fbb5 100644 --- a/tests/ui/unneeded_struct_pattern.rs +++ b/tests/ui/unneeded_struct_pattern.rs @@ -2,8 +2,7 @@ #![allow( clippy::manual_unwrap_or_default, clippy::manual_unwrap_or, - clippy::redundant_pattern_matching, - clippy::no_effect + clippy::redundant_pattern_matching )] #![warn(clippy::unneeded_struct_pattern)] @@ -65,22 +64,28 @@ fn main() { match Custom::Init { Custom::HasFields { field: value } => value, Custom::HasBracketsNoFields {} => 0, + Custom::NoBrackets {} => 0, //~ unneeded_struct_pattern + Custom::NoBracketsNonExhaustive {} => 0, //~ unneeded_struct_pattern _ => 0, }; match Custom::Init { Custom::HasFields { field: value } => value, Custom::HasBracketsNoFields { .. } => 0, + Custom::NoBrackets { .. } => 0, //~ unneeded_struct_pattern + Custom::NoBracketsNonExhaustive { .. } => 0, //~ unneeded_struct_pattern _ => 0, }; match Custom::Init { + Custom::NoBrackets {} if true => 0, //~ unneeded_struct_pattern _ => 0, }; - //~^^^ match_single_binding match Custom::Init { - //~^ match_single_binding + Custom::NoBrackets {} | Custom::NoBracketsNonExhaustive {} => 0, + //~^ unneeded_struct_pattern + //~| unneeded_struct_pattern _ => 0, }; @@ -126,6 +131,7 @@ fn main() { let Custom::HasBracketsNoFields { .. } = Custom::Init else { panic!() }; + let Custom::NoBrackets {} = Custom::Init else { panic!() }; //~ unneeded_struct_pattern let Custom::NoBrackets { .. } = Custom::Init else { //~^ unneeded_struct_pattern @@ -143,6 +149,12 @@ fn main() { enum Refutable { Variant, } + + fn pat_in_fn_param_1(Refutable::Variant {}: Refutable) {} //~ unneeded_struct_pattern + fn pat_in_fn_param_2(Refutable::Variant { .. }: Refutable) {} //~ unneeded_struct_pattern + + for Refutable::Variant {} in [] {} //~ unneeded_struct_pattern + for Refutable::Variant { .. } in [] {} //~ unneeded_struct_pattern } fn external_crate() { @@ -155,14 +167,14 @@ fn external_crate() { }; match ExhaustiveUnit { - //~^ match_single_binding // Exhaustive variant + ExhaustiveUnit { .. } => 0, //~ unneeded_struct_pattern _ => 0, }; match ExhaustiveUnit { - //~^ match_single_binding // Exhaustive variant + ExhaustiveUnit {} => 0, //~ unneeded_struct_pattern _ => 0, }; diff --git a/tests/ui/unneeded_struct_pattern.stderr b/tests/ui/unneeded_struct_pattern.stderr index 5630795823c4..7c0c3c9e4462 100644 --- a/tests/ui/unneeded_struct_pattern.stderr +++ b/tests/ui/unneeded_struct_pattern.stderr @@ -1,5 +1,5 @@ error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:18:13 + --> tests/ui/unneeded_struct_pattern.rs:17:13 | LL | None {} => 0, | ^^^ help: remove the struct pattern @@ -8,152 +8,196 @@ LL | None {} => 0, = help: to override `-D warnings` add `#[allow(clippy::unneeded_struct_pattern)]` error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:24:13 + --> tests/ui/unneeded_struct_pattern.rs:23:13 | LL | None { .. } => 0, | ^^^^^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:35:18 + --> tests/ui/unneeded_struct_pattern.rs:34:18 | LL | Some(None {}) => 0, | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:37:13 + --> tests/ui/unneeded_struct_pattern.rs:36:13 | LL | None {} => 0, | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:41:16 + --> tests/ui/unneeded_struct_pattern.rs:40:16 | LL | if let None {} = Some(0) {} | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:43:16 + --> tests/ui/unneeded_struct_pattern.rs:42:16 | LL | if let None { .. } = Some(0) {} | ^^^^^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:45:21 + --> tests/ui/unneeded_struct_pattern.rs:44:21 | LL | if let Some(None {}) = Some(Some(0)) {} | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:47:13 + --> tests/ui/unneeded_struct_pattern.rs:46:13 | LL | let None {} = Some(0) else { panic!() }; | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:49:13 + --> tests/ui/unneeded_struct_pattern.rs:48:13 | LL | let None { .. } = Some(0) else { panic!() }; | ^^^^^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:51:18 + --> tests/ui/unneeded_struct_pattern.rs:50:18 | LL | let Some(None {}) = Some(Some(0)) else { panic!() }; | ^^^ help: remove the struct pattern -error: this match could be replaced by its body itself - --> tests/ui/unneeded_struct_pattern.rs:77:5 +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:67:27 | -LL | / match Custom::Init { -LL | | _ => 0, -LL | | }; - | |_____^ help: consider using the match body instead: `0` +LL | Custom::NoBrackets {} => 0, + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:68:40 + | +LL | Custom::NoBracketsNonExhaustive {} => 0, + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:75:27 | - = note: `-D clippy::match-single-binding` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::match_single_binding)]` +LL | Custom::NoBrackets { .. } => 0, + | ^^^^^^^ help: remove the struct pattern -error: this match could be replaced by its body itself - --> tests/ui/unneeded_struct_pattern.rs:82:5 +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:76:40 + | +LL | Custom::NoBracketsNonExhaustive { .. } => 0, + | ^^^^^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:81:27 + | +LL | Custom::NoBrackets {} if true => 0, + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:86:27 + | +LL | Custom::NoBrackets {} | Custom::NoBracketsNonExhaustive {} => 0, + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:86:64 | -LL | / match Custom::Init { -LL | | -LL | | _ => 0, -LL | | }; - | |_____^ help: consider using the match body instead: `0` +LL | Custom::NoBrackets {} | Custom::NoBracketsNonExhaustive {} => 0, + | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:96:30 + --> tests/ui/unneeded_struct_pattern.rs:101:30 | LL | if let Custom::NoBrackets {} = Custom::Init { | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:100:30 + --> tests/ui/unneeded_struct_pattern.rs:105:30 | LL | if let Custom::NoBrackets { .. } = Custom::Init { | ^^^^^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:104:30 + --> tests/ui/unneeded_struct_pattern.rs:109:30 | LL | if let Custom::NoBrackets {} | Custom::NoBracketsNonExhaustive {} = Custom::Init { | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:104:67 + --> tests/ui/unneeded_struct_pattern.rs:109:67 | LL | if let Custom::NoBrackets {} | Custom::NoBracketsNonExhaustive {} = Custom::Init { | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:109:43 + --> tests/ui/unneeded_struct_pattern.rs:114:43 | LL | if let Custom::NoBracketsNonExhaustive {} = Custom::Init { | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:113:43 + --> tests/ui/unneeded_struct_pattern.rs:118:43 | LL | if let Custom::NoBracketsNonExhaustive { .. } = Custom::Init { | ^^^^^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:130:27 + --> tests/ui/unneeded_struct_pattern.rs:134:27 + | +LL | let Custom::NoBrackets {} = Custom::Init else { panic!() }; + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:136:27 | LL | let Custom::NoBrackets { .. } = Custom::Init else { | ^^^^^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:134:40 + --> tests/ui/unneeded_struct_pattern.rs:140:40 | LL | let Custom::NoBracketsNonExhaustive {} = Custom::Init else { | ^^^ help: remove the struct pattern error: struct pattern is not needed for a unit variant - --> tests/ui/unneeded_struct_pattern.rs:138:40 + --> tests/ui/unneeded_struct_pattern.rs:144:40 | LL | let Custom::NoBracketsNonExhaustive { .. } = Custom::Init else { | ^^^^^^^ help: remove the struct pattern -error: this match could be replaced by its body itself - --> tests/ui/unneeded_struct_pattern.rs:157:5 +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:153:44 + | +LL | fn pat_in_fn_param_1(Refutable::Variant {}: Refutable) {} + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:154:44 + | +LL | fn pat_in_fn_param_2(Refutable::Variant { .. }: Refutable) {} + | ^^^^^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:156:27 | -LL | / match ExhaustiveUnit { -LL | | -LL | | // Exhaustive variant -LL | | _ => 0, -LL | | }; - | |_____^ help: consider using the match body instead: `0` +LL | for Refutable::Variant {} in [] {} + | ^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:157:27 + | +LL | for Refutable::Variant { .. } in [] {} + | ^^^^^^^ help: remove the struct pattern -error: this match could be replaced by its body itself - --> tests/ui/unneeded_struct_pattern.rs:163:5 +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:171:23 + | +LL | ExhaustiveUnit { .. } => 0, + | ^^^^^^^ help: remove the struct pattern + +error: struct pattern is not needed for a unit variant + --> tests/ui/unneeded_struct_pattern.rs:177:23 | -LL | / match ExhaustiveUnit { -LL | | -LL | | // Exhaustive variant -LL | | _ => 0, -LL | | }; - | |_____^ help: consider using the match body instead: `0` +LL | ExhaustiveUnit {} => 0, + | ^^^ help: remove the struct pattern -error: aborting due to 23 previous errors +error: aborting due to 33 previous errors