about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-21 12:21:19 +0000
committerbors <bors@rust-lang.org>2021-06-21 12:21:19 +0000
commit6a5b97adb4da4b0f913d19765e91d4322ef6542e (patch)
tree3032f3b0de196f0dabda79d943bc0adfe00f66a3
parent9d93819fa7ae40376ac1f563a858d2ba5f3b0277 (diff)
parent35bf1becaac46ae79c92ee8b87a05b02687eeae7 (diff)
downloadrust-6a5b97adb4da4b0f913d19765e91d4322ef6542e.tar.gz
rust-6a5b97adb4da4b0f913d19765e91d4322ef6542e.zip
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 https://github.com/rust-lang/rustfix/pull/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.
-rw-r--r--Cargo.lock2
-rw-r--r--src/test/ui/parser/expr-as-stmt.fixed1
-rw-r--r--src/test/ui/parser/expr-as-stmt.rs1
-rw-r--r--src/test/ui/parser/expr-as-stmt.stderr18
-rw-r--r--src/tools/compiletest/Cargo.toml2
-rw-r--r--src/tools/compiletest/src/runtest.rs7
-rw-r--r--src/tools/tidy/src/deps.rs20
7 files changed, 38 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4a4f4d04c77..86dd4695aa4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -673,7 +673,7 @@ dependencies = [
  "libc",
  "miow 0.3.6",
  "regex",
- "rustfix 0.5.1",
+ "rustfix 0.6.0",
  "serde",
  "serde_json",
  "tracing",
diff --git a/src/test/ui/parser/expr-as-stmt.fixed b/src/test/ui/parser/expr-as-stmt.fixed
index 02816ef2791..c217ab9774f 100644
--- a/src/test/ui/parser/expr-as-stmt.fixed
+++ b/src/test/ui/parser/expr-as-stmt.fixed
@@ -1,4 +1,5 @@
 // run-rustfix
+// rustfix-only-machine-applicable
 #![allow(unused_variables)]
 #![allow(dead_code)]
 #![allow(unused_must_use)]
diff --git a/src/test/ui/parser/expr-as-stmt.rs b/src/test/ui/parser/expr-as-stmt.rs
index 93baa8278f8..b04025faaec 100644
--- a/src/test/ui/parser/expr-as-stmt.rs
+++ b/src/test/ui/parser/expr-as-stmt.rs
@@ -1,4 +1,5 @@
 // run-rustfix
+// rustfix-only-machine-applicable
 #![allow(unused_variables)]
 #![allow(dead_code)]
 #![allow(unused_must_use)]
diff --git a/src/test/ui/parser/expr-as-stmt.stderr b/src/test/ui/parser/expr-as-stmt.stderr
index 09a6d7cbeb1..067b7edc770 100644
--- a/src/test/ui/parser/expr-as-stmt.stderr
+++ b/src/test/ui/parser/expr-as-stmt.stderr
@@ -1,5 +1,5 @@
 error: expected expression, found `+`
-  --> $DIR/expr-as-stmt.rs:7:9
+  --> $DIR/expr-as-stmt.rs:8:9
    |
 LL |     {2} + {2}
    |     --- ^ expected expression
@@ -7,7 +7,7 @@ LL |     {2} + {2}
    |     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
@@ -15,7 +15,7 @@ LL |     {2} + 2
    |     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
@@ -23,7 +23,7 @@ LL |     { 42 } + foo;
    |     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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
    |     ----- ^^^
diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml
index f61d61e8f9d..771e36e4d2c 100644
--- a/src/tools/compiletest/Cargo.toml
+++ b/src/tools/compiletest/Cargo.toml
@@ -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"
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 02dffaab7b6..6a1faee1d8e 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -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);
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 06cec1964a0..ea587210b4f 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -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();
@@ -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
+        );
+    }
+}