Skip to content

Commit 6a5b97a

Browse files
committed
Auto merge of #86210 - ehuss:rustfix-update, r=Mark-Simulacrum
Rustfix update This updates to rustfix 0.6.0. One of the key changes here is rust-lang/rustfix#195 which changes rustfix to apply multi-part suggestions. One of the tests needs to updated because there are some overlapping suggestions which rustfix cannot handle. The solution is to only apply the machine-applicable suggestions to avoid the overlapping issue. This also includes a minor change to compiletest to provide better error messages with rustfix.
2 parents 9d93819 + 35bf1be commit 6a5b97a

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ dependencies = [
673673
"libc",
674674
"miow 0.3.6",
675675
"regex",
676-
"rustfix 0.5.1",
676+
"rustfix 0.6.0",
677677
"serde",
678678
"serde_json",
679679
"tracing",

src/test/ui/parser/expr-as-stmt.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
// rustfix-only-machine-applicable
23
#![allow(unused_variables)]
34
#![allow(dead_code)]
45
#![allow(unused_must_use)]

src/test/ui/parser/expr-as-stmt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
// rustfix-only-machine-applicable
23
#![allow(unused_variables)]
34
#![allow(dead_code)]
45
#![allow(unused_must_use)]

src/test/ui/parser/expr-as-stmt.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error: expected expression, found `+`
2-
--> $DIR/expr-as-stmt.rs:7:9
2+
--> $DIR/expr-as-stmt.rs:8:9
33
|
44
LL | {2} + {2}
55
| --- ^ expected expression
66
| |
77
| help: parentheses are required to parse this as an expression: `({2})`
88

99
error: expected expression, found `+`
10-
--> $DIR/expr-as-stmt.rs:12:9
10+
--> $DIR/expr-as-stmt.rs:13:9
1111
|
1212
LL | {2} + 2
1313
| --- ^ expected expression
1414
| |
1515
| help: parentheses are required to parse this as an expression: `({2})`
1616

1717
error: expected expression, found `+`
18-
--> $DIR/expr-as-stmt.rs:18:12
18+
--> $DIR/expr-as-stmt.rs:19:12
1919
|
2020
LL | { 42 } + foo;
2121
| ------ ^ expected expression
2222
| |
2323
| help: parentheses are required to parse this as an expression: `({ 42 })`
2424

2525
error: expected expression, found `>`
26-
--> $DIR/expr-as-stmt.rs:31:7
26+
--> $DIR/expr-as-stmt.rs:32:7
2727
|
2828
LL | } > 0
2929
| ^ expected expression
@@ -36,7 +36,7 @@ LL | }) > 0
3636
|
3737

3838
error[E0308]: mismatched types
39-
--> $DIR/expr-as-stmt.rs:7:6
39+
--> $DIR/expr-as-stmt.rs:8:6
4040
|
4141
LL | {2} + {2}
4242
| ^ expected `()`, found integer
@@ -47,7 +47,7 @@ LL | {return 2;} + {2}
4747
| ^^^^^^ ^
4848

4949
error[E0308]: mismatched types
50-
--> $DIR/expr-as-stmt.rs:12:6
50+
--> $DIR/expr-as-stmt.rs:13:6
5151
|
5252
LL | {2} + 2
5353
| ^ expected `()`, found integer
@@ -58,7 +58,7 @@ LL | {return 2;} + 2
5858
| ^^^^^^ ^
5959

6060
error[E0308]: mismatched types
61-
--> $DIR/expr-as-stmt.rs:18:7
61+
--> $DIR/expr-as-stmt.rs:19:7
6262
|
6363
LL | { 42 } + foo;
6464
| ^^ expected `()`, found integer
@@ -69,7 +69,7 @@ LL | { return 42; } + foo;
6969
| ^^^^^^ ^
7070

7171
error[E0308]: mismatched types
72-
--> $DIR/expr-as-stmt.rs:24:7
72+
--> $DIR/expr-as-stmt.rs:25:7
7373
|
7474
LL | { 3 } * 3
7575
| ^ expected `()`, found integer
@@ -80,7 +80,7 @@ LL | { return 3; } * 3
8080
| ^^^^^^ ^
8181

8282
error[E0614]: type `{integer}` cannot be dereferenced
83-
--> $DIR/expr-as-stmt.rs:24:11
83+
--> $DIR/expr-as-stmt.rs:25:11
8484
|
8585
LL | { 3 } * 3
8686
| ----- ^^^

src/tools/compiletest/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tracing-subscriber = { version = "0.2", default-features = false, features = ["f
1414
regex = "1.0"
1515
serde = { version = "1.0", features = ["derive"] }
1616
serde_json = "1.0"
17-
rustfix = "0.5.0"
17+
rustfix = "0.6.0"
1818
lazy_static = "1.0"
1919
walkdir = "2"
2020
glob = "0.3.0"

src/tools/compiletest/src/runtest.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3328,8 +3328,11 @@ impl<'test> TestCx<'test> {
33283328
},
33293329
)
33303330
.unwrap();
3331-
let fixed_code = apply_suggestions(&unfixed_code, &suggestions).unwrap_or_else(|_| {
3332-
panic!("failed to apply suggestions for {:?} with rustfix", self.testpaths.file)
3331+
let fixed_code = apply_suggestions(&unfixed_code, &suggestions).unwrap_or_else(|e| {
3332+
panic!(
3333+
"failed to apply suggestions for {:?} with rustfix: {}",
3334+
self.testpaths.file, e
3335+
)
33333336
});
33343337

33353338
errors += self.compare_output("fixed", &fixed_code, &expected_fixed);

src/tools/tidy/src/deps.rs

+20
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
287287
check_exceptions(&metadata, EXCEPTIONS, runtime_ids, bad);
288288
check_dependencies(&metadata, PERMITTED_DEPENDENCIES, RESTRICTED_DEPENDENCY_CRATES, bad);
289289
check_crate_duplicate(&metadata, FORBIDDEN_TO_HAVE_DUPLICATES, bad);
290+
check_rustfix(&metadata, bad);
290291

291292
// Check rustc_codegen_cranelift independently as it has it's own workspace.
292293
let mut cmd = cargo_metadata::MetadataCommand::new();
@@ -547,3 +548,22 @@ fn normal_deps_of_r<'a>(
547548
normal_deps_of_r(resolve, &dep.pkg, result);
548549
}
549550
}
551+
552+
fn check_rustfix(metadata: &Metadata, bad: &mut bool) {
553+
let cargo = pkg_from_name(metadata, "cargo");
554+
let compiletest = pkg_from_name(metadata, "compiletest");
555+
let cargo_deps = deps_of(metadata, &cargo.id);
556+
let compiletest_deps = deps_of(metadata, &compiletest.id);
557+
let cargo_rustfix = cargo_deps.iter().find(|p| p.name == "rustfix").unwrap();
558+
let compiletest_rustfix = compiletest_deps.iter().find(|p| p.name == "rustfix").unwrap();
559+
if cargo_rustfix.version != compiletest_rustfix.version {
560+
tidy_error!(
561+
bad,
562+
"cargo's rustfix version {} does not match compiletest's rustfix version {}\n\
563+
rustfix should be kept in sync, update the cargo side first, and then update \
564+
compiletest along with cargo.",
565+
cargo_rustfix.version,
566+
compiletest_rustfix.version
567+
);
568+
}
569+
}

0 commit comments

Comments
 (0)