Skip to content

Commit 63412be

Browse files
pietroalbiniehuss
authored andcommitted
switch from unused_imports to deprecated to test unfixable warnings
The unused_imports warning is going to emit fixable suggestions in the near future, but that means parts of the cargo's test suite will break. This commit switches the tests to use the deprecated warning, which *shouldn't* be fixable at all.
1 parent 18f7f17 commit 63412be

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

tests/testsuite/fix.rs

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,11 @@ fn fix_features() {
702702
#[test]
703703
fn shows_warnings() {
704704
let p = project()
705-
.file("src/lib.rs", "use std::default::Default; pub fn foo() {}")
705+
.file("src/lib.rs", "#[deprecated] fn bar() {} pub fn foo() { let _ = bar(); }")
706706
.build();
707707

708708
p.cargo("fix --allow-no-vcs")
709-
.with_stderr_contains("[..]warning: unused import[..]")
709+
.with_stderr_contains("[..]warning: use of deprecated item[..]")
710710
.run();
711711
}
712712

@@ -984,20 +984,22 @@ fn shows_warnings_on_second_run_without_changes() {
984984
.file(
985985
"src/lib.rs",
986986
r#"
987-
use std::default::Default;
987+
#[deprecated]
988+
fn bar() {}
988989
989990
pub fn foo() {
991+
let _ = bar();
990992
}
991993
"#,
992994
)
993995
.build();
994996

995997
p.cargo("fix --allow-no-vcs")
996-
.with_stderr_contains("[..]warning: unused import[..]")
998+
.with_stderr_contains("[..]warning: use of deprecated item[..]")
997999
.run();
9981000

9991001
p.cargo("fix --allow-no-vcs")
1000-
.with_stderr_contains("[..]warning: unused import[..]")
1002+
.with_stderr_contains("[..]warning: use of deprecated item[..]")
10011003
.run();
10021004
}
10031005

@@ -1007,65 +1009,76 @@ fn shows_warnings_on_second_run_without_changes_on_multiple_targets() {
10071009
.file(
10081010
"src/lib.rs",
10091011
r#"
1010-
use std::default::Default;
1012+
#[deprecated]
1013+
fn bar() {}
10111014
1012-
pub fn a() -> u32 { 3 }
1015+
pub fn foo() {
1016+
let _ = bar();
1017+
}
10131018
"#,
10141019
)
10151020
.file(
10161021
"src/main.rs",
10171022
r#"
1018-
use std::default::Default;
1019-
fn main() { println!("3"); }
1023+
#[deprecated]
1024+
fn bar() {}
1025+
1026+
fn main() {
1027+
let _ = bar();
1028+
}
10201029
"#,
10211030
)
10221031
.file(
10231032
"tests/foo.rs",
10241033
r#"
1025-
use std::default::Default;
1034+
#[deprecated]
1035+
fn bar() {}
1036+
10261037
#[test]
10271038
fn foo_test() {
1028-
println!("3");
1039+
let _ = bar();
10291040
}
10301041
"#,
10311042
)
10321043
.file(
10331044
"tests/bar.rs",
10341045
r#"
1035-
use std::default::Default;
1046+
#[deprecated]
1047+
fn bar() {}
10361048
10371049
#[test]
10381050
fn foo_test() {
1039-
println!("3");
1051+
let _ = bar();
10401052
}
10411053
"#,
10421054
)
10431055
.file(
10441056
"examples/fooxample.rs",
10451057
r#"
1046-
use std::default::Default;
1058+
#[deprecated]
1059+
fn bar() {}
10471060
10481061
fn main() {
1049-
println!("3");
1062+
let _ = bar();
10501063
}
10511064
"#,
10521065
)
10531066
.build();
10541067

10551068
p.cargo("fix --allow-no-vcs --all-targets")
1056-
.with_stderr_contains(" --> examples/fooxample.rs:2:21")
1057-
.with_stderr_contains(" --> src/lib.rs:2:21")
1058-
.with_stderr_contains(" --> src/main.rs:2:21")
1059-
.with_stderr_contains(" --> tests/bar.rs:2:21")
1060-
.with_stderr_contains(" --> tests/foo.rs:2:21")
1069+
.with_stderr_contains(" --> examples/fooxample.rs:6:29")
1070+
.with_stderr_contains(" --> src/lib.rs:6:29")
1071+
.with_stderr_contains(" --> src/main.rs:6:29")
1072+
.with_stderr_contains(" --> tests/bar.rs:7:29")
1073+
.with_stderr_contains(" --> tests/foo.rs:7:29")
10611074
.run();
10621075

10631076
p.cargo("fix --allow-no-vcs --all-targets")
1064-
.with_stderr_contains(" --> examples/fooxample.rs:2:21")
1065-
.with_stderr_contains(" --> src/lib.rs:2:21")
1066-
.with_stderr_contains(" --> src/main.rs:2:21")
1067-
.with_stderr_contains(" --> tests/bar.rs:2:21")
1068-
.with_stderr_contains(" --> tests/foo.rs:2:21")
1077+
.with_stderr_contains(" --> examples/fooxample.rs:6:29")
1078+
.with_stderr_contains(" --> src/lib.rs:6:29")
1079+
.with_stderr_contains(" --> src/main.rs:6:29")
1080+
.with_stderr_contains(" --> tests/bar.rs:7:29")
1081+
.with_stderr_contains(" --> tests/foo.rs:7:29")
10691082
.run();
10701083
}
10711084

0 commit comments

Comments
 (0)