ui_test annotation cleanup

This commit is contained in:
Alex Macleod 2025-02-16 15:38:07 +00:00
parent a8b17827c6
commit d03ae8ba6b
24 changed files with 342 additions and 357 deletions

View file

@ -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() {

View file

@ -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")]

View file

@ -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")]
| ^^^^^^^^^^^

View file

@ -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() {}

View file

@ -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,

View file

@ -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

View file

@ -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.

View file

@ -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
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`.
| |____________________________________^
|
= 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
| ++
= 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
LL | /// This paragraph is fine and should_be linted normally.
| ^^^^^^^^^
|
= 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
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
|
LL | // /// `
| ++
= help: a backtick may be missing a pair
error: empty line after doc comment
--> tests/ui/doc/unbalanced_ticks.rs:67:1
error: item in documentation is missing backticks
--> tests/ui/doc/unbalanced_ticks.rs:34:8
|
LL | / /// Escaped \` ` backticks don't count, but unescaped backticks do.
LL | |
LL | |
| |_^
LL | fn escape_3() {}
| ------------- the comment documents this function
LL | /// ## not_fine
| ^^^^^^^^
|
= help: if the empty line is unintentional remove it
help: if the doc comment should not document `escape_3` comment it out
help: try
|
LL | // /// Escaped \` ` backticks don't count, but unescaped backticks do.
| ++
LL | /// ## `not_fine`
| ~~~~~~~~~~
error: aborting due to 5 previous errors
error: backticks are unbalanced
--> tests/ui/doc/unbalanced_ticks.rs:37:5
|
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
|
LL | /// Escaped \` ` backticks don't count, but unescaped backticks do.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: a backtick may be missing a pair
error: aborting due to 10 previous errors

View file

@ -1,5 +1,4 @@
#![warn(clippy::doc_link_with_quotes)]
#![allow(clippy::empty_line_after_doc_comments)]
fn main() {
foo()

View file

@ -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
| ^^^^^

View file

@ -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() {}

View file

@ -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`

View file

@ -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`

View file

@ -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 | |
| |_^

View file

@ -3,8 +3,6 @@
#![allow(dead_code)]
#[allow(unused)]
//~^ mixed_attributes_style
mod foo {
#![allow(dead_code)]
}

View file

@ -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"]

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -99,10 +99,11 @@ fn main() {
// Almost Allman style braces. Lint these.
if foo() {
}
else
{
}
//~^^^^^ suspicious_else_formatting
if foo() {
}

View file

@ -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

View file

@ -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,

View file

@ -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,
};

View file

@ -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`
|
= note: `-D clippy::match-single-binding` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::match_single_binding)]`
error: this match could be replaced by its body itself
--> tests/ui/unneeded_struct_pattern.rs:82:5
|
LL | / match Custom::Init {
LL | |
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:96:30
--> 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
|
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: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 | 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: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 | / match ExhaustiveUnit {
LL | |
LL | | // Exhaustive variant
LL | | _ => 0,
LL | | };
| |_____^ help: consider using the match body instead: `0`
LL | fn pat_in_fn_param_1(Refutable::Variant {}: Refutable) {}
| ^^^ 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:154:44
|
LL | / match ExhaustiveUnit {
LL | |
LL | | // Exhaustive variant
LL | | _ => 0,
LL | | };
| |_____^ help: consider using the match body instead: `0`
LL | fn pat_in_fn_param_2(Refutable::Variant { .. }: Refutable) {}
| ^^^^^^^ help: remove the struct pattern
error: aborting due to 23 previous errors
error: struct pattern is not needed for a unit variant
--> tests/ui/unneeded_struct_pattern.rs:156:27
|
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: 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 | ExhaustiveUnit {} => 0,
| ^^^ help: remove the struct pattern
error: aborting due to 33 previous errors