From cc48ae5a64a4e648211a2e7c9f37df0c5d6c32a6 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 11 Apr 2018 15:41:22 -0700 Subject: compiletest: detect non-ICE compiler panics --- src/tools/compiletest/src/runtest.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/tools') diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index aabf2e6f8f0..4a7f902a892 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1166,6 +1166,8 @@ impl<'test> TestCx<'test> { for line in proc_res.stderr.lines() { if line.contains("error: internal compiler error") { self.fatal_proc_rec("compiler encountered internal error", proc_res); + } else if line.contains(" panicked at ") { + self.fatal_proc_rec("compiler panicked", proc_res); } } } -- cgit 1.4.1-3-g733a5 From d27e2a185411474e341b2a0baab43c27ca635357 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sat, 28 Apr 2018 15:10:42 +0200 Subject: Update clippy submodule --- src/tools/clippy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/clippy b/src/tools/clippy index c5b39a5917f..1742229ebb7 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit c5b39a5917ffc0f1349b6e414fa3b874fdcf8429 +Subproject commit 1742229ebb7843a65c05ee495d8de5366fcc5567 -- cgit 1.4.1-3-g733a5 From 00bbda16a72eab1cf3418f9021329915eddb267c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 28 Apr 2018 17:21:12 +0200 Subject: Add query search order check --- src/test/rustdoc-js/alias.js | 2 ++ src/test/rustdoc-js/basic.js | 2 +- src/tools/rustdoc-js/tester.js | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/tools') diff --git a/src/test/rustdoc-js/alias.js b/src/test/rustdoc-js/alias.js index a0500f24c17..93a04e31985 100644 --- a/src/test/rustdoc-js/alias.js +++ b/src/test/rustdoc-js/alias.js @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-order + const QUERY = '['; const EXPECTED = { diff --git a/src/test/rustdoc-js/basic.js b/src/test/rustdoc-js/basic.js index 863437cac91..d7ba1253eab 100644 --- a/src/test/rustdoc-js/basic.js +++ b/src/test/rustdoc-js/basic.js @@ -13,8 +13,8 @@ const QUERY = 'String'; const EXPECTED = { 'others': [ { 'path': 'std::string', 'name': 'String' }, - { 'path': 'std::ffi', 'name': 'OsString' }, { 'path': 'std::ffi', 'name': 'CString' }, + { 'path': 'std::ffi', 'name': 'OsString' }, ], 'in_args': [ { 'path': 'std::str', 'name': 'eq' }, diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 6992f2ba123..1c79443dedf 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -87,6 +87,7 @@ function loadContent(content) { var Module = module.constructor; var m = new Module(); m._compile(content, "tmp.js"); + m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1; return m.exports; } @@ -130,10 +131,10 @@ function lookForEntry(entry, data) { } } if (allGood === true) { - return true; + return i; } } - return false; + return null; } function main(argv) { @@ -177,6 +178,7 @@ function main(argv) { 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;'); const expected = loadedFile.EXPECTED; const query = loadedFile.QUERY; + const ignore_order = loadedFile.ignore_order; var results = loaded.execSearch(loaded.getQuery(query), index); process.stdout.write('Checking "' + file + '" ... '); var error_text = []; @@ -189,13 +191,17 @@ function main(argv) { break; } var entry = expected[key]; - var found = false; + var prev_pos = 0; for (var i = 0; i < entry.length; ++i) { - if (lookForEntry(entry[i], results[key]) === true) { - found = true; - } else { + var entry_pos = lookForEntry(entry[i], results[key]); + if (entry_pos === null) { error_text.push("==> Result not found in '" + key + "': '" + JSON.stringify(entry[i]) + "'"); + } else if (entry_pos < prev_pos && ignore_order === false) { + error_text.push("==> '" + JSON.stringify(entry[i]) + "' was supposed to be " + + " before '" + JSON.stringify(results[key][entry_pos]) + "'"); + } else { + prev_pos = entry_pos; } } } -- cgit 1.4.1-3-g733a5 From 410e2011bd739024ff184cebd299ba4d6d96d57e Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 27 Apr 2018 11:45:34 +1200 Subject: Update Rustfmt --- src/tools/rustfmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/rustfmt b/src/tools/rustfmt index ac8ae006254..0f4ed08d0e3 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit ac8ae0062544743aaea1719a34f299b66f2b7dc9 +Subproject commit 0f4ed08d0e3d180d66e46904126c3792f57668a9 -- cgit 1.4.1-3-g733a5 From 21941c8129da7b37f5df687e3862a5b331c04f83 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 30 Apr 2018 17:04:42 +0200 Subject: Update Cargo to 2018-04-28 122fd5be5201913d42e219e132d6569493583bca --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/cargo b/src/tools/cargo index 0a1add2d868..122fd5be520 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 0a1add2d8689ad12a86f6c32d0a5cd0393dc5d80 +Subproject commit 122fd5be5201913d42e219e132d6569493583bca -- cgit 1.4.1-3-g733a5 From 6457241133b20cf447dec325c0f846e4dea51c71 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 2 May 2018 07:50:58 +1200 Subject: Update RLS and Rustfmt --- src/Cargo.lock | 71 ++++++++++++++++++++++++++++++++++--------------------- src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 3 files changed, 46 insertions(+), 29 deletions(-) (limited to 'src/tools') diff --git a/src/Cargo.lock b/src/Cargo.lock index 940ca1aace0..f482bed3176 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1623,7 +1623,7 @@ dependencies = [ [[package]] name = "rls" -version = "0.126.0" +version = "0.127.0" dependencies = [ "cargo 0.28.0", "cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1644,7 +1644,7 @@ dependencies = [ "rls-rustc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.6.0", + "rustfmt-nightly 0.6.1", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1739,16 +1739,17 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_cratesio_shim" -version = "110.0.0" +version = "113.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_data_structures" -version = "110.0.0" +version = "113.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1756,53 +1757,66 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_errors" -version = "110.0.0" +version = "113.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-ap-rustc_target" +version = "113.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustc-ap-serialize" -version = "110.0.0" +version = "113.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-ap-syntax" -version = "110.0.0" +version = "113.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-syntax_pos" -version = "110.0.0" +version = "113.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2221,20 +2235,22 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "0.6.0" +version = "0.6.1" dependencies = [ "assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3120,12 +3136,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rls-rustc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "885f66b92757420572cbb02e033d4a9558c7413ca9b7ac206f28fd58ffdb44ea" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "be231e1e559c315bc60ced5ad2cc2d7a9c208ed7d4e2c126500149836fda19bb" -"checksum rustc-ap-rustc_cratesio_shim 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0256e318ad99c467d24bd7188f2d4a3028360621bb92d769b4b65fc44717d514" -"checksum rustc-ap-rustc_data_structures 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83430df7f76ea85c1f70fe145041576eee8fd5d77053bf426df24b480918d185" -"checksum rustc-ap-rustc_errors 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2b03f874277103039816f6467b1ff30a81b1d6a29d4de6efccefe4c488f6535a" -"checksum rustc-ap-serialize 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2e47cf949f06b0c7ab7566c2f69d49f28cb3ecf1bb8bf0bda48b1ba5b7945ae" -"checksum rustc-ap-syntax 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "625e6fb41fde299082cda3bceb08f81c9ba56b14a2ec737b4366f9c3c9be07d8" -"checksum rustc-ap-syntax_pos 110.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "474a23ef1a1245ae02c5fd6a1e9a0725ce6fd25ca2294703c03bddce041f867b" +"checksum rustc-ap-rustc_cratesio_shim 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a01334797c5c4cf56cc40bb9636d7b4c4a076665b9b9b7f100fd666cf0a02ffc" +"checksum rustc-ap-rustc_data_structures 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03d6f8f7da0de905f6ef80dc14dce3bbc372430622b6aeb421cf13190bc70e8a" +"checksum rustc-ap-rustc_errors 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dfd6183804a685c48601651d8c8c7b0daa8f83b0b5e24edfbcb6a0337085127" +"checksum rustc-ap-rustc_target 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f223157f51bf0e0621bef099de862468892ee4c4b83056f48f63e1bc00ccb72" +"checksum rustc-ap-serialize 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2104a55a87d65cba8a845656f1f19a35da52af403863cd2a4bd5876ba522d879" +"checksum rustc-ap-syntax 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b50671adb9b0a7c57a4690ac6a40cb614879f543b64aada42f55b66212492323" +"checksum rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55793c2a775230c42661194c48d44b35d4c8439d79ad8528e56651e854c48c63" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" diff --git a/src/tools/rls b/src/tools/rls index 9144e223a5b..99796f6a659 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 9144e223a5b90e078366275ff3dcdd406e62eae3 +Subproject commit 99796f6a6592b4d897719a1736ec580c96f5441a diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 0f4ed08d0e3..d8982e5efe8 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 0f4ed08d0e3d180d66e46904126c3792f57668a9 +Subproject commit d8982e5efe8fda1d6f64e88a67da2f05b6af225e -- cgit 1.4.1-3-g733a5 From f67c683950001615805638e2d2b4d1a82347d3c0 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 26 Feb 2018 14:46:43 +0100 Subject: Include the test name when reporting that an expected line was not found in a mir-opt test. --- src/tools/compiletest/src/runtest.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/tools') diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d1dac370c9e..01d9f52424d 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2735,10 +2735,12 @@ impl<'test> TestCx<'test> { panic!( "Did not find expected line, error: {}\n\ Expected Line: {:?}\n\ + Test Name: {}\n\ Expected:\n{}\n\ Actual:\n{}", extra_msg, expected_line, + test_name, expected_content, normalize_all ); -- cgit 1.4.1-3-g733a5 From 70c52e5e19b277adf8eb3212f620e93699c24ed4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 3 May 2018 14:17:58 +0300 Subject: Update Cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/cargo b/src/tools/cargo index 122fd5be520..66b0ffa81c5 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 122fd5be5201913d42e219e132d6569493583bca +Subproject commit 66b0ffa81c560be1b79511b51f49cbb23bc78651 -- cgit 1.4.1-3-g733a5 From b71f6364d22e1e9cea597003e4c563c32e5f651c Mon Sep 17 00:00:00 2001 From: Harm Berntsen Date: Thu, 3 May 2018 14:35:59 +0200 Subject: Add armv5te-unknown-linux-musl target --- src/bootstrap/configure.py | 2 + src/ci/docker/dist-armv5te-linux-musl/Dockerfile | 47 ++++++++++++++++++++++ .../spec/armv5te_unknown_linux_musl.rs | 38 +++++++++++++++++ src/librustc_target/spec/mod.rs | 1 + src/tools/build-manifest/src/main.rs | 1 + 5 files changed, 89 insertions(+) create mode 100644 src/ci/docker/dist-armv5te-linux-musl/Dockerfile create mode 100644 src/librustc_target/spec/armv5te_unknown_linux_musl.rs (limited to 'src/tools') diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index a0123da6d8f..54b6526c5c8 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -120,6 +120,8 @@ v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root", "arm-unknown-linux-musleabi install directory") v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root", "arm-unknown-linux-musleabihf install directory") +v("musl-root-armv5te", "target.armv5te-unknown-linux-musl.musl-root", + "armv5te-unknown-linux-musleabi install directory") v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root", "armv7-unknown-linux-musleabihf install directory") v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root", diff --git a/src/ci/docker/dist-armv5te-linux-musl/Dockerfile b/src/ci/docker/dist-armv5te-linux-musl/Dockerfile new file mode 100644 index 00000000000..42eaebcc3db --- /dev/null +++ b/src/ci/docker/dist-armv5te-linux-musl/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:16.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + sudo \ + xz-utils \ + zlib1g-dev \ + g++-arm-linux-gnueabi \ + bzip2 \ + patch \ + pkg-config + +WORKDIR /build + +# Suppress some warnings in the openwrt toolchains we downloaded +ENV STAGING_DIR=/tmp + +COPY scripts/musl.sh /build +RUN env \ + CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ + CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ + bash musl.sh armv5te && \ + rm -rf /build/* + +ENV TARGETS=armv5te-unknown-linux-musl + +# FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 +# get fixed and cc update +ENV CC_armv5te_unknown_linux_musl=arm-linux-gnueabi-gcc \ + CFLAGS_armv5te_unknown_linux_musl="-march=armv5te -marm -mfloat-abi=soft" + +ENV RUST_CONFIGURE_ARGS \ + --musl-root-armv5te=/musl-armv5te \ + --disable-docs + +ENV SCRIPT python2.7 ../x.py dist --target $TARGETS + +# sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh diff --git a/src/librustc_target/spec/armv5te_unknown_linux_musl.rs b/src/librustc_target/spec/armv5te_unknown_linux_musl.rs new file mode 100644 index 00000000000..2d4e95ab01d --- /dev/null +++ b/src/librustc_target/spec/armv5te_unknown_linux_musl.rs @@ -0,0 +1,38 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + let base = super::linux_musl_base::opts(); + Ok(Target { + // It's important we use "gnueabihf" and not "musleabihf" here. LLVM + // uses it to determine the calling convention and float ABI, and LLVM + // doesn't support the "musleabihf" value. + llvm_target: "armv5te-unknown-linux-gnueabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "linux".to_string(), + target_env: "musl".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + + options: TargetOptions { + features: "+soft-float,+strict-align".to_string(), + // Atomic operations provided by compiler-builtins + max_atomic_width: Some(32), + abi_blacklist: super::arm_base::abi_blacklist(), + .. base + } + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 1e94f037885..e4071b316c1 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -283,6 +283,7 @@ supported_targets! { ("arm-unknown-linux-musleabihf", arm_unknown_linux_musleabihf), ("armv4t-unknown-linux-gnueabi", armv4t_unknown_linux_gnueabi), ("armv5te-unknown-linux-gnueabi", armv5te_unknown_linux_gnueabi), + ("armv5te-unknown-linux-musl", armv5te_unknown_linux_musl), ("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf), ("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf), ("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu), diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 9f238929215..ba5bb45d767 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -57,6 +57,7 @@ static TARGETS: &'static [&'static str] = &[ "arm-unknown-linux-musleabi", "arm-unknown-linux-musleabihf", "armv5te-unknown-linux-gnueabi", + "armv5te-unknown-linux-musl", "armv7-apple-ios", "armv7-linux-androideabi", "armv7-unknown-cloudabi-eabihf", -- cgit 1.4.1-3-g733a5 From 4952426c50cf4379afa3d1eb3647f30afeb5d690 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 4 May 2018 07:53:33 +1200 Subject: Update RLS and Rustfmt (and Cargo) --- src/Cargo.lock | 7 ++++--- src/tools/cargo | 2 +- src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/tools') diff --git a/src/Cargo.lock b/src/Cargo.lock index f482bed3176..ccdb24d7375 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -996,9 +996,10 @@ dependencies = [ [[package]] name = "languageserver-types" -version = "0.36.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1632,7 +1633,7 @@ dependencies = [ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "languageserver-types 0.36.0 (registry+https://github.com/rust-lang/crates.io-index)", + "languageserver-types 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3065,7 +3066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be" "checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum languageserver-types 0.36.0 (registry+https://github.com/rust-lang/crates.io-index)" = "174cdfb8bed13225bb419bec66ee1c970099c875688645f9c4a82e3af43ba69d" +"checksum languageserver-types 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4cdd5e52d71aca47050e5b25f03082609c63a1e76b7362ebdd010895b3f854" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" diff --git a/src/tools/cargo b/src/tools/cargo index 66b0ffa81c5..af3f1cd29bc 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 66b0ffa81c560be1b79511b51f49cbb23bc78651 +Subproject commit af3f1cd29bc872b932a13083e531255aab233a7e diff --git a/src/tools/rls b/src/tools/rls index 99796f6a659..d2f44357fef 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 99796f6a6592b4d897719a1736ec580c96f5441a +Subproject commit d2f44357fef6d61f316abc403e0a5d917f2771c6 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index d8982e5efe8..b6cd17f28ae 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit d8982e5efe8fda1d6f64e88a67da2f05b6af225e +Subproject commit b6cd17f28ae314f2484ff05d3ce57652d51c5e85 -- cgit 1.4.1-3-g733a5 From 80f1912d83c977ac12946f1a12d2523383a0d3b7 Mon Sep 17 00:00:00 2001 From: Harm Berntsen Date: Fri, 4 May 2018 08:47:24 +0200 Subject: Add eabi suffix to armv5te musl target --- src/bootstrap/configure.py | 2 +- src/ci/docker/dist-armv5te-linux-musl/Dockerfile | 47 ---------------------- .../docker/dist-armv5te-linux-musleabi/Dockerfile | 47 ++++++++++++++++++++++ .../spec/armv5te_unknown_linux_musl.rs | 38 ----------------- .../spec/armv5te_unknown_linux_musleabi.rs | 38 +++++++++++++++++ src/librustc_target/spec/mod.rs | 2 +- src/tools/build-manifest/src/main.rs | 2 +- 7 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 src/ci/docker/dist-armv5te-linux-musl/Dockerfile create mode 100644 src/ci/docker/dist-armv5te-linux-musleabi/Dockerfile delete mode 100644 src/librustc_target/spec/armv5te_unknown_linux_musl.rs create mode 100644 src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs (limited to 'src/tools') diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 54b6526c5c8..3574b7d210a 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -120,7 +120,7 @@ v("musl-root-arm", "target.arm-unknown-linux-musleabi.musl-root", "arm-unknown-linux-musleabi install directory") v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root", "arm-unknown-linux-musleabihf install directory") -v("musl-root-armv5te", "target.armv5te-unknown-linux-musl.musl-root", +v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root", "armv5te-unknown-linux-musleabi install directory") v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root", "armv7-unknown-linux-musleabihf install directory") diff --git a/src/ci/docker/dist-armv5te-linux-musl/Dockerfile b/src/ci/docker/dist-armv5te-linux-musl/Dockerfile deleted file mode 100644 index 42eaebcc3db..00000000000 --- a/src/ci/docker/dist-armv5te-linux-musl/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y --no-install-recommends \ - g++ \ - make \ - file \ - curl \ - ca-certificates \ - python2.7 \ - git \ - cmake \ - sudo \ - xz-utils \ - zlib1g-dev \ - g++-arm-linux-gnueabi \ - bzip2 \ - patch \ - pkg-config - -WORKDIR /build - -# Suppress some warnings in the openwrt toolchains we downloaded -ENV STAGING_DIR=/tmp - -COPY scripts/musl.sh /build -RUN env \ - CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ - CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ - bash musl.sh armv5te && \ - rm -rf /build/* - -ENV TARGETS=armv5te-unknown-linux-musl - -# FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 -# get fixed and cc update -ENV CC_armv5te_unknown_linux_musl=arm-linux-gnueabi-gcc \ - CFLAGS_armv5te_unknown_linux_musl="-march=armv5te -marm -mfloat-abi=soft" - -ENV RUST_CONFIGURE_ARGS \ - --musl-root-armv5te=/musl-armv5te \ - --disable-docs - -ENV SCRIPT python2.7 ../x.py dist --target $TARGETS - -# sccache -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/dist-armv5te-linux-musleabi/Dockerfile b/src/ci/docker/dist-armv5te-linux-musleabi/Dockerfile new file mode 100644 index 00000000000..af2e410a379 --- /dev/null +++ b/src/ci/docker/dist-armv5te-linux-musleabi/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:16.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + sudo \ + xz-utils \ + zlib1g-dev \ + g++-arm-linux-gnueabi \ + bzip2 \ + patch \ + pkg-config + +WORKDIR /build + +# Suppress some warnings in the openwrt toolchains we downloaded +ENV STAGING_DIR=/tmp + +COPY scripts/musl.sh /build +RUN env \ + CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ + CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ + bash musl.sh armv5te && \ + rm -rf /build/* + +ENV TARGETS=armv5te-unknown-linux-musleabi + +# FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 +# get fixed and cc update +ENV CC_armv5te_unknown_linux_musleabi=arm-linux-gnueabi-gcc \ + CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" + +ENV RUST_CONFIGURE_ARGS \ + --musl-root-armv5te=/musl-armv5te \ + --disable-docs + +ENV SCRIPT python2.7 ../x.py dist --target $TARGETS + +# sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh diff --git a/src/librustc_target/spec/armv5te_unknown_linux_musl.rs b/src/librustc_target/spec/armv5te_unknown_linux_musl.rs deleted file mode 100644 index 2d4e95ab01d..00000000000 --- a/src/librustc_target/spec/armv5te_unknown_linux_musl.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; - -pub fn target() -> TargetResult { - let base = super::linux_musl_base::opts(); - Ok(Target { - // It's important we use "gnueabihf" and not "musleabihf" here. LLVM - // uses it to determine the calling convention and float ABI, and LLVM - // doesn't support the "musleabihf" value. - llvm_target: "armv5te-unknown-linux-gnueabi".to_string(), - target_endian: "little".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), - target_os: "linux".to_string(), - target_env: "musl".to_string(), - target_vendor: "unknown".to_string(), - linker_flavor: LinkerFlavor::Gcc, - - options: TargetOptions { - features: "+soft-float,+strict-align".to_string(), - // Atomic operations provided by compiler-builtins - max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), - .. base - } - }) -} diff --git a/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs b/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs new file mode 100644 index 00000000000..2d4e95ab01d --- /dev/null +++ b/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs @@ -0,0 +1,38 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + let base = super::linux_musl_base::opts(); + Ok(Target { + // It's important we use "gnueabihf" and not "musleabihf" here. LLVM + // uses it to determine the calling convention and float ABI, and LLVM + // doesn't support the "musleabihf" value. + llvm_target: "armv5te-unknown-linux-gnueabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "linux".to_string(), + target_env: "musl".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + + options: TargetOptions { + features: "+soft-float,+strict-align".to_string(), + // Atomic operations provided by compiler-builtins + max_atomic_width: Some(32), + abi_blacklist: super::arm_base::abi_blacklist(), + .. base + } + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index e4071b316c1..48e771e0aaf 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -283,7 +283,7 @@ supported_targets! { ("arm-unknown-linux-musleabihf", arm_unknown_linux_musleabihf), ("armv4t-unknown-linux-gnueabi", armv4t_unknown_linux_gnueabi), ("armv5te-unknown-linux-gnueabi", armv5te_unknown_linux_gnueabi), - ("armv5te-unknown-linux-musl", armv5te_unknown_linux_musl), + ("armv5te-unknown-linux-musleabi", armv5te_unknown_linux_musleabi), ("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf), ("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf), ("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu), diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index ba5bb45d767..6b548742fb3 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -57,7 +57,7 @@ static TARGETS: &'static [&'static str] = &[ "arm-unknown-linux-musleabi", "arm-unknown-linux-musleabihf", "armv5te-unknown-linux-gnueabi", - "armv5te-unknown-linux-musl", + "armv5te-unknown-linux-musleabi", "armv7-apple-ios", "armv7-linux-androideabi", "armv7-unknown-cloudabi-eabihf", -- cgit 1.4.1-3-g733a5 From fd6aa149bca7b896650c5f15a9c0000fc4f0056d Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Fri, 20 Apr 2018 00:04:08 +0200 Subject: First step towards rustfix compiletest mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the first small step towards testing auto-fixable compiler suggestions using compiletest. Currently, it only checks if next to a UI test there also happens to a `*.rs.fixed` file, and then uses rustfix (added as external crate) on the original file, and asserts that it produces the fixed version. To show that this works, I've included one such test. I picked this test case at random (and because it was simple) -- It is not relevant to the 2018 edition. Indeed, in the near future, we want to be able to restrict rustfix to edition-lints, so this test cast might go away soon. In case you still think this is somewhat feature-complete, here's a quick list of things currently missing that I want to add before telling people they can use this: - [ ] Make this an actual compiletest mode, with `test [fix] …` output and everything - [ ] Assert that fixed files still compile - [ ] Assert that fixed files produce no (or a known set of) diagnostics output - [ ] Update `update-references.sh` to support rustfix - [ ] Use a published version of rustfix (i.e.: publish a new version rustfix that exposes a useful API for this) --- .../closure-immutable-outer-variable.rs.fixed | 20 +++++++ src/tools/compiletest/Cargo.toml | 1 + src/tools/compiletest/src/autofix.rs | 70 ++++++++++++++++++++++ src/tools/compiletest/src/common.rs | 3 +- src/tools/compiletest/src/main.rs | 2 + src/tools/compiletest/src/runtest.rs | 16 ++++- 6 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed create mode 100644 src/tools/compiletest/src/autofix.rs (limited to 'src/tools') diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed new file mode 100644 index 00000000000..80a5a45a305 --- /dev/null +++ b/src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Point at the captured immutable outer variable + +fn foo(mut f: Box) { + f(); +} + +fn main() { + let mut y = true; + foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable +} diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 7d02f0b746d..1710a44380f 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -13,6 +13,7 @@ regex = "0.2" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" +rustfix = { git = "https://github.com/rust-lang-nursery/rustfix" } [target.'cfg(unix)'.dependencies] libc = "0.2" diff --git a/src/tools/compiletest/src/autofix.rs b/src/tools/compiletest/src/autofix.rs new file mode 100644 index 00000000000..29ea5cdff8f --- /dev/null +++ b/src/tools/compiletest/src/autofix.rs @@ -0,0 +1,70 @@ +use rustfix::{get_suggestions_from_json, Replacement}; +use std::collections::HashSet; +use std::error::Error; + +pub fn run_rustfix(code: &str, json: &str) -> String { + let suggestions = get_suggestions_from_json(&json, &HashSet::new()) + .expect("could not load suggestions"); + + let mut fixed = code.to_string(); + + for sug in suggestions.into_iter().rev() { + for sol in sug.solutions { + for r in sol.replacements { + fixed = apply_suggestion(&mut fixed, &r) + .expect("could not apply suggestion"); + } + } + } + + fixed +} + +fn apply_suggestion( + file_content: &mut String, + suggestion: &Replacement, +) -> Result> { + use std::cmp::max; + + let mut new_content = String::new(); + + // Add the lines before the section we want to replace + new_content.push_str(&file_content + .lines() + .take(max(suggestion.snippet.line_range.start.line - 1, 0) as usize) + .collect::>() + .join("\n")); + new_content.push_str("\n"); + + // Parts of line before replacement + new_content.push_str(&file_content + .lines() + .nth(suggestion.snippet.line_range.start.line - 1) + .unwrap_or("") + .chars() + .take(suggestion.snippet.line_range.start.column - 1) + .collect::()); + + // Insert new content! Finally! + new_content.push_str(&suggestion.replacement); + + // Parts of line after replacement + new_content.push_str(&file_content + .lines() + .nth(suggestion.snippet.line_range.end.line - 1) + .unwrap_or("") + .chars() + .skip(suggestion.snippet.line_range.end.column - 1) + .collect::()); + + // Add the lines after the section we want to replace + new_content.push_str("\n"); + new_content.push_str(&file_content + .lines() + .skip(suggestion.snippet.line_range.end.line as usize) + .collect::>() + .join("\n")); + new_content.push_str("\n"); + + Ok(new_content) +} diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 365b47447f2..5159b1a692e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -269,6 +269,7 @@ pub fn expected_output_path(testpaths: &TestPaths, testpaths.file.with_extension(extension) } -pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT]; +pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT, UI_FIXED]; pub const UI_STDERR: &str = "stderr"; pub const UI_STDOUT: &str = "stdout"; +pub const UI_FIXED: &str = "rs.fixed"; diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 37f7af0abe8..3e7c6500433 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -26,6 +26,7 @@ extern crate regex; extern crate serde_derive; extern crate serde_json; extern crate test; +extern crate rustfix; use std::env; use std::ffi::OsString; @@ -52,6 +53,7 @@ pub mod common; pub mod errors; mod raise_fd_limit; mod read2; +mod autofix; fn main() { env_logger::init(); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 01d9f52424d..20456a21cb5 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -12,7 +12,7 @@ use common::{Config, TestPaths}; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; use common::{Incremental, MirOpt, RunMake, Ui}; -use common::{expected_output_path, UI_STDERR, UI_STDOUT}; +use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED}; use common::CompareMode; use diff; use errors::{self, Error, ErrorKind}; @@ -35,6 +35,7 @@ use std::path::{Path, PathBuf}; use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::str; +use autofix::run_rustfix; use extract_gdb_version; /// The name of the environment variable that holds dynamic library locations. @@ -2603,6 +2604,19 @@ impl<'test> TestCx<'test> { self.check_error_patterns(&proc_res.stderr, &proc_res); } } + + let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); + if fixture_path.exists() { + let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) + .unwrap(); + let expected_fixed = self.load_expected_output_from_path(&fixture_path).unwrap(); + let fixed_code = run_rustfix(&unfixed_code, &proc_res.stderr); + let errors = self.compare_output("rs.fixed", &fixed_code, &expected_fixed); + if errors > 0 { + panic!("rustfix produced different fixed file!"); + // TODO: Add info for update-references.sh call + } + } } fn run_mir_opt_test(&self) { -- cgit 1.4.1-3-g733a5 From c02aedfcafafe3d2d0fbb4e9d85b2bbbbfa9abb2 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Wed, 2 May 2018 00:32:31 +0200 Subject: Use rustfix' suggestion fixing API Uses branch from until we publish a new release. --- src/tools/compiletest/Cargo.toml | 2 +- src/tools/compiletest/src/autofix.rs | 70 ------------------------------------ src/tools/compiletest/src/main.rs | 1 - src/tools/compiletest/src/runtest.rs | 7 ++-- 4 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 src/tools/compiletest/src/autofix.rs (limited to 'src/tools') diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 1710a44380f..476e5927a2f 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -13,7 +13,7 @@ regex = "0.2" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" -rustfix = { git = "https://github.com/rust-lang-nursery/rustfix" } +rustfix = { git = "https://github.com/rust-lang-nursery/rustfix", branch = "apply_suggestion" } [target.'cfg(unix)'.dependencies] libc = "0.2" diff --git a/src/tools/compiletest/src/autofix.rs b/src/tools/compiletest/src/autofix.rs deleted file mode 100644 index 29ea5cdff8f..00000000000 --- a/src/tools/compiletest/src/autofix.rs +++ /dev/null @@ -1,70 +0,0 @@ -use rustfix::{get_suggestions_from_json, Replacement}; -use std::collections::HashSet; -use std::error::Error; - -pub fn run_rustfix(code: &str, json: &str) -> String { - let suggestions = get_suggestions_from_json(&json, &HashSet::new()) - .expect("could not load suggestions"); - - let mut fixed = code.to_string(); - - for sug in suggestions.into_iter().rev() { - for sol in sug.solutions { - for r in sol.replacements { - fixed = apply_suggestion(&mut fixed, &r) - .expect("could not apply suggestion"); - } - } - } - - fixed -} - -fn apply_suggestion( - file_content: &mut String, - suggestion: &Replacement, -) -> Result> { - use std::cmp::max; - - let mut new_content = String::new(); - - // Add the lines before the section we want to replace - new_content.push_str(&file_content - .lines() - .take(max(suggestion.snippet.line_range.start.line - 1, 0) as usize) - .collect::>() - .join("\n")); - new_content.push_str("\n"); - - // Parts of line before replacement - new_content.push_str(&file_content - .lines() - .nth(suggestion.snippet.line_range.start.line - 1) - .unwrap_or("") - .chars() - .take(suggestion.snippet.line_range.start.column - 1) - .collect::()); - - // Insert new content! Finally! - new_content.push_str(&suggestion.replacement); - - // Parts of line after replacement - new_content.push_str(&file_content - .lines() - .nth(suggestion.snippet.line_range.end.line - 1) - .unwrap_or("") - .chars() - .skip(suggestion.snippet.line_range.end.column - 1) - .collect::()); - - // Add the lines after the section we want to replace - new_content.push_str("\n"); - new_content.push_str(&file_content - .lines() - .skip(suggestion.snippet.line_range.end.line as usize) - .collect::>() - .join("\n")); - new_content.push_str("\n"); - - Ok(new_content) -} diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 3e7c6500433..a7849d53c3d 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -53,7 +53,6 @@ pub mod common; pub mod errors; mod raise_fd_limit; mod read2; -mod autofix; fn main() { env_logger::init(); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 20456a21cb5..f0feb9b50f1 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -35,7 +35,6 @@ use std::path::{Path, PathBuf}; use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::str; -use autofix::run_rustfix; use extract_gdb_version; /// The name of the environment variable that holds dynamic library locations. @@ -2607,10 +2606,14 @@ impl<'test> TestCx<'test> { let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); if fixture_path.exists() { + use std::collections::HashSet; + use rustfix::{apply_suggestions, get_suggestions_from_json}; + let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) .unwrap(); let expected_fixed = self.load_expected_output_from_path(&fixture_path).unwrap(); - let fixed_code = run_rustfix(&unfixed_code, &proc_res.stderr); + let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); + let fixed_code = apply_suggestions(&unfixed_code, &suggestions); let errors = self.compare_output("rs.fixed", &fixed_code, &expected_fixed); if errors > 0 { panic!("rustfix produced different fixed file!"); -- cgit 1.4.1-3-g733a5 From 9680f3b381767010c97b5d3ea0a14fdc19efde0c Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Wed, 2 May 2018 00:33:59 +0200 Subject: Skip NLL compiletest in rustfix mode for now --- src/tools/compiletest/src/common.rs | 4 ++-- src/tools/compiletest/src/runtest.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tools') diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 5159b1a692e..df0cf61e7c4 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -95,9 +95,9 @@ impl fmt::Display for Mode { } } -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub enum CompareMode { - Nll + Nll, } impl CompareMode { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index f0feb9b50f1..a7c34921842 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2605,7 +2605,10 @@ impl<'test> TestCx<'test> { } let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); - if fixture_path.exists() { + + // TODO(killercup): Add `nll.rs.fixed` files matching + let nll = self.config.compare_mode.as_ref().map(|x| *x == CompareMode::Nll).unwrap_or(false); + if fixture_path.exists() && !nll { use std::collections::HashSet; use rustfix::{apply_suggestions, get_suggestions_from_json}; -- cgit 1.4.1-3-g733a5 From b2645044039cb59858ec494e0ddacbe597757cdb Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Wed, 2 May 2018 00:44:39 +0200 Subject: tidy --- src/tools/compiletest/src/runtest.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tools') diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a7c34921842..745952ddf9e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2606,8 +2606,11 @@ impl<'test> TestCx<'test> { let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); - // TODO(killercup): Add `nll.rs.fixed` files matching - let nll = self.config.compare_mode.as_ref().map(|x| *x == CompareMode::Nll).unwrap_or(false); + // FIXME(killercup): Add `nll.rs.fixed` files matching + let nll = self.config.compare_mode + .as_ref() + .map(|x| *x == CompareMode::Nll) + .unwrap_or(false); if fixture_path.exists() && !nll { use std::collections::HashSet; use rustfix::{apply_suggestions, get_suggestions_from_json}; @@ -2620,7 +2623,7 @@ impl<'test> TestCx<'test> { let errors = self.compare_output("rs.fixed", &fixed_code, &expected_fixed); if errors > 0 { panic!("rustfix produced different fixed file!"); - // TODO: Add info for update-references.sh call + // FIXME(killercup): Add info for update-references.sh call } } } -- cgit 1.4.1-3-g733a5 From fa9e55faeb0b4fac282ed47f20780c05f4efc86d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 May 2018 08:43:15 -0700 Subject: test: Make a dedicated testsuite for rustfix This commit adds a dedicated mode to compiletest for running rustfix tests, adding a new `src/test/rustfix` directory which will execute all tests as a "rustfix" test, namely requiring that a `*.fixed` is next to the main file which is the result of the rustfix project's application of fixes. The `rustfix` crate is pulled in to actually perform the fixing, and the rustfix compiletest mode will assert a few properties about the fixing: * The expected fixed output must be the same as rustc's output suggestions applied to the original code. * The fixed code must compile successfully * The fixed code must have no further diagnostics emitted about it --- src/Cargo.lock | 15 ++++ src/bootstrap/builder.rs | 2 +- src/bootstrap/test.rs | 6 ++ .../rustfix/closure-immutable-outer-variable.fixed | 20 ++++++ .../rustfix/closure-immutable-outer-variable.rs | 20 ++++++ src/test/rustfix/empty-no-fixes.fixed | 11 +++ src/test/rustfix/empty-no-fixes.rs | 11 +++ src/test/rustfix/empty-no-fixes.rs.fixed | 12 ++++ src/test/rustfix/issue-45562.fixed | 13 ++++ src/test/rustfix/issue-45562.rs | 13 ++++ ...extern-crate-rename-suggestion-formatting.fixed | 12 ++++ ...ad-extern-crate-rename-suggestion-formatting.rs | 12 ++++ ...-46756-consider-borrowing-cast-or-binexpr.fixed | 22 ++++++ ...sue-46756-consider-borrowing-cast-or-binexpr.rs | 22 ++++++ src/test/rustfix/main-no-fixes.fixed | 11 +++ src/test/rustfix/main-no-fixes.rs | 11 +++ src/test/rustfix/main-no-fixes.rs.fixed | 11 +++ src/test/rustfix/missing-comma-in-match.fixed | 17 +++++ src/test/rustfix/missing-comma-in-match.rs | 17 +++++ src/test/rustfix/str-as-char.fixed | 13 ++++ src/test/rustfix/str-as-char.rs | 13 ++++ src/test/rustfix/tuple-float-index.fixed | 15 ++++ src/test/rustfix/tuple-float-index.rs | 15 ++++ src/test/rustfix/update-all-references.sh | 31 ++++++++ src/test/rustfix/update-references.sh | 45 ++++++++++++ src/tools/compiletest/src/common.rs | 41 ++++++----- src/tools/compiletest/src/runtest.rs | 84 +++++++++++++++------- 27 files changed, 471 insertions(+), 44 deletions(-) create mode 100644 src/test/rustfix/closure-immutable-outer-variable.fixed create mode 100644 src/test/rustfix/closure-immutable-outer-variable.rs create mode 100644 src/test/rustfix/empty-no-fixes.fixed create mode 100644 src/test/rustfix/empty-no-fixes.rs create mode 100644 src/test/rustfix/empty-no-fixes.rs.fixed create mode 100644 src/test/rustfix/issue-45562.fixed create mode 100644 src/test/rustfix/issue-45562.rs create mode 100644 src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed create mode 100644 src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs create mode 100644 src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed create mode 100644 src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs create mode 100644 src/test/rustfix/main-no-fixes.fixed create mode 100644 src/test/rustfix/main-no-fixes.rs create mode 100644 src/test/rustfix/main-no-fixes.rs.fixed create mode 100644 src/test/rustfix/missing-comma-in-match.fixed create mode 100644 src/test/rustfix/missing-comma-in-match.rs create mode 100644 src/test/rustfix/str-as-char.fixed create mode 100644 src/test/rustfix/str-as-char.rs create mode 100644 src/test/rustfix/tuple-float-index.fixed create mode 100644 src/test/rustfix/tuple-float-index.rs create mode 100755 src/test/rustfix/update-all-references.sh create mode 100755 src/test/rustfix/update-references.sh (limited to 'src/tools') diff --git a/src/Cargo.lock b/src/Cargo.lock index ccdb24d7375..113369c9971 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -394,6 +394,7 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rustfix 0.1.0 (git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2234,6 +2235,19 @@ dependencies = [ "rustdoc 0.0.0", ] +[[package]] +name = "rustfix" +version = "0.1.0" +source = "git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion#571b43a1a1777561ddd7a41b37512bf0e3452c1a" +dependencies = [ + "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", + "colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustfmt-nightly" version = "0.6.1" @@ -3146,6 +3160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55793c2a775230c42661194c48d44b35d4c8439d79ad8528e56651e854c48c63" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +"checksum rustfix 0.1.0 (git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion)" = "" "checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" "checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637" "checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade" diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 08bb8ab4815..5920e356bca 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -326,7 +326,7 @@ impl<'a> Builder<'a> { test::TheBook, test::UnstableBook, test::RustcBook, test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme, // Run run-make last, since these won't pass without make on Windows - test::RunMake, test::RustdocUi), + test::RunMake, test::RustdocUi, test::Rustfix), Kind::Bench => describe!(test::Crate, test::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e8c40dfdb0a..fa32dd31635 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -716,6 +716,12 @@ default_test!(RunFail { suite: "run-fail" }); +default_test!(Rustfix { + path: "src/test/rustfix", + mode: "rustfix", + suite: "rustfix" +}); + default_test!(RunPassValgrind { path: "src/test/run-pass-valgrind", mode: "run-pass-valgrind", diff --git a/src/test/rustfix/closure-immutable-outer-variable.fixed b/src/test/rustfix/closure-immutable-outer-variable.fixed new file mode 100644 index 00000000000..bddc2eab16d --- /dev/null +++ b/src/test/rustfix/closure-immutable-outer-variable.fixed @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Point at the captured immutable outer variable + +fn foo(mut f: Box) { + f(); +} + +fn main() { + let mut y = true; + foo(Box::new(move || y = false) as Box<_>); +} diff --git a/src/test/rustfix/closure-immutable-outer-variable.rs b/src/test/rustfix/closure-immutable-outer-variable.rs new file mode 100644 index 00000000000..fe8e2bc6c8e --- /dev/null +++ b/src/test/rustfix/closure-immutable-outer-variable.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Point at the captured immutable outer variable + +fn foo(mut f: Box) { + f(); +} + +fn main() { + let y = true; + foo(Box::new(move || y = false) as Box<_>); +} diff --git a/src/test/rustfix/empty-no-fixes.fixed b/src/test/rustfix/empty-no-fixes.fixed new file mode 100644 index 00000000000..39e19566d76 --- /dev/null +++ b/src/test/rustfix/empty-no-fixes.fixed @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--crate-type lib diff --git a/src/test/rustfix/empty-no-fixes.rs b/src/test/rustfix/empty-no-fixes.rs new file mode 100644 index 00000000000..39e19566d76 --- /dev/null +++ b/src/test/rustfix/empty-no-fixes.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--crate-type lib diff --git a/src/test/rustfix/empty-no-fixes.rs.fixed b/src/test/rustfix/empty-no-fixes.rs.fixed new file mode 100644 index 00000000000..ee58e778253 --- /dev/null +++ b/src/test/rustfix/empty-no-fixes.rs.fixed @@ -0,0 +1,12 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--crate-type lib +fn foo() {} diff --git a/src/test/rustfix/issue-45562.fixed b/src/test/rustfix/issue-45562.fixed new file mode 100644 index 00000000000..d7a27a11fc0 --- /dev/null +++ b/src/test/rustfix/issue-45562.fixed @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] pub static RAH: usize = 5; + +fn main() {} diff --git a/src/test/rustfix/issue-45562.rs b/src/test/rustfix/issue-45562.rs new file mode 100644 index 00000000000..39576e9c845 --- /dev/null +++ b/src/test/rustfix/issue-45562.rs @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] pub const RAH: usize = 5; + +fn main() {} diff --git a/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed new file mode 100644 index 00000000000..d931f90cd04 --- /dev/null +++ b/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed @@ -0,0 +1,12 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate std as other_std; +fn main() {} diff --git a/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs new file mode 100644 index 00000000000..7c55f9c4eb9 --- /dev/null +++ b/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs @@ -0,0 +1,12 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate std; +fn main() {} diff --git a/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed new file mode 100644 index 00000000000..aaa04ef4004 --- /dev/null +++ b/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { + and_yet + 1 +} + +fn main() { + let behold: isize = 2; + let with_tears: usize = 3; + light_flows_our_war_of_mocking_words(&(behold as usize)); + light_flows_our_war_of_mocking_words(&(with_tears + 4)); +} diff --git a/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs b/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs new file mode 100644 index 00000000000..d21681747e9 --- /dev/null +++ b/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { + and_yet + 1 +} + +fn main() { + let behold: isize = 2; + let with_tears: usize = 3; + light_flows_our_war_of_mocking_words(behold as usize); + light_flows_our_war_of_mocking_words(with_tears + 4); +} diff --git a/src/test/rustfix/main-no-fixes.fixed b/src/test/rustfix/main-no-fixes.fixed new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/rustfix/main-no-fixes.fixed @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/rustfix/main-no-fixes.rs b/src/test/rustfix/main-no-fixes.rs new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/rustfix/main-no-fixes.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/rustfix/main-no-fixes.rs.fixed b/src/test/rustfix/main-no-fixes.rs.fixed new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/rustfix/main-no-fixes.rs.fixed @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/rustfix/missing-comma-in-match.fixed b/src/test/rustfix/missing-comma-in-match.fixed new file mode 100644 index 00000000000..621a4127bc2 --- /dev/null +++ b/src/test/rustfix/missing-comma-in-match.fixed @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match &Some(3) { + &None => 1, + &Some(2) => { 3 } + _ => 2 + }; +} diff --git a/src/test/rustfix/missing-comma-in-match.rs b/src/test/rustfix/missing-comma-in-match.rs new file mode 100644 index 00000000000..8ccad7b9c94 --- /dev/null +++ b/src/test/rustfix/missing-comma-in-match.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match &Some(3) { + &None => 1 + &Some(2) => { 3 } + _ => 2 + }; +} diff --git a/src/test/rustfix/str-as-char.fixed b/src/test/rustfix/str-as-char.fixed new file mode 100644 index 00000000000..0ace6d96613 --- /dev/null +++ b/src/test/rustfix/str-as-char.fixed @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("●●"); +} diff --git a/src/test/rustfix/str-as-char.rs b/src/test/rustfix/str-as-char.rs new file mode 100644 index 00000000000..fa0e474fc7f --- /dev/null +++ b/src/test/rustfix/str-as-char.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!('●●'); +} diff --git a/src/test/rustfix/tuple-float-index.fixed b/src/test/rustfix/tuple-float-index.fixed new file mode 100644 index 00000000000..9cb7537b428 --- /dev/null +++ b/src/test/rustfix/tuple-float-index.fixed @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main () { + ((1, (2, 3)).1).1; +} diff --git a/src/test/rustfix/tuple-float-index.rs b/src/test/rustfix/tuple-float-index.rs new file mode 100644 index 00000000000..8bfbd0e74db --- /dev/null +++ b/src/test/rustfix/tuple-float-index.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main () { + (1, (2, 3)).1.1; +} diff --git a/src/test/rustfix/update-all-references.sh b/src/test/rustfix/update-all-references.sh new file mode 100755 index 00000000000..c3f615066bb --- /dev/null +++ b/src/test/rustfix/update-all-references.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Copyright 2015 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# A script to update the references for all tests. The idea is that +# you do a run, which will generate files in the build directory +# containing the (normalized) actual output of the compiler. You then +# run this script, which will copy those files over. If you find +# yourself manually editing a foo.stderr file, you're doing it wrong. +# +# See all `update-references.sh`, if you just want to update a single test. + +if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" != "" ]]; then + echo "usage: $0 " + echo "" + echo "For example:" + echo " $0 ../../../build/x86_64-apple-darwin/test/rustfix" +fi + +BUILD_DIR=$PWD/$1 +MY_DIR=$(dirname $0) +cd $MY_DIR +find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR diff --git a/src/test/rustfix/update-references.sh b/src/test/rustfix/update-references.sh new file mode 100755 index 00000000000..bcca2fec10d --- /dev/null +++ b/src/test/rustfix/update-references.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Copyright 2015 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# A script to update the references for particular tests. The idea is +# that you do a run, which will generate files in the build directory +# containing the (normalized) actual output of the compiler. This +# script will then copy that output and replace the "expected output" +# files. You can then commit the changes. +# +# If you find yourself manually editing a foo.stderr file, you're +# doing it wrong. + +if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then + echo "usage: $0 " + echo "" + echo "For example:" + echo " $0 ../../../build/x86_64-apple-darwin/test/rustfix *.rs */*.rs" +fi + +MYDIR=$(dirname $0) + +BUILD_DIR="$1" +shift + +shopt -s nullglob + +while [[ "$1" != "" ]]; do + for OUT_NAME in $BUILD_DIR/${1%.rs}.*fixed; do + OUT_BASE=`basename "$OUT_NAME"` + if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then + echo updating $MYDIR/$OUT_BASE + cp $OUT_NAME $MYDIR + fi + done + shift +done diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index df0cf61e7c4..733fc1f16d2 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -32,6 +32,7 @@ pub enum Mode { RunMake, Ui, MirOpt, + Rustfix, } impl Mode { @@ -67,6 +68,7 @@ impl FromStr for Mode { "run-make" => Ok(RunMake), "ui" => Ok(Ui), "mir-opt" => Ok(MirOpt), + "rustfix" => Ok(Rustfix), _ => Err(()), } } @@ -74,24 +76,25 @@ impl FromStr for Mode { impl fmt::Display for Mode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(match *self { - CompileFail => "compile-fail", - ParseFail => "parse-fail", - RunFail => "run-fail", - RunPass => "run-pass", - RunPassValgrind => "run-pass-valgrind", - Pretty => "pretty", - DebugInfoGdb => "debuginfo-gdb", - DebugInfoLldb => "debuginfo-lldb", - Codegen => "codegen", - Rustdoc => "rustdoc", - CodegenUnits => "codegen-units", - Incremental => "incremental", - RunMake => "run-make", - Ui => "ui", - MirOpt => "mir-opt", - }, - f) + let s = match *self { + CompileFail => "compile-fail", + ParseFail => "parse-fail", + RunFail => "run-fail", + RunPass => "run-pass", + RunPassValgrind => "run-pass-valgrind", + Pretty => "pretty", + DebugInfoGdb => "debuginfo-gdb", + DebugInfoLldb => "debuginfo-lldb", + Codegen => "codegen", + Rustdoc => "rustdoc", + CodegenUnits => "codegen-units", + Incremental => "incremental", + RunMake => "run-make", + Ui => "ui", + MirOpt => "mir-opt", + Rustfix => "rustfix", + }; + fmt::Display::fmt(s, f) } } @@ -272,4 +275,4 @@ pub fn expected_output_path(testpaths: &TestPaths, pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT, UI_FIXED]; pub const UI_STDERR: &str = "stderr"; pub const UI_STDOUT: &str = "stdout"; -pub const UI_FIXED: &str = "rs.fixed"; +pub const UI_FIXED: &str = "fixed"; diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 745952ddf9e..ea1863b2fd1 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -11,7 +11,7 @@ use common::{Config, TestPaths}; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; -use common::{Incremental, MirOpt, RunMake, Ui}; +use common::{Incremental, MirOpt, RunMake, Ui, Rustfix}; use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED}; use common::CompareMode; use diff; @@ -21,6 +21,7 @@ use json; use header::TestProps; use util::logv; use regex::Regex; +use rustfix::{apply_suggestions, get_suggestions_from_json}; use std::collections::VecDeque; use std::collections::HashMap; @@ -241,6 +242,7 @@ impl<'test> TestCx<'test> { CodegenUnits => self.run_codegen_units_test(), Incremental => self.run_incremental_test(), RunMake => self.run_rmake_test(), + Rustfix => self.run_rustfix_test(), Ui => self.run_ui_test(), MirOpt => self.run_mir_opt_test(), } @@ -1687,6 +1689,7 @@ impl<'test> TestCx<'test> { rustc.arg(dir_opt); } + Rustfix | RunPass | RunFail | RunPassValgrind | @@ -2603,29 +2606,6 @@ impl<'test> TestCx<'test> { self.check_error_patterns(&proc_res.stderr, &proc_res); } } - - let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); - - // FIXME(killercup): Add `nll.rs.fixed` files matching - let nll = self.config.compare_mode - .as_ref() - .map(|x| *x == CompareMode::Nll) - .unwrap_or(false); - if fixture_path.exists() && !nll { - use std::collections::HashSet; - use rustfix::{apply_suggestions, get_suggestions_from_json}; - - let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) - .unwrap(); - let expected_fixed = self.load_expected_output_from_path(&fixture_path).unwrap(); - let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); - let fixed_code = apply_suggestions(&unfixed_code, &suggestions); - let errors = self.compare_output("rs.fixed", &fixed_code, &expected_fixed); - if errors > 0 { - panic!("rustfix produced different fixed file!"); - // FIXME(killercup): Add info for update-references.sh call - } - } } fn run_mir_opt_test(&self) { @@ -2950,6 +2930,62 @@ impl<'test> TestCx<'test> { println!("Actual {} saved to {}", kind, output_file.display()); 1 } + + fn run_rustfix_test(&self) { + // First up, compile the test with --error-format=json + let mut rustc = self.make_compile_args( + &self.testpaths.file, + TargetLocation::ThisFile(self.make_exe_name()), + ); + rustc.arg("--error-format").arg("json") + .arg("-L").arg(&self.aux_output_dir_name()); + let proc_res = self.compose_and_run_compiler(rustc, None); + + // Now apply suggestions from rustc to the code itself + let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) + .unwrap(); + let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); + let fixed_code = apply_suggestions(&unfixed_code, &suggestions); + + // Load up what the expected result of fixing should be + let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); + let expected_fixed = self.load_expected_output_from_path(&fixture_path) + .unwrap_or(String::new()); + + // Make sure our fixed code is the same as what we're expecting + let errors = self.compare_output(UI_FIXED, &fixed_code, &expected_fixed); + if errors > 0 { + println!("To update references, run this command from build directory:"); + let relative_path_to_file = self.testpaths + .relative_dir + .join(self.testpaths.file.file_name().unwrap()); + println!( + "{}/update-references.sh '{}' '{}'", + self.config.src_base.display(), + self.config.build_base.display(), + relative_path_to_file.display() + ); + self.fatal_proc_rec( + &format!("{} errors occurred comparing output.", errors), + &proc_res, + ); + } + + // And finally, compile the fixed code and make sure it both succeeds + // and has no diagnostics. + let mut rustc = self.make_compile_args( + &self.testpaths.file.with_extension(UI_FIXED), + TargetLocation::ThisFile(self.make_exe_name()), + ); + rustc.arg("-L").arg(&self.aux_output_dir_name()); + let res = self.compose_and_run_compiler(rustc, None); + if !res.status.success() { + self.fatal_proc_rec("failed to compile fixed code", &res); + } + if !res.stderr.is_empty() { + self.fatal_proc_rec("fixed code is still producing diagnostics", &res); + } + } } struct ProcArgs { -- cgit 1.4.1-3-g733a5 From a563027cb8f2cb1c46d2a1e59f3686d3f3a3213a Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 3 May 2018 15:35:42 +0200 Subject: Use published rustfix 0.2 version --- src/Cargo.lock | 10 ++++------ src/tools/compiletest/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/tools') diff --git a/src/Cargo.lock b/src/Cargo.lock index 113369c9971..0f08eaf596a 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -394,7 +394,7 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfix 0.1.0 (git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion)", + "rustfix 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2237,11 +2237,9 @@ dependencies = [ [[package]] name = "rustfix" -version = "0.1.0" -source = "git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion#571b43a1a1777561ddd7a41b37512bf0e3452c1a" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", - "colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3160,7 +3158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55793c2a775230c42661194c48d44b35d4c8439d79ad8528e56651e854c48c63" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum rustfix 0.1.0 (git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion)" = "" +"checksum rustfix 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "165a212dd11124d7070892da20f71d82970ef1d1dd41cd804b70f39740a21c85" "checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" "checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637" "checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade" diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 476e5927a2f..77554f244c8 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -13,7 +13,7 @@ regex = "0.2" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" -rustfix = { git = "https://github.com/rust-lang-nursery/rustfix", branch = "apply_suggestion" } +rustfix = "0.2" [target.'cfg(unix)'.dependencies] libc = "0.2" -- cgit 1.4.1-3-g733a5 From 6f2d023028bbd666be2c211b923b32faf10a41da Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 3 May 2018 11:26:58 -0700 Subject: Fold rustfix tests back into the UI test suite --- src/bootstrap/builder.rs | 2 +- src/bootstrap/test.rs | 6 -- .../closure-immutable-outer-variable.fixed | 22 +++++ .../closure-immutable-outer-variable.nll.fixed | 22 +++++ .../closure-immutable-outer-variable.nll.stderr | 2 +- .../closure-immutable-outer-variable.rs | 2 + .../closure-immutable-outer-variable.stderr | 2 +- src/test/ui/suggestions/issue-45562.fixed | 16 ++++ src/test/ui/suggestions/issue-45562.rs | 2 + src/test/ui/suggestions/issue-45562.stderr | 2 +- ...extern-crate-rename-suggestion-formatting.fixed | 15 ++++ ...ad-extern-crate-rename-suggestion-formatting.rs | 2 + ...xtern-crate-rename-suggestion-formatting.stderr | 2 +- ...-46756-consider-borrowing-cast-or-binexpr.fixed | 26 ++++++ ...sue-46756-consider-borrowing-cast-or-binexpr.rs | 2 + ...46756-consider-borrowing-cast-or-binexpr.stderr | 4 +- .../ui/suggestions/missing-comma-in-match.fixed | 21 +++++ src/test/ui/suggestions/missing-comma-in-match.rs | 2 + .../ui/suggestions/missing-comma-in-match.stderr | 2 +- src/test/ui/suggestions/str-as-char.fixed | 16 ++++ src/test/ui/suggestions/str-as-char.rs | 2 + src/test/ui/suggestions/str-as-char.stderr | 2 +- src/test/ui/suggestions/tuple-float-index.fixed | 16 ++++ src/test/ui/suggestions/tuple-float-index.rs | 1 + src/test/ui/suggestions/tuple-float-index.stderr | 2 +- src/test/ui/update-references.sh | 4 +- src/tools/compiletest/src/common.rs | 3 - src/tools/compiletest/src/header.rs | 10 +++ src/tools/compiletest/src/runtest.rs | 93 ++++++++-------------- 29 files changed, 223 insertions(+), 80 deletions(-) create mode 100644 src/test/ui/suggestions/closure-immutable-outer-variable.fixed create mode 100644 src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed create mode 100644 src/test/ui/suggestions/issue-45562.fixed create mode 100644 src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed create mode 100644 src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed create mode 100644 src/test/ui/suggestions/missing-comma-in-match.fixed create mode 100644 src/test/ui/suggestions/str-as-char.fixed create mode 100644 src/test/ui/suggestions/tuple-float-index.fixed (limited to 'src/tools') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 5920e356bca..08bb8ab4815 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -326,7 +326,7 @@ impl<'a> Builder<'a> { test::TheBook, test::UnstableBook, test::RustcBook, test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme, // Run run-make last, since these won't pass without make on Windows - test::RunMake, test::RustdocUi, test::Rustfix), + test::RunMake, test::RustdocUi), Kind::Bench => describe!(test::Crate, test::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index fa32dd31635..e8c40dfdb0a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -716,12 +716,6 @@ default_test!(RunFail { suite: "run-fail" }); -default_test!(Rustfix { - path: "src/test/rustfix", - mode: "rustfix", - suite: "rustfix" -}); - default_test!(RunPassValgrind { path: "src/test/run-pass-valgrind", mode: "run-pass-valgrind", diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.fixed new file mode 100644 index 00000000000..b3a0d592f76 --- /dev/null +++ b/src/test/ui/suggestions/closure-immutable-outer-variable.fixed @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +// Point at the captured immutable outer variable + +fn foo(mut f: Box) { + f(); +} + +fn main() { + let mut y = true; + foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable +} diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed new file mode 100644 index 00000000000..e162678460c --- /dev/null +++ b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +// Point at the captured immutable outer variable + +fn foo(mut f: Box) { + f(); +} + +fn main() { + let y = true; + foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable +} diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr index e4e93ecac8e..bc655114c2b 100644 --- a/src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr +++ b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to immutable item `y` - --> $DIR/closure-immutable-outer-variable.rs:19:26 + --> $DIR/closure-immutable-outer-variable.rs:21:26 | LL | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable | ^^^^^^^^^ cannot mutate diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.rs b/src/test/ui/suggestions/closure-immutable-outer-variable.rs index 1d14afd6a01..e162678460c 100644 --- a/src/test/ui/suggestions/closure-immutable-outer-variable.rs +++ b/src/test/ui/suggestions/closure-immutable-outer-variable.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + // Point at the captured immutable outer variable fn foo(mut f: Box) { diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.stderr b/src/test/ui/suggestions/closure-immutable-outer-variable.stderr index 3353e2c7291..0ee11d8cf15 100644 --- a/src/test/ui/suggestions/closure-immutable-outer-variable.stderr +++ b/src/test/ui/suggestions/closure-immutable-outer-variable.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to captured outer variable in an `FnMut` closure - --> $DIR/closure-immutable-outer-variable.rs:19:26 + --> $DIR/closure-immutable-outer-variable.rs:21:26 | LL | let y = true; | - help: consider making `y` mutable: `mut y` diff --git a/src/test/ui/suggestions/issue-45562.fixed b/src/test/ui/suggestions/issue-45562.fixed new file mode 100644 index 00000000000..7c01f0d1ee5 --- /dev/null +++ b/src/test/ui/suggestions/issue-45562.fixed @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +#[no_mangle] pub static RAH: usize = 5; +//~^ ERROR const items should never be #[no_mangle] + +fn main() {} diff --git a/src/test/ui/suggestions/issue-45562.rs b/src/test/ui/suggestions/issue-45562.rs index f493df56f94..c27d52fcdd3 100644 --- a/src/test/ui/suggestions/issue-45562.rs +++ b/src/test/ui/suggestions/issue-45562.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + #[no_mangle] pub const RAH: usize = 5; //~^ ERROR const items should never be #[no_mangle] diff --git a/src/test/ui/suggestions/issue-45562.stderr b/src/test/ui/suggestions/issue-45562.stderr index d6960dca054..d9e624cadc7 100644 --- a/src/test/ui/suggestions/issue-45562.stderr +++ b/src/test/ui/suggestions/issue-45562.stderr @@ -1,5 +1,5 @@ error: const items should never be #[no_mangle] - --> $DIR/issue-45562.rs:11:14 + --> $DIR/issue-45562.rs:13:14 | LL | #[no_mangle] pub const RAH: usize = 5; | ---------^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed new file mode 100644 index 00000000000..e3287030408 --- /dev/null +++ b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +extern crate std as other_std; +fn main() {} +//~^^ ERROR the name `std` is defined multiple times [E0259] diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs index 4d75127b645..f47ea474d51 100644 --- a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs +++ b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + extern crate std; fn main() {} //~^^ ERROR the name `std` is defined multiple times [E0259] diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr index 8e2b2d845e9..ecdfec2b3bf 100644 --- a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr +++ b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr @@ -1,5 +1,5 @@ error[E0259]: the name `std` is defined multiple times - --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:11:1 + --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:13:1 | LL | extern crate std; | ^^^^^^^^^^^^^^^^^ `std` reimported here diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed new file mode 100644 index 00000000000..77171cad6e7 --- /dev/null +++ b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +#![allow(unused)] + +fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { + and_yet + 1 +} + +fn main() { + let behold: isize = 2; + let with_tears: usize = 3; + light_flows_our_war_of_mocking_words(&(behold as usize)); + //~^ ERROR mismatched types [E0308] + light_flows_our_war_of_mocking_words(&(with_tears + 4)); + //~^ ERROR mismatched types [E0308] +} diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs index 5617c46afa9..e5ea9b5ed09 100644 --- a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs +++ b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + #![allow(unused)] fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr index e89e9dce94d..9c492751ca1 100644 --- a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr +++ b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:20:42 + --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42 | LL | light_flows_our_war_of_mocking_words(behold as usize); | ^^^^^^^^^^^^^^^ @@ -11,7 +11,7 @@ LL | light_flows_our_war_of_mocking_words(behold as usize); found type `usize` error[E0308]: mismatched types - --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42 + --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:24:42 | LL | light_flows_our_war_of_mocking_words(with_tears + 4); | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/suggestions/missing-comma-in-match.fixed b/src/test/ui/suggestions/missing-comma-in-match.fixed new file mode 100644 index 00000000000..4832f35f42d --- /dev/null +++ b/src/test/ui/suggestions/missing-comma-in-match.fixed @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +fn main() { + match &Some(3) { + &None => 1, + &Some(2) => { 3 } + //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` + //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here + _ => 2 + }; +} diff --git a/src/test/ui/suggestions/missing-comma-in-match.rs b/src/test/ui/suggestions/missing-comma-in-match.rs index 6f86cdea3cf..e39b20e77ea 100644 --- a/src/test/ui/suggestions/missing-comma-in-match.rs +++ b/src/test/ui/suggestions/missing-comma-in-match.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + fn main() { match &Some(3) { &None => 1 diff --git a/src/test/ui/suggestions/missing-comma-in-match.stderr b/src/test/ui/suggestions/missing-comma-in-match.stderr index b71a50b6631..77935934107 100644 --- a/src/test/ui/suggestions/missing-comma-in-match.stderr +++ b/src/test/ui/suggestions/missing-comma-in-match.stderr @@ -1,5 +1,5 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` - --> $DIR/missing-comma-in-match.rs:14:18 + --> $DIR/missing-comma-in-match.rs:16:18 | LL | &None => 1 | - help: missing a comma here to end this `match` arm diff --git a/src/test/ui/suggestions/str-as-char.fixed b/src/test/ui/suggestions/str-as-char.fixed new file mode 100644 index 00000000000..c0dad38e436 --- /dev/null +++ b/src/test/ui/suggestions/str-as-char.fixed @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +fn main() { + println!("●●"); + //~^ ERROR character literal may only contain one codepoint +} diff --git a/src/test/ui/suggestions/str-as-char.rs b/src/test/ui/suggestions/str-as-char.rs index 09aca61147d..b5a5df0af7f 100644 --- a/src/test/ui/suggestions/str-as-char.rs +++ b/src/test/ui/suggestions/str-as-char.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + fn main() { println!('●●'); //~^ ERROR character literal may only contain one codepoint diff --git a/src/test/ui/suggestions/str-as-char.stderr b/src/test/ui/suggestions/str-as-char.stderr index d881becf00c..60eb182adf1 100644 --- a/src/test/ui/suggestions/str-as-char.stderr +++ b/src/test/ui/suggestions/str-as-char.stderr @@ -1,5 +1,5 @@ error: character literal may only contain one codepoint - --> $DIR/str-as-char.rs:12:14 + --> $DIR/str-as-char.rs:14:14 | LL | println!('●●'); | ^^^^ diff --git a/src/test/ui/suggestions/tuple-float-index.fixed b/src/test/ui/suggestions/tuple-float-index.fixed new file mode 100644 index 00000000000..55bc2f77dad --- /dev/null +++ b/src/test/ui/suggestions/tuple-float-index.fixed @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix +// compile-flags: -Z parse-only + +fn main () { + ((1, (2, 3)).1).1; //~ ERROR unexpected token: `1.1` +} diff --git a/src/test/ui/suggestions/tuple-float-index.rs b/src/test/ui/suggestions/tuple-float-index.rs index 0a188305a92..d569ca4cb86 100644 --- a/src/test/ui/suggestions/tuple-float-index.rs +++ b/src/test/ui/suggestions/tuple-float-index.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix // compile-flags: -Z parse-only fn main () { diff --git a/src/test/ui/suggestions/tuple-float-index.stderr b/src/test/ui/suggestions/tuple-float-index.stderr index 4a1e34890f4..15af0834f03 100644 --- a/src/test/ui/suggestions/tuple-float-index.stderr +++ b/src/test/ui/suggestions/tuple-float-index.stderr @@ -1,5 +1,5 @@ error: unexpected token: `1.1` - --> $DIR/tuple-float-index.rs:14:17 + --> $DIR/tuple-float-index.rs:15:17 | LL | (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1` | ------------^^^ diff --git a/src/test/ui/update-references.sh b/src/test/ui/update-references.sh index 4fc11daaa3a..47a85352b00 100755 --- a/src/test/ui/update-references.sh +++ b/src/test/ui/update-references.sh @@ -26,7 +26,6 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs" fi -MYDIR=$(dirname $0) BUILD_DIR="$1" shift @@ -34,7 +33,8 @@ shift shopt -s nullglob while [[ "$1" != "" ]]; do - for EXT in "stderr" "stdout"; do + MYDIR=$(dirname $1) + for EXT in "stderr" "stdout" "fixed"; do for OUT_NAME in $BUILD_DIR/${1%.rs}.*$EXT; do OUT_BASE=`basename "$OUT_NAME"` if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 733fc1f16d2..2df52816599 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -32,7 +32,6 @@ pub enum Mode { RunMake, Ui, MirOpt, - Rustfix, } impl Mode { @@ -68,7 +67,6 @@ impl FromStr for Mode { "run-make" => Ok(RunMake), "ui" => Ok(Ui), "mir-opt" => Ok(MirOpt), - "rustfix" => Ok(Rustfix), _ => Err(()), } } @@ -92,7 +90,6 @@ impl fmt::Display for Mode { RunMake => "run-make", Ui => "ui", MirOpt => "mir-opt", - Rustfix => "rustfix", }; fmt::Display::fmt(s, f) } diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 73dd079cf0c..7ac3f5b5b25 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -236,6 +236,7 @@ pub struct TestProps { pub normalize_stdout: Vec<(String, String)>, pub normalize_stderr: Vec<(String, String)>, pub failure_status: i32, + pub run_rustfix: bool, } impl TestProps { @@ -267,6 +268,7 @@ impl TestProps { normalize_stdout: vec![], normalize_stderr: vec![], failure_status: 101, + run_rustfix: false, } } @@ -403,6 +405,10 @@ impl TestProps { if let Some(code) = config.parse_failure_status(ln) { self.failure_status = code; } + + if !self.run_rustfix { + self.run_rustfix = config.parse_run_rustfix(ln); + } }); for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] { @@ -642,6 +648,10 @@ impl Config { None } + + fn parse_run_rustfix(&self, line: &str) -> bool { + self.parse_name_directive(line, "run-rustfix") + } } pub fn lldb_version_to_int(version_string: &str) -> isize { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ea1863b2fd1..fae75c352da 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -11,7 +11,7 @@ use common::{Config, TestPaths}; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; -use common::{Incremental, MirOpt, RunMake, Ui, Rustfix}; +use common::{Incremental, MirOpt, RunMake, Ui}; use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED}; use common::CompareMode; use diff; @@ -242,7 +242,6 @@ impl<'test> TestCx<'test> { CodegenUnits => self.run_codegen_units_test(), Incremental => self.run_incremental_test(), RunMake => self.run_rmake_test(), - Rustfix => self.run_rustfix_test(), Ui => self.run_ui_test(), MirOpt => self.run_mir_opt_test(), } @@ -1689,7 +1688,6 @@ impl<'test> TestCx<'test> { rustc.arg(dir_opt); } - Rustfix | RunPass | RunFail | RunPassValgrind | @@ -2555,6 +2553,7 @@ impl<'test> TestCx<'test> { let expected_stderr = self.load_expected_output(UI_STDERR); let expected_stdout = self.load_expected_output(UI_STDOUT); + let expected_fixed = self.load_expected_output(UI_FIXED); let normalized_stdout = self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout); @@ -2571,6 +2570,21 @@ impl<'test> TestCx<'test> { errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr); + if self.config.compare_mode.is_some() { + // don't test rustfix with nll right now + } else if self.props.run_rustfix { + // Apply suggestions from rustc to the code itself + let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) + .unwrap(); + let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); + let fixed_code = apply_suggestions(&unfixed_code, &suggestions); + + errors += self.compare_output("fixed", &fixed_code, &expected_fixed); + } else if !expected_fixed.is_empty() { + panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \ + file was found"); + } + if errors > 0 { println!("To update references, run this command from build directory:"); let relative_path_to_file = self.testpaths @@ -2606,6 +2620,23 @@ impl<'test> TestCx<'test> { self.check_error_patterns(&proc_res.stderr, &proc_res); } } + + if self.props.run_rustfix && self.config.compare_mode.is_none() { + // And finally, compile the fixed code and make sure it both + // succeeds and has no diagnostics. + let mut rustc = self.make_compile_args( + &self.testpaths.file.with_extension(UI_FIXED), + TargetLocation::ThisFile(self.make_exe_name()), + ); + rustc.arg("-L").arg(&self.aux_output_dir_name()); + let res = self.compose_and_run_compiler(rustc, None); + if !res.status.success() { + self.fatal_proc_rec("failed to compile fixed code", &res); + } + if !res.stderr.is_empty() { + self.fatal_proc_rec("fixed code is still producing diagnostics", &res); + } + } } fn run_mir_opt_test(&self) { @@ -2930,62 +2961,6 @@ impl<'test> TestCx<'test> { println!("Actual {} saved to {}", kind, output_file.display()); 1 } - - fn run_rustfix_test(&self) { - // First up, compile the test with --error-format=json - let mut rustc = self.make_compile_args( - &self.testpaths.file, - TargetLocation::ThisFile(self.make_exe_name()), - ); - rustc.arg("--error-format").arg("json") - .arg("-L").arg(&self.aux_output_dir_name()); - let proc_res = self.compose_and_run_compiler(rustc, None); - - // Now apply suggestions from rustc to the code itself - let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) - .unwrap(); - let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); - let fixed_code = apply_suggestions(&unfixed_code, &suggestions); - - // Load up what the expected result of fixing should be - let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED); - let expected_fixed = self.load_expected_output_from_path(&fixture_path) - .unwrap_or(String::new()); - - // Make sure our fixed code is the same as what we're expecting - let errors = self.compare_output(UI_FIXED, &fixed_code, &expected_fixed); - if errors > 0 { - println!("To update references, run this command from build directory:"); - let relative_path_to_file = self.testpaths - .relative_dir - .join(self.testpaths.file.file_name().unwrap()); - println!( - "{}/update-references.sh '{}' '{}'", - self.config.src_base.display(), - self.config.build_base.display(), - relative_path_to_file.display() - ); - self.fatal_proc_rec( - &format!("{} errors occurred comparing output.", errors), - &proc_res, - ); - } - - // And finally, compile the fixed code and make sure it both succeeds - // and has no diagnostics. - let mut rustc = self.make_compile_args( - &self.testpaths.file.with_extension(UI_FIXED), - TargetLocation::ThisFile(self.make_exe_name()), - ); - rustc.arg("-L").arg(&self.aux_output_dir_name()); - let res = self.compose_and_run_compiler(rustc, None); - if !res.status.success() { - self.fatal_proc_rec("failed to compile fixed code", &res); - } - if !res.stderr.is_empty() { - self.fatal_proc_rec("fixed code is still producing diagnostics", &res); - } - } } struct ProcArgs { -- cgit 1.4.1-3-g733a5 From f24915b67fafe33e87e685d884ff63389b6967cb Mon Sep 17 00:00:00 2001 From: kennytm Date: Sun, 6 May 2018 00:54:12 +0800 Subject: Added a tidy test to ensure libcore cannot contain any tests. --- src/tools/tidy/src/lib.rs | 1 + src/tools/tidy/src/libcoretest.rs | 34 ++++++++++++++++++++++++++++++++++ src/tools/tidy/src/main.rs | 1 + 3 files changed, 36 insertions(+) create mode 100644 src/tools/tidy/src/libcoretest.rs (limited to 'src/tools') diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index fa227436640..022ef57503a 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -51,6 +51,7 @@ pub mod pal; pub mod deps; pub mod ui_tests; pub mod unstable_book; +pub mod libcoretest; fn filter_dirs(path: &Path) -> bool { let skip = [ diff --git a/src/tools/tidy/src/libcoretest.rs b/src/tools/tidy/src/libcoretest.rs new file mode 100644 index 00000000000..ef8b55186b1 --- /dev/null +++ b/src/tools/tidy/src/libcoretest.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Tidy check to ensure `#[test]` is not used directly inside `libcore`. +//! +//! `#![no_core]` libraries cannot be tested directly due to duplicating lang +//! item. All tests must be written externally in `libcore/tests`. + +use std::path::Path; +use std::fs::read_to_string; + +pub fn check(path: &Path, bad: &mut bool) { + let libcore_path = path.join("libcore"); + super::walk( + &libcore_path, + &mut |subpath| t!(subpath.strip_prefix(&libcore_path)).starts_with("tests"), + &mut |subpath| { + if t!(read_to_string(subpath)).contains("#[test]") { + tidy_error!( + bad, + "{} contains #[test]; libcore tests must be placed inside `src/libcore/tests/`", + subpath.display() + ); + } + }, + ); +} diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 24974192795..7b86650823a 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -41,6 +41,7 @@ fn main() { features::check(&path, &mut bad, quiet); pal::check(&path, &mut bad); unstable_book::check(&path, &mut bad); + libcoretest::check(&path, &mut bad); if !args.iter().any(|s| *s == "--no-vendor") { deps::check(&path, &mut bad); } -- cgit 1.4.1-3-g733a5 From e24cbe2da07f1a713bd50a8f30792b145633795e Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Sun, 8 Apr 2018 13:44:29 +0200 Subject: Misc tweaks --- config.toml.example | 3 +++ src/Cargo.lock | 1 + src/bootstrap/bin/rustc.rs | 7 +++++++ src/bootstrap/builder.rs | 4 ++++ src/bootstrap/config.rs | 3 +++ src/bootstrap/job.rs | 10 ++++------ src/librustc/util/common.rs | 11 +++++++++++ src/librustc_plugin/lib.rs | 1 - src/librustc_plugin/registry.rs | 2 -- src/tools/compiletest/Cargo.toml | 1 + src/tools/compiletest/src/main.rs | 3 +++ src/tools/compiletest/src/runtest.rs | 36 ++++++++++++++++++++++++++++++++++-- src/tools/tidy/src/deps.rs | 1 + 13 files changed, 72 insertions(+), 11 deletions(-) (limited to 'src/tools') diff --git a/config.toml.example b/config.toml.example index effe0084381..34fcc755b3a 100644 --- a/config.toml.example +++ b/config.toml.example @@ -346,6 +346,9 @@ # Whether to deny warnings in crates #deny-warnings = true +# Print backtrace on internal compiler errors during bootstrap +#backtrace-on-ice = false + # ============================================================================= # Options for specific targets # diff --git a/src/Cargo.lock b/src/Cargo.lock index 0f08eaf596a..a2767bd290d 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -390,6 +390,7 @@ dependencies = [ "env_logger 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index b6ae824c376..3f97accaa4d 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -107,6 +107,13 @@ fn main() { env::join_paths(&dylib_path).unwrap()); let mut maybe_crate = None; + // Print backtrace in case of ICE + if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() { + cmd.env("RUST_BACKTRACE", "1"); + } + + cmd.env("RUSTC_BREAK_ON_ICE", "1"); + if let Some(target) = target { // The stage0 compiler has a special sysroot distinct from what we // actually downloaded, so we just always pass the `--sysroot` option. diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 08bb8ab4815..43387e28565 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -706,6 +706,10 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_PRINT_STEP_TIMINGS", "1"); } + if self.config.backtrace_on_ice { + cargo.env("RUSTC_BACKTRACE_ON_ICE", "1"); + } + cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity)); // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful. diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 7175f6a6764..6dd6291be23 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -72,6 +72,7 @@ pub struct Config { pub dry_run: bool, pub deny_warnings: bool, + pub backtrace_on_ice: bool, // llvm codegen options pub llvm_enabled: bool, @@ -306,6 +307,7 @@ struct Rust { wasm_syscall: Option, lld: Option, deny_warnings: Option, + backtrace_on_ice: Option, } /// TOML representation of how each build target is configured. @@ -531,6 +533,7 @@ impl Config { config.musl_root = rust.musl_root.clone().map(PathBuf::from); config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from); set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings)); + set(&mut config.backtrace_on_ice, rust.backtrace_on_ice); if let Some(ref backends) = rust.codegen_backends { config.rust_codegen_backends = backends.iter() diff --git a/src/bootstrap/job.rs b/src/bootstrap/job.rs index fa3ba02482f..6445ce8da33 100644 --- a/src/bootstrap/job.rs +++ b/src/bootstrap/job.rs @@ -122,12 +122,10 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION { } pub unsafe fn setup(build: &mut Build) { - // Tell Windows to not show any UI on errors (such as not finding a required dll - // during startup or terminating abnormally). This is important for running tests, - // since some of them use abnormal termination by design. - // This mode is inherited by all child processes. - let mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags - SetErrorMode(mode | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); + // Enable the Windows Error Reporting dialog which msys disables, + // so we can JIT debug rustc + let mode = SetErrorMode(0); + SetErrorMode(mode & !SEM_NOGPFAULTERRORBOX); // Create a new job object for us to use let job = CreateJobObjectW(0 as *mut _, 0 as *const _); diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index c74e42263ef..85533caffce 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -58,6 +58,17 @@ fn panic_hook(info: &panic::PanicInfo) { if backtrace { TyCtxt::try_print_query_stack(); } + + #[cfg(windows)] + unsafe { + if env::var("RUSTC_BREAK_ON_ICE").is_ok() { + extern "system" { + fn DebugBreak(); + } + // Trigger a debugger if we crashed during bootstrap + DebugBreak(); + } + } } } diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 622d8e51a6c..348aa6a7cef 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -65,7 +65,6 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(rustc_diagnostic_macros)] -#![feature(staged_api)] #[macro_use] extern crate syntax; diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs index ebfd8785a0a..7e3c411c1d2 100644 --- a/src/librustc_plugin/registry.rs +++ b/src/librustc_plugin/registry.rs @@ -128,8 +128,6 @@ impl<'a> Registry<'a> { /// This can be used in place of `register_syntax_extension` to register legacy custom derives /// (i.e. attribute syntax extensions whose name begins with `derive_`). Legacy custom /// derives defined by this function do not trigger deprecation warnings when used. - #[unstable(feature = "rustc_private", issue = "27812")] - #[rustc_deprecated(since = "1.15.0", reason = "replaced by macros 1.1 (RFC 1861)")] pub fn register_custom_derive(&mut self, name: ast::Name, extension: SyntaxExtension) { assert!(name.as_str().starts_with("derive_")); self.whitelisted_custom_derives.push(name); diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 77554f244c8..45cb147fbbc 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -19,5 +19,6 @@ rustfix = "0.2" libc = "0.2" [target.'cfg(windows)'.dependencies] +lazy_static = "1.0" miow = "0.3" winapi = { version = "0.3", features = ["winerror"] } diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index a7849d53c3d..e2b446c99dc 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -23,6 +23,9 @@ extern crate libc; extern crate log; extern crate regex; #[macro_use] +#[cfg(windows)] +extern crate lazy_static; +#[macro_use] extern crate serde_derive; extern crate serde_json; extern crate test; diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index fae75c352da..1bac9ef66bb 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -38,6 +38,39 @@ use std::str; use extract_gdb_version; +#[cfg(windows)] +fn disable_error_reporting R, R>(f: F) -> R { + use std::sync::Mutex; + const SEM_NOGPFAULTERRORBOX: u32 = 0x0002; + extern "system" { + fn SetErrorMode(mode: u32) -> u32; + } + + lazy_static! { + static ref LOCK: Mutex<()> = { + Mutex::new(()) + }; + } + // Error mode is a global variable, so lock it so only one thread will change it + let _lock = LOCK.lock().unwrap(); + + // Tell Windows to not show any UI on errors (such as terminating abnormally). + // This is important for running tests, since some of them use abnormal + // termination by design. This mode is inherited by all child processes. + unsafe { + let old_mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags + SetErrorMode(old_mode | SEM_NOGPFAULTERRORBOX); + let r = f(); + SetErrorMode(old_mode); + r + } +} + +#[cfg(not(windows))] +fn disable_error_reporting R, R>(f: F) -> R { + f() +} + /// The name of the environment variable that holds dynamic library locations. pub fn dylib_env_var() -> &'static str { if cfg!(windows) { @@ -1578,8 +1611,7 @@ impl<'test> TestCx<'test> { let newpath = env::join_paths(&path).unwrap(); command.env(dylib_env_var(), newpath); - let mut child = command - .spawn() + let mut child = disable_error_reporting(|| command.spawn()) .expect(&format!("failed to exec `{:?}`", &command)); if let Some(input) = input { child diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 8caf39fc27b..9a87fcb00d5 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -73,6 +73,7 @@ static WHITELIST: &'static [Crate] = &[ Crate("flate2"), Crate("fuchsia-zircon"), Crate("fuchsia-zircon-sys"), + Crate("getopts"), Crate("humantime"), Crate("jobserver"), Crate("kernel32-sys"), -- cgit 1.4.1-3-g733a5