-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4729 - rust-lang:needless-doc-main-syn, r=<try>
Use syn in needless_doctest_main lint changelog: none This fixes #4698 by only linting non-empty `fn main()`s. This is not a perfect solution, but I don't want to omit linting if any macro call or attribute is detected, as that would result in many false negatives.
- Loading branch information
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/// This method does nothing. It's just there for testing. | ||
/// | ||
/// # Examples: | ||
/// | ||
/// ```text,ignore | ||
/// This is not Rust code | ||
/// Just check that parsing won't crash | ||
/// R€fridger@tør. | ||
/// ``` | ||
/// | ||
/// ``` | ||
/// fn main() { | ||
/// let this_is_linted = 42u8; | ||
/// assert_eq!(this_is_linted / 2, 21); | ||
/// } | ||
/// ``` | ||
/// | ||
/// ``` | ||
/// #[allow(unused)] | ||
/// const I = 1; | ||
/// fn main() { | ||
/// // this main method contains no code and is thus not linted. | ||
/// } | ||
/// ``` | ||
fn main() { | ||
// nothing to see here, move along. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: needless `fn main() {}` in doctest | ||
--> $DIR/needless_doc_main.rs:12:4 | ||
| | ||
LL | /// fn main() { | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::needless-doctest-main` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
|