Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustfix update #86210

Merged
merged 3 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ dependencies = [
"libc",
"miow 0.3.6",
"regex",
"rustfix 0.5.1",
"rustfix 0.6.0",
"serde",
"serde_json",
"tracing",
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/parser/expr-as-stmt.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// run-rustfix
// rustfix-only-machine-applicable
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_must_use)]
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/parser/expr-as-stmt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// run-rustfix
// rustfix-only-machine-applicable
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_must_use)]
Expand Down
18 changes: 9 additions & 9 deletions src/test/ui/parser/expr-as-stmt.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error: expected expression, found `+`
--> $DIR/expr-as-stmt.rs:7:9
--> $DIR/expr-as-stmt.rs:8:9
|
LL | {2} + {2}
| --- ^ expected expression
| |
| help: parentheses are required to parse this as an expression: `({2})`

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

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

error: expected expression, found `>`
--> $DIR/expr-as-stmt.rs:31:7
--> $DIR/expr-as-stmt.rs:32:7
|
LL | } > 0
| ^ expected expression
Expand All @@ -36,7 +36,7 @@ LL | }) > 0
|

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

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

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

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

error[E0614]: type `{integer}` cannot be dereferenced
--> $DIR/expr-as-stmt.rs:24:11
--> $DIR/expr-as-stmt.rs:25:11
|
LL | { 3 } * 3
| ----- ^^^
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tracing-subscriber = { version = "0.2", default-features = false, features = ["f
regex = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rustfix = "0.5.0"
rustfix = "0.6.0"
lazy_static = "1.0"
walkdir = "2"
glob = "0.3.0"
Expand Down
7 changes: 5 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3328,8 +3328,11 @@ impl<'test> TestCx<'test> {
},
)
.unwrap();
let fixed_code = apply_suggestions(&unfixed_code, &suggestions).unwrap_or_else(|_| {
panic!("failed to apply suggestions for {:?} with rustfix", self.testpaths.file)
let fixed_code = apply_suggestions(&unfixed_code, &suggestions).unwrap_or_else(|e| {
panic!(
"failed to apply suggestions for {:?} with rustfix: {}",
self.testpaths.file, e
)
});

errors += self.compare_output("fixed", &fixed_code, &expected_fixed);
Expand Down
20 changes: 20 additions & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
check_exceptions(&metadata, EXCEPTIONS, runtime_ids, bad);
check_dependencies(&metadata, PERMITTED_DEPENDENCIES, RESTRICTED_DEPENDENCY_CRATES, bad);
check_crate_duplicate(&metadata, FORBIDDEN_TO_HAVE_DUPLICATES, bad);
check_rustfix(&metadata, bad);

// Check rustc_codegen_cranelift independently as it has it's own workspace.
let mut cmd = cargo_metadata::MetadataCommand::new();
Expand Down Expand Up @@ -547,3 +548,22 @@ fn normal_deps_of_r<'a>(
normal_deps_of_r(resolve, &dep.pkg, result);
}
}

fn check_rustfix(metadata: &Metadata, bad: &mut bool) {
let cargo = pkg_from_name(metadata, "cargo");
let compiletest = pkg_from_name(metadata, "compiletest");
let cargo_deps = deps_of(metadata, &cargo.id);
let compiletest_deps = deps_of(metadata, &compiletest.id);
let cargo_rustfix = cargo_deps.iter().find(|p| p.name == "rustfix").unwrap();
let compiletest_rustfix = compiletest_deps.iter().find(|p| p.name == "rustfix").unwrap();
if cargo_rustfix.version != compiletest_rustfix.version {
tidy_error!(
bad,
"cargo's rustfix version {} does not match compiletest's rustfix version {}\n\
rustfix should be kept in sync, update the cargo side first, and then update \
compiletest along with cargo.",
cargo_rustfix.version,
compiletest_rustfix.version
);
}
}