Skip to content

Commit 865cb70

Browse files
committed
Auto merge of #6649 - pietroalbini:change-unfixable-warning, r=dwijnand
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.
2 parents 9118c7f + ea9cd6e commit 865cb70

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

@@ -982,20 +982,22 @@ fn shows_warnings_on_second_run_without_changes() {
982982
.file(
983983
"src/lib.rs",
984984
r#"
985-
use std::default::Default;
985+
#[deprecated]
986+
fn bar() {}
986987
987988
pub fn foo() {
989+
let _ = bar();
988990
}
989991
"#,
990992
)
991993
.build();
992994

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

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

@@ -1005,65 +1007,76 @@ fn shows_warnings_on_second_run_without_changes_on_multiple_targets() {
10051007
.file(
10061008
"src/lib.rs",
10071009
r#"
1008-
use std::default::Default;
1010+
#[deprecated]
1011+
fn bar() {}
10091012
1010-
pub fn a() -> u32 { 3 }
1013+
pub fn foo() {
1014+
let _ = bar();
1015+
}
10111016
"#,
10121017
)
10131018
.file(
10141019
"src/main.rs",
10151020
r#"
1016-
use std::default::Default;
1017-
fn main() { println!("3"); }
1021+
#[deprecated]
1022+
fn bar() {}
1023+
1024+
fn main() {
1025+
let _ = bar();
1026+
}
10181027
"#,
10191028
)
10201029
.file(
10211030
"tests/foo.rs",
10221031
r#"
1023-
use std::default::Default;
1032+
#[deprecated]
1033+
fn bar() {}
1034+
10241035
#[test]
10251036
fn foo_test() {
1026-
println!("3");
1037+
let _ = bar();
10271038
}
10281039
"#,
10291040
)
10301041
.file(
10311042
"tests/bar.rs",
10321043
r#"
1033-
use std::default::Default;
1044+
#[deprecated]
1045+
fn bar() {}
10341046
10351047
#[test]
10361048
fn foo_test() {
1037-
println!("3");
1049+
let _ = bar();
10381050
}
10391051
"#,
10401052
)
10411053
.file(
10421054
"examples/fooxample.rs",
10431055
r#"
1044-
use std::default::Default;
1056+
#[deprecated]
1057+
fn bar() {}
10451058
10461059
fn main() {
1047-
println!("3");
1060+
let _ = bar();
10481061
}
10491062
"#,
10501063
)
10511064
.build();
10521065

10531066
p.cargo("fix --allow-no-vcs --all-targets")
1054-
.with_stderr_contains(" --> examples/fooxample.rs:2:21")
1055-
.with_stderr_contains(" --> src/lib.rs:2:21")
1056-
.with_stderr_contains(" --> src/main.rs:2:21")
1057-
.with_stderr_contains(" --> tests/bar.rs:2:21")
1058-
.with_stderr_contains(" --> tests/foo.rs:2:21")
1067+
.with_stderr_contains(" --> examples/fooxample.rs:6:29")
1068+
.with_stderr_contains(" --> src/lib.rs:6:29")
1069+
.with_stderr_contains(" --> src/main.rs:6:29")
1070+
.with_stderr_contains(" --> tests/bar.rs:7:29")
1071+
.with_stderr_contains(" --> tests/foo.rs:7:29")
10591072
.run();
10601073

10611074
p.cargo("fix --allow-no-vcs --all-targets")
1062-
.with_stderr_contains(" --> examples/fooxample.rs:2:21")
1063-
.with_stderr_contains(" --> src/lib.rs:2:21")
1064-
.with_stderr_contains(" --> src/main.rs:2:21")
1065-
.with_stderr_contains(" --> tests/bar.rs:2:21")
1066-
.with_stderr_contains(" --> tests/foo.rs:2:21")
1075+
.with_stderr_contains(" --> examples/fooxample.rs:6:29")
1076+
.with_stderr_contains(" --> src/lib.rs:6:29")
1077+
.with_stderr_contains(" --> src/main.rs:6:29")
1078+
.with_stderr_contains(" --> tests/bar.rs:7:29")
1079+
.with_stderr_contains(" --> tests/foo.rs:7:29")
10671080
.run();
10681081
}
10691082

0 commit comments

Comments
 (0)