Skip to content

Commit b7a1fcb

Browse files
committed
Tweaks: Changes needed to pass cargo test locally
1 parent 16d9fc0 commit b7a1fcb

File tree

9 files changed

+40
-22
lines changed

9 files changed

+40
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6556,6 +6556,7 @@ Released 2018-09-13
65566556
[`source-item-ordering`]: https://doc.rust-lang.org/clippy/lint_configuration.html#source-item-ordering
65576557
[`stack-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#stack-size-threshold
65586558
[`standard-macro-braces`]: https://doc.rust-lang.org/clippy/lint_configuration.html#standard-macro-braces
6559+
[`strict-order-of-use`]: https://doc.rust-lang.org/clippy/lint_configuration.html#strict-order-of-use
65596560
[`struct-field-name-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#struct-field-name-threshold
65606561
[`suppress-restriction-lint-in-const`]: https://doc.rust-lang.org/clippy/lint_configuration.html#suppress-restriction-lint-in-const
65616562
[`too-large-for-stack`]: https://doc.rust-lang.org/clippy/lint_configuration.html#too-large-for-stack

book/src/lint_configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,16 @@ could be used with a full path two `MacroMatcher`s have to be added one with the
957957
* [`nonstandard_macro_braces`](https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces)
958958

959959

960+
## `strict-order-of-use`
961+
Makes the lint strict, use statements must precede mod and extern crate statements too. (Stylistic Choice)
962+
963+
**Default Value:** `false`
964+
965+
---
966+
**Affected lints:**
967+
* [`items_before_use`](https://rust-lang.github.io/rust-clippy/master/index.html#items_before_use)
968+
969+
960970
## `struct-field-name-threshold`
961971
The minimum number of struct fields for the lints about field names to trigger
962972

clippy_config/src/conf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ define_Conf! {
804804
/// `crate_name::macro_name` and one with just the macro name.
805805
#[lints(nonstandard_macro_braces)]
806806
standard_macro_braces: Vec<MacroMatcher> = Vec::new(),
807+
/// Makes the lint strict, use statements must precede mod and extern crate statements too. (Stylistic Choice)
808+
#[lints(items_before_use)]
809+
strict_order_of_use: bool = false,
807810
/// The minimum number of struct fields for the lints about field names to trigger
808811
#[lints(struct_field_names)]
809812
struct_field_name_threshold: u64 = 3,
@@ -856,9 +859,6 @@ define_Conf! {
856859
/// Whether to also emit warnings for unsafe blocks with metavariable expansions in **private** macros.
857860
#[lints(macro_metavars_in_unsafe)]
858861
warn_unsafe_macro_metavars_in_private_macros: bool = false,
859-
/// Makes the lint strict, use statements must precede mod and extern crate statements too. (Stylistic Choice)
860-
#[lints(items_before_use)]
861-
strict_order_of_use: bool = false,
862862
}
863863

864864
/// Search for the configuration file.

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::items_before_use)]
12
use clippy_config::Conf;
23
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
34
use clippy_utils::msrvs::{self, Msrv};

clippy_lints/src/infinite_iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::items_before_use)]
12
use clippy_utils::diagnostics::span_lint;
23
use clippy_utils::ty::{get_type_diagnostic_name, implements_trait};
34
use clippy_utils::{higher, sym};

clippy_lints/src/items_before_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_config::Conf;
22
use clippy_utils::diagnostics::span_lint_and_note;
33
use clippy_utils::sym;
4-
use rustc_hir::*;
4+
use rustc_hir::{HirId, Item, ItemKind, Mod};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::impl_lint_pass;
77

clippy_lints/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
clippy::must_use_candidate,
1818
rustc::diagnostic_outside_of_impl,
1919
rustc::untranslatable_diagnostic,
20-
clippy::literal_string_with_formatting_args
20+
clippy::literal_string_with_formatting_args,
21+
clippy::items_before_use
2122
)]
2223
#![warn(
2324
trivial_casts,

tests/ui/infinite_iter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#![allow(clippy::uninlined_format_args, clippy::double_ended_iterator_last)]
1+
#![allow(
2+
clippy::uninlined_format_args,
3+
clippy::double_ended_iterator_last,
4+
clippy::items_before_use
5+
)]
26

37
use std::iter::repeat;
48
fn square_is_lower_64(x: &u32) -> bool {

tests/ui/infinite_iter.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error: infinite iteration detected
2-
--> tests/ui/infinite_iter.rs:11:5
2+
--> tests/ui/infinite_iter.rs:15:5
33
|
44
LL | repeat(0_u8).collect::<Vec<_>>();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> tests/ui/infinite_iter.rs:9:8
8+
--> tests/ui/infinite_iter.rs:13:8
99
|
1010
LL | #[deny(clippy::infinite_iter)]
1111
| ^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: infinite iteration detected
14-
--> tests/ui/infinite_iter.rs:15:5
14+
--> tests/ui/infinite_iter.rs:19:5
1515
|
1616
LL | (0..8_u32).take_while(square_is_lower_64).cycle().count();
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: infinite iteration detected
20-
--> tests/ui/infinite_iter.rs:19:5
20+
--> tests/ui/infinite_iter.rs:23:5
2121
|
2222
LL | (0..8_u64).chain(0..).max();
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error: infinite iteration detected
26-
--> tests/ui/infinite_iter.rs:28:5
26+
--> tests/ui/infinite_iter.rs:32:5
2727
|
2828
LL | / (0..8_u32)
2929
LL | |
@@ -34,37 +34,37 @@ LL | | .for_each(|x| println!("{}", x));
3434
| |________________________________________^
3535

3636
error: infinite iteration detected
37-
--> tests/ui/infinite_iter.rs:37:5
37+
--> tests/ui/infinite_iter.rs:41:5
3838
|
3939
LL | (0_usize..).flat_map(|x| 0..x).product::<usize>();
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141

4242
error: infinite iteration detected
43-
--> tests/ui/infinite_iter.rs:41:5
43+
--> tests/ui/infinite_iter.rs:45:5
4444
|
4545
LL | (0_u64..).filter(|x| x % 2 == 0).last();
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747

4848
error: possible infinite iteration detected
49-
--> tests/ui/infinite_iter.rs:53:5
49+
--> tests/ui/infinite_iter.rs:57:5
5050
|
5151
LL | (0..).zip((0..).take_while(square_is_lower_64)).count();
5252
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5353
|
5454
note: the lint level is defined here
55-
--> tests/ui/infinite_iter.rs:50:8
55+
--> tests/ui/infinite_iter.rs:54:8
5656
|
5757
LL | #[deny(clippy::maybe_infinite_iter)]
5858
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
5959

6060
error: possible infinite iteration detected
61-
--> tests/ui/infinite_iter.rs:57:5
61+
--> tests/ui/infinite_iter.rs:61:5
6262
|
6363
LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max();
6464
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6565

6666
error: possible infinite iteration detected
67-
--> tests/ui/infinite_iter.rs:61:5
67+
--> tests/ui/infinite_iter.rs:65:5
6868
|
6969
LL | / (1..)
7070
LL | |
@@ -76,31 +76,31 @@ LL | | .min();
7676
| |______________^
7777

7878
error: possible infinite iteration detected
79-
--> tests/ui/infinite_iter.rs:69:5
79+
--> tests/ui/infinite_iter.rs:73:5
8080
|
8181
LL | (0..).find(|x| *x == 24);
8282
| ^^^^^^^^^^^^^^^^^^^^^^^^
8383

8484
error: possible infinite iteration detected
85-
--> tests/ui/infinite_iter.rs:73:5
85+
--> tests/ui/infinite_iter.rs:77:5
8686
|
8787
LL | (0..).position(|x| x == 24);
8888
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
8989

9090
error: possible infinite iteration detected
91-
--> tests/ui/infinite_iter.rs:77:5
91+
--> tests/ui/infinite_iter.rs:81:5
9292
|
9393
LL | (0..).any(|x| x == 24);
9494
| ^^^^^^^^^^^^^^^^^^^^^^
9595

9696
error: possible infinite iteration detected
97-
--> tests/ui/infinite_iter.rs:81:5
97+
--> tests/ui/infinite_iter.rs:85:5
9898
|
9999
LL | (0..).all(|x| x == 24);
100100
| ^^^^^^^^^^^^^^^^^^^^^^
101101

102102
error: infinite iteration detected
103-
--> tests/ui/infinite_iter.rs:107:31
103+
--> tests/ui/infinite_iter.rs:111:31
104104
|
105105
LL | let _: HashSet<i32> = (0..).collect();
106106
| ^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)