forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
items_after_test_module
for non root modules, add applicable su…
…ggestion
- Loading branch information
Showing
11 changed files
with
177 additions
and
59 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,11 @@ | ||
//@aux-build:../auxiliary/proc_macros.rs | ||
extern crate proc_macros; | ||
|
||
proc_macros::with_span! { | ||
span | ||
#[cfg(test)] | ||
mod tests {} | ||
} | ||
|
||
#[test] | ||
fn f() {} |
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,4 @@ | ||
#[cfg(test)] | ||
mod tests {} | ||
|
||
fn in_submodule() {} |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
#[path = "auxiliary/submodule.rs"] | ||
mod submodule; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn t() {} | ||
} |
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,14 @@ | ||
error: items after a test module | ||
--> $DIR/auxiliary/submodule.rs:2:1 | ||
| | ||
LL | mod tests {} | ||
| ^^^^^^^^^ | ||
LL | | ||
LL | fn in_submodule() {} | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::items-after-test-module` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` | ||
|
||
error: aborting due to previous error | ||
|
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,11 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn f() {} | ||
} | ||
|
||
#[cfg(test)] | ||
mod more_tests { | ||
#[test] | ||
fn g() {} | ||
} |
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,22 @@ | ||
#![allow(unused)] | ||
#![warn(clippy::items_after_test_module)] | ||
|
||
fn main() {} | ||
|
||
fn should_not_lint() {} | ||
|
||
#[allow(dead_code)] | ||
#[allow(unused)] // Some attributes to check that span replacement is good enough | ||
#[allow(clippy::allow_attributes)] | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn hi() {} | ||
} | ||
|
||
fn should_lint() {} | ||
|
||
const SHOULD_ALSO_LINT: usize = 1; | ||
macro_rules! should_lint { | ||
() => {}; | ||
} |
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,20 @@ | ||
error: items after a test module | ||
--> $DIR/root_module.rs:12:1 | ||
| | ||
LL | mod tests { | ||
| ^^^^^^^^^ | ||
... | ||
LL | fn should_lint() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
LL | | ||
LL | const SHOULD_ALSO_LINT: usize = 1; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | macro_rules! should_lint { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::items-after-test-module` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` | ||
= help: move the items to before the test module was defined | ||
|
||
error: aborting due to previous error | ||
|