Skip to content

Commit 6b68893

Browse files
committed
fix(diag): Make unused dep text more consistent
1 parent 1152700 commit 6b68893

5 files changed

Lines changed: 39 additions & 36 deletions

File tree

src/cargo/diagnostics/rules/unused_dependencies.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ pub(crate) fn lint_package(
149149
primary = primary.element(Level::NOTE.message(emitted_source));
150150
}
151151
let mut report = vec![primary];
152-
let mut help = Group::with_title(Level::HELP.secondary_title("remove the dependency"));
152+
let mut help = Group::with_title(
153+
Level::HELP.secondary_title("consider removing the unused dependency"),
154+
);
153155
if let Some(document) = document
154156
&& let Some(contents) = contents
155157
&& let Some(span) = get_key_value_span(document, &["build-dependencies", dep_name])
@@ -335,8 +337,9 @@ fn lint_package_build_results(
335337
}
336338
lint_count += 1;
337339
let mut report = vec![primary];
338-
let mut help =
339-
Group::with_title(Level::HELP.secondary_title("remove the dependency"));
340+
let mut help = Group::with_title(
341+
Level::HELP.secondary_title("consider removing the unused dependency"),
342+
);
340343
if let Some(document) = document
341344
&& let Some(contents) = contents
342345
&& let Some(span) = get_key_value_span(document, &toml_path)

src/cargo/diagnostics/rules/unused_workspace_dependencies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub(crate) fn lint_workspace(
151151
}
152152
let mut report = vec![primary];
153153
let mut help = Group::with_title(
154-
Level::HELP.secondary_title("consider removing the unused dependency"),
154+
Level::HELP.secondary_title("consider removing the unused workspace dependency"),
155155
);
156156
if let Some(document) = document
157157
&& let Some(contents) = contents

tests/testsuite/lints/unused_dependencies.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn unused_dep_normal() {
5050
| ^^^^^^^^^^^^^^^^
5151
|
5252
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
53-
[HELP] remove the dependency
53+
[HELP] consider removing the unused dependency
5454
|
5555
9 - unused = "0.1.0"
5656
|
@@ -112,7 +112,7 @@ fn unused_dep_build() {
112112
| ^^^^^^^^^^^^^^^^
113113
|
114114
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
115-
[HELP] remove the dependency
115+
[HELP] consider removing the unused dependency
116116
|
117117
9 - unused = "0.1.0"
118118
|
@@ -162,7 +162,7 @@ fn unused_dep_build_no_build_rs() {
162162
| ^^^^^^^^^^^^^^^^
163163
|
164164
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
165-
[HELP] remove the dependency
165+
[HELP] consider removing the unused dependency
166166
|
167167
9 - unused = "0.1.0"
168168
|
@@ -249,7 +249,7 @@ fn unused_dep_lib_bins() {
249249
| ^^^^^^^^^^^^^^^^
250250
|
251251
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
252-
[HELP] remove the dependency
252+
[HELP] consider removing the unused dependency
253253
|
254254
9 - unused = "0.1.0"
255255
|
@@ -342,7 +342,7 @@ fn unused_dep_build_with_used_dep_normal() {
342342
| ^^^^^^^^^^^^^^^^^^^^^^
343343
|
344344
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
345-
[HELP] remove the dependency
345+
[HELP] consider removing the unused dependency
346346
|
347347
9 - unused_build = "0.1.0"
348348
|
@@ -407,7 +407,7 @@ fn unused_dep_normal_but_implicit_used_dep_dev() {
407407
| ^^^^^^^^^^^^^^^^^^
408408
|
409409
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
410-
[HELP] remove the dependency
410+
[HELP] consider removing the unused dependency
411411
|
412412
9 - used_dev = "0.1.0"
413413
|
@@ -428,7 +428,7 @@ fn unused_dep_normal_but_implicit_used_dep_dev() {
428428
| ^^^^^^^^^^^^^^^^^^
429429
|
430430
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
431-
[HELP] remove the dependency
431+
[HELP] consider removing the unused dependency
432432
|
433433
9 - used_dev = "0.1.0"
434434
|
@@ -497,7 +497,7 @@ fn unused_dep_normal_but_explicit_used_dep_dev() {
497497
| ^^^^^^^^^^^^^^^^^^^
498498
|
499499
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
500-
[HELP] remove the dependency
500+
[HELP] consider removing the unused dependency
501501
|
502502
9 - used_once = "0.1.0"
503503
|
@@ -631,7 +631,7 @@ fn optional_dependency() {
631631
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
632632
|
633633
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
634-
[HELP] remove the dependency
634+
[HELP] consider removing the unused dependency
635635
|
636636
9 - unused = { version = "0.1.0", optional = true }
637637
|
@@ -696,7 +696,7 @@ fn unused_dep_renamed() {
696696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
697697
|
698698
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
699-
[HELP] remove the dependency
699+
[HELP] consider removing the unused dependency
700700
|
701701
9 - baz = { package = "bar", version = "0.1.0" }
702702
|
@@ -754,7 +754,7 @@ fn warning_replay() {
754754
| ^^^^^^^^^^^^^^^^
755755
|
756756
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
757-
[HELP] remove the dependency
757+
[HELP] consider removing the unused dependency
758758
|
759759
9 - unused = "0.1.0"
760760
|
@@ -774,7 +774,7 @@ fn warning_replay() {
774774
| ^^^^^^^^^^^^^^^^
775775
|
776776
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
777-
[HELP] remove the dependency
777+
[HELP] consider removing the unused dependency
778778
|
779779
9 - unused = "0.1.0"
780780
|
@@ -841,7 +841,7 @@ fn unused_dep_target() {
841841
| ^^^^^^^^^^^^^^^^
842842
|
843843
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
844-
[HELP] remove the dependency
844+
[HELP] consider removing the unused dependency
845845
|
846846
9 - unused = "0.1.0"
847847
|
@@ -1132,7 +1132,7 @@ fn package_selection() {
11321132
| ^^^^^^^^^^^^^^^^^^^^
11331133
|
11341134
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1135-
[HELP] remove the dependency
1135+
[HELP] consider removing the unused dependency
11361136
|
11371137
9 - unused_bar = "0.1.0"
11381138
|
@@ -1143,7 +1143,7 @@ fn package_selection() {
11431143
| ^^^
11441144
|
11451145
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1146-
[HELP] remove the dependency
1146+
[HELP] consider removing the unused dependency
11471147
|
11481148
11 - bar.path = "../bar"
11491149
11 + .path = "../bar"
@@ -1154,7 +1154,7 @@ fn package_selection() {
11541154
12 | external.path = "../external"
11551155
| ^^^^^^^^
11561156
|
1157-
[HELP] remove the dependency
1157+
[HELP] consider removing the unused dependency
11581158
|
11591159
12 - external.path = "../external"
11601160
12 + .path = "../external"
@@ -1165,7 +1165,7 @@ fn package_selection() {
11651165
9 | unused_foo = "0.1.0"
11661166
| ^^^^^^^^^^^^^^^^^^^^
11671167
|
1168-
[HELP] remove the dependency
1168+
[HELP] consider removing the unused dependency
11691169
|
11701170
9 - unused_foo = "0.1.0"
11711171
|
@@ -1189,7 +1189,7 @@ fn package_selection() {
11891189
| ^^^
11901190
|
11911191
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1192-
[HELP] remove the dependency
1192+
[HELP] consider removing the unused dependency
11931193
|
11941194
11 - bar.path = "../bar"
11951195
11 + .path = "../bar"
@@ -1200,7 +1200,7 @@ fn package_selection() {
12001200
12 | external.path = "../external"
12011201
| ^^^^^^^^
12021202
|
1203-
[HELP] remove the dependency
1203+
[HELP] consider removing the unused dependency
12041204
|
12051205
12 - external.path = "../external"
12061206
12 + .path = "../external"
@@ -1211,7 +1211,7 @@ fn package_selection() {
12111211
9 | unused_foo = "0.1.0"
12121212
| ^^^^^^^^^^^^^^^^^^^^
12131213
|
1214-
[HELP] remove the dependency
1214+
[HELP] consider removing the unused dependency
12151215
|
12161216
9 - unused_foo = "0.1.0"
12171217
|
@@ -1234,7 +1234,7 @@ fn package_selection() {
12341234
| ^^^^^^^^^^^^^^^^^^^^
12351235
|
12361236
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1237-
[HELP] remove the dependency
1237+
[HELP] consider removing the unused dependency
12381238
|
12391239
9 - unused_bar = "0.1.0"
12401240
|
@@ -1431,7 +1431,7 @@ fn allow_rustflags() {
14311431
| ^^^^^^^^^^^^^^^^
14321432
|
14331433
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1434-
[HELP] remove the dependency
1434+
[HELP] consider removing the unused dependency
14351435
|
14361436
9 - unused = "0.1.0"
14371437
|
@@ -1489,7 +1489,7 @@ fn allow_attribute() {
14891489
| ^^^^^^^^^^^^^^^^
14901490
|
14911491
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1492-
[HELP] remove the dependency
1492+
[HELP] consider removing the unused dependency
14931493
|
14941494
9 - unused = "0.1.0"
14951495
|
@@ -1546,7 +1546,7 @@ fn deny_in_manifest() {
15461546
| ^^^^^^^^^^^^^^^^
15471547
|
15481548
= [NOTE] `cargo::unused_dependencies` is set to `deny` in `[lints]`
1549-
[HELP] remove the dependency
1549+
[HELP] consider removing the unused dependency
15501550
|
15511551
9 - unused = "0.1.0"
15521552
|
@@ -1603,7 +1603,7 @@ fn deny_rustflags() {
16031603
| ^^^^^^^^^^^^^^^^
16041604
|
16051605
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1606-
[HELP] remove the dependency
1606+
[HELP] consider removing the unused dependency
16071607
|
16081608
9 - unused = "0.1.0"
16091609
|
@@ -1661,7 +1661,7 @@ fn deny_attribute() {
16611661
| ^^^^^^^^^^^^^^^^
16621662
|
16631663
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1664-
[HELP] remove the dependency
1664+
[HELP] consider removing the unused dependency
16651665
|
16661666
9 - unused = "0.1.0"
16671667
|
@@ -1719,7 +1719,7 @@ fn forbid_rustflags() {
17191719
| ^^^^^^^^^^^^^^^^
17201720
|
17211721
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1722-
[HELP] remove the dependency
1722+
[HELP] consider removing the unused dependency
17231723
|
17241724
9 - unused = "0.1.0"
17251725
|
@@ -1777,7 +1777,7 @@ fn forbid_attribute() {
17771777
| ^^^^^^^^^^^^^^^^
17781778
|
17791779
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
1780-
[HELP] remove the dependency
1780+
[HELP] consider removing the unused dependency
17811781
|
17821782
9 - unused = "0.1.0"
17831783
|

tests/testsuite/lints/unused_workspace_dependencies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ workspace = true
8686
| ^^^^^^^^^^^^^
8787
|
8888
= [NOTE] `cargo::unused_workspace_dependencies` is set to `warn` in `[lints]`
89-
[HELP] consider removing the unused dependency
89+
[HELP] consider removing the unused workspace dependency
9090
|
9191
12 - not-inherited = "1"
9292
|
@@ -96,7 +96,7 @@ workspace = true
9696
11 | unused = "1"
9797
| ^^^^^^
9898
|
99-
[HELP] consider removing the unused dependency
99+
[HELP] consider removing the unused workspace dependency
100100
|
101101
11 - unused = "1"
102102
|

tests/testsuite/warning_override.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ fn lint_build_result_pass() {
412412
| ^^^^^^^^^^^^^^^^
413413
|
414414
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
415-
[HELP] remove the dependency
415+
[HELP] consider removing the unused dependency
416416
|
417417
9 - unused = "0.1.0"
418418
|
@@ -445,7 +445,7 @@ fn lint_build_result_pass() {
445445
| ^^^^^^^^^^^^^^^^
446446
|
447447
= [NOTE] `cargo::unused_dependencies` is set to `warn` in `[lints]`
448-
[HELP] remove the dependency
448+
[HELP] consider removing the unused dependency
449449
|
450450
9 - unused = "0.1.0"
451451
|

0 commit comments

Comments
 (0)