Skip to content

Commit 4227411

Browse files
committed
Generate deprecated lints test
1 parent 85b88be commit 4227411

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

clippy_dev/src/update_lints.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ pub fn run(update_mode: UpdateMode) {
107107
&content,
108108
);
109109
}
110+
111+
let content = gen_deprecated_lints_test(&deprecated_lints);
112+
process_file("tests/ui/deprecated.rs", update_mode, &content);
110113
}
111114

112115
pub fn print_lints() {
@@ -276,6 +279,15 @@ fn gen_register_lint_list<'a>(
276279
output
277280
}
278281

282+
fn gen_deprecated_lints_test(lints: &[DeprecatedLint]) -> String {
283+
let mut res: String = GENERATED_FILE_COMMENT.into();
284+
for lint in lints {
285+
writeln!(res, "#![warn(clippy::{})]", lint.name).unwrap();
286+
}
287+
res.push_str("\nfn main() {}\n");
288+
res
289+
}
290+
279291
/// Gathers all lints defined in `clippy_lints/src`
280292
fn gather_all() -> (Vec<Lint>, Vec<DeprecatedLint>) {
281293
let mut lints = Vec::with_capacity(1000);

tests/ui/deprecated.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This file was generated by `cargo dev update_lints`.
2+
// Use that command to update this file and do not edit by hand.
3+
// Manual edits will be overwritten.
4+
15
#![warn(clippy::should_assert_eq)]
26
#![warn(clippy::extend_from_slice)]
37
#![warn(clippy::range_step_by_zero)]

tests/ui/deprecated.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
11
error: lint `clippy::should_assert_eq` has been removed: `assert!()` will be more flexible with RFC 2011
2-
--> $DIR/deprecated.rs:1:9
2+
--> $DIR/deprecated.rs:5:9
33
|
44
LL | #![warn(clippy::should_assert_eq)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
88

99
error: lint `clippy::extend_from_slice` has been removed: `.extend_from_slice(_)` is a faster way to extend a Vec by a slice
10-
--> $DIR/deprecated.rs:2:9
10+
--> $DIR/deprecated.rs:6:9
1111
|
1212
LL | #![warn(clippy::extend_from_slice)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: lint `clippy::range_step_by_zero` has been removed: `iterator.step_by(0)` panics nowadays
16-
--> $DIR/deprecated.rs:3:9
16+
--> $DIR/deprecated.rs:7:9
1717
|
1818
LL | #![warn(clippy::range_step_by_zero)]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
error: lint `clippy::unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7
22-
--> $DIR/deprecated.rs:4:9
22+
--> $DIR/deprecated.rs:8:9
2323
|
2424
LL | #![warn(clippy::unstable_as_slice)]
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2626

2727
error: lint `clippy::unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7
28-
--> $DIR/deprecated.rs:5:9
28+
--> $DIR/deprecated.rs:9:9
2929
|
3030
LL | #![warn(clippy::unstable_as_mut_slice)]
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232

3333
error: lint `clippy::misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr
34-
--> $DIR/deprecated.rs:6:9
34+
--> $DIR/deprecated.rs:10:9
3535
|
3636
LL | #![warn(clippy::misaligned_transmute)]
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3838

3939
error: lint `clippy::assign_ops` has been removed: using compound assignment operators (e.g., `+=`) is harmless
40-
--> $DIR/deprecated.rs:7:9
40+
--> $DIR/deprecated.rs:11:9
4141
|
4242
LL | #![warn(clippy::assign_ops)]
4343
| ^^^^^^^^^^^^^^^^^^
4444

4545
error: lint `clippy::if_let_redundant_pattern_matching` has been removed: this lint has been changed to redundant_pattern_matching
46-
--> $DIR/deprecated.rs:8:9
46+
--> $DIR/deprecated.rs:12:9
4747
|
4848
LL | #![warn(clippy::if_let_redundant_pattern_matching)]
4949
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5050

5151
error: lint `clippy::unsafe_vector_initialization` has been removed: the replacement suggested by this lint had substantially different behavior
52-
--> $DIR/deprecated.rs:9:9
52+
--> $DIR/deprecated.rs:13:9
5353
|
5454
LL | #![warn(clippy::unsafe_vector_initialization)]
5555
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5656

5757
error: lint `clippy::unused_collect` has been removed: `collect` has been marked as #[must_use] in rustc and that covers all cases of this lint
58-
--> $DIR/deprecated.rs:10:9
58+
--> $DIR/deprecated.rs:14:9
5959
|
6060
LL | #![warn(clippy::unused_collect)]
6161
| ^^^^^^^^^^^^^^^^^^^^^^
6262

6363
error: lint `clippy::replace_consts` has been removed: associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants
64-
--> $DIR/deprecated.rs:11:9
64+
--> $DIR/deprecated.rs:15:9
6565
|
6666
LL | #![warn(clippy::replace_consts)]
6767
| ^^^^^^^^^^^^^^^^^^^^^^
6868

6969
error: lint `clippy::regex_macro` has been removed: the regex! macro has been removed from the regex crate in 2018
70-
--> $DIR/deprecated.rs:12:9
70+
--> $DIR/deprecated.rs:16:9
7171
|
7272
LL | #![warn(clippy::regex_macro)]
7373
| ^^^^^^^^^^^^^^^^^^^
7474

7575
error: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint
76-
--> $DIR/deprecated.rs:13:9
76+
--> $DIR/deprecated.rs:17:9
7777
|
7878
LL | #![warn(clippy::find_map)]
7979
| ^^^^^^^^^^^^^^^^
8080

8181
error: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint
82-
--> $DIR/deprecated.rs:14:9
82+
--> $DIR/deprecated.rs:18:9
8383
|
8484
LL | #![warn(clippy::filter_map)]
8585
| ^^^^^^^^^^^^^^^^^^
8686

8787
error: lint `clippy::pub_enum_variant_names` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items
88-
--> $DIR/deprecated.rs:15:9
88+
--> $DIR/deprecated.rs:19:9
8989
|
9090
LL | #![warn(clippy::pub_enum_variant_names)]
9191
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9292

9393
error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items
94-
--> $DIR/deprecated.rs:16:9
94+
--> $DIR/deprecated.rs:20:9
9595
|
9696
LL | #![warn(clippy::wrong_pub_self_convention)]
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)