Skip to content

Commit

Permalink
add tests for spurious failure and fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann committed Feb 7, 2025
1 parent 6914ef3 commit a96c556
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 21 deletions.
17 changes: 17 additions & 0 deletions src/tools/clippy/tests/ui/doc/unbalanced_ticks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,20 @@ fn escape_3() {}

/// Backslashes ` \` within code blocks don't count.
fn escape_4() {}

trait Foo {
fn bar();
}

struct Bar;
impl Foo for Bar {
// NOTE: false positive
/// Returns an `Option<Month>` from a i64, assuming a 1-index, January = 1.
///
/// `Month::from_i64(n: i64)`: | `1` | `2` | ... | `12`
/// ---------------------------| -------------------- | --------------------- | ... | -----
/// ``: | Some(Month::January) | Some(Month::February) | ... |
/// Some(Month::December)
fn bar() {}
}
27 changes: 26 additions & 1 deletion src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
error: empty line after doc comment
--> tests/ui/doc/unbalanced_ticks.rs:82:5
|
LL | / /// Some(Month::December)
LL | |
| |_^
LL | fn bar() {}
| ------ 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

error: backticks are unbalanced
--> tests/ui/doc/unbalanced_ticks.rs:7:5
|
Expand Down Expand Up @@ -94,5 +107,17 @@ 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
error: backticks are unbalanced
--> tests/ui/doc/unbalanced_ticks.rs:79:9
|
LL | /// `Month::from_i64(n: i64)`: | `1` | `2` | ... | `12`
| _________^
LL | | /// ---------------------------| -------------------- | --------------------- | ... | -----
LL | | /// ``: | Some(Month::January) | Some(Month::February) | ... |
LL | | /// Some(Month::December)
| |_____________________________^
|
= help: a backtick may be missing a pair

error: aborting due to 12 previous errors

22 changes: 11 additions & 11 deletions src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 empty line is unintentional, remove it
help: if the comment should document the crate use an inner doc comment
|
LL ~ //! Meant to be an
Expand All @@ -26,7 +26,7 @@ LL | |
LL | fn first_in_module() {}
| ------------------ the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it
help: if the comment should document the parent module use an inner doc comment
|
LL ~ //! Meant to be an
Expand All @@ -44,7 +44,7 @@ LL | /// Blank line
LL | fn indented() {}
| ----------- the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it
help: if the documentation should include the empty line include it in the comment
|
LL | ///
Expand All @@ -59,7 +59,7 @@ LL | |
LL | fn with_doc_and_newline() {}
| ----------------------- the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty lines after doc comment
--> tests/ui/empty_line_after/doc_comments.rs:44:1
Expand All @@ -74,7 +74,7 @@ LL | |
LL | fn three_attributes() {}
| ------------------- the comment documents this function
|
= help: if the empty lines are unintentional remove them
= help: if the empty lines are unintentional, remove them

error: empty line after doc comment
--> tests/ui/empty_line_after/doc_comments.rs:56:5
Expand All @@ -86,7 +86,7 @@ LL | |
LL | fn new_code() {}
| ----------- the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it
help: if the doc comment should not document `new_code` comment it out
|
LL | // /// docs for `old_code`
Expand All @@ -106,7 +106,7 @@ LL | |
LL | struct Multiple;
| --------------- the comment documents this struct
|
= help: if the empty lines are unintentional remove them
= help: if the empty lines are unintentional, remove them
help: if the doc comment should not document `Multiple` comment it out
|
LL ~ // /// Docs
Expand All @@ -128,7 +128,7 @@ LL | |
LL | fn first_in_module() {}
| ------------------ the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it
help: if the comment should document the parent module use an inner doc comment
|
LL | /*!
Expand All @@ -147,7 +147,7 @@ LL | |
LL | fn new_code() {}
| ----------- the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it
help: if the doc comment should not document `new_code` comment it out
|
LL - /**
Expand All @@ -165,7 +165,7 @@ LL | /// Docs for `new_code2`
LL | fn new_code2() {}
| ------------ the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it
help: if the doc comment should not document `new_code2` comment it out
|
LL | // /// Docs for `old_code2`
Expand All @@ -180,7 +180,7 @@ LL | |
LL | fn bar() {}
| ------ the comment documents this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: aborting due to 11 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | fn first_in_crate() {}
|
= 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 empty line is unintentional, remove it
help: if the attribute should apply to the crate use an inner attribute
|
LL | #![crate_type = "lib"]
Expand All @@ -25,7 +25,7 @@ LL | /// some comment
LL | fn with_one_newline_and_comment() {}
| ------------------------------- the attribute applies to this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty line after outer attribute
--> tests/ui/empty_line_after/outer_attribute.rs:23:1
Expand All @@ -36,7 +36,7 @@ LL | |
LL | fn with_one_newline() {}
| ------------------- the attribute applies to this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty lines after outer attribute
--> tests/ui/empty_line_after/outer_attribute.rs:30:5
Expand All @@ -48,7 +48,7 @@ LL | |
LL | fn with_two_newlines() {}
| -------------------- the attribute applies to this function
|
= help: if the empty lines are unintentional remove them
= help: if the empty lines are unintentional, remove them
help: if the attribute should apply to the parent module use an inner attribute
|
LL | #![crate_type = "lib"]
Expand All @@ -63,7 +63,7 @@ LL | |
LL | enum Baz {
| -------- the attribute applies to this enum
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty line after outer attribute
--> tests/ui/empty_line_after/outer_attribute.rs:45:1
Expand All @@ -74,7 +74,7 @@ LL | |
LL | struct Foo {
| ---------- the attribute applies to this struct
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty line after outer attribute
--> tests/ui/empty_line_after/outer_attribute.rs:53:1
Expand All @@ -85,7 +85,7 @@ LL | |
LL | mod foo {}
| ------- the attribute applies to this module
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty line after outer attribute
--> tests/ui/empty_line_after/outer_attribute.rs:58:1
Expand All @@ -97,7 +97,7 @@ LL | |
LL | fn comment_before_empty_line() {}
| ---------------------------- the attribute applies to this function
|
= help: if the empty line is unintentional remove it
= help: if the empty line is unintentional, remove it

error: empty lines after outer attribute
--> tests/ui/empty_line_after/outer_attribute.rs:64:1
Expand All @@ -109,7 +109,7 @@ LL | |
LL | pub fn isolated_comment() {}
| ----------------------- the attribute applies to this function
|
= help: if the empty lines are unintentional remove them
= help: if the empty lines are unintentional, remove them

error: aborting due to 9 previous errors

0 comments on commit a96c556

Please sign in to comment.