From bcdb67bf43ba42bcb1fd03a4a151066cae1365ed Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Tue, 8 May 2018 20:55:43 +0200 Subject: [PATCH 01/19] Update derive-new This removes the last dependency on syn 0.12 --- src/Cargo.lock | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 21c35458398b7..098960fa36b5c 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -311,7 +311,7 @@ dependencies = [ "clippy-mini-macro-test 0.2.0", "clippy_lints 0.0.197", "compiletest_rs 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -551,12 +551,12 @@ version = "0.1.0" [[package]] name = "derive-new" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.12.15 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1429,14 +1429,6 @@ dependencies = [ "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "proc-macro2" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "proc-macro2" version = "0.3.6" @@ -1488,14 +1480,6 @@ name = "quote" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "quote" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "quote" version = "0.5.1" @@ -1660,7 +1644,7 @@ name = "rls-analysis" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "derive-new 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "radix_trie 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2254,7 +2238,7 @@ 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)", + "derive-new 0.5.4 (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)", @@ -2522,16 +2506,6 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syn" -version = "0.12.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syn" version = "0.13.1" @@ -3033,7 +3007,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum curl 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "aaf20bbe084f285f215eef2165feed70d6b75ba29cad24469badb853a4a287d0" "checksum curl-sys 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f3f7738d877ec81040305d5bb91976ac594f564f5e455dc02a29a23c1d00fe6f" "checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3" -"checksum derive-new 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fcb923bab47a948f1b01cec2f758fdebba95c9ebc255458654b2b88efe59d71" +"checksum derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ceed73957c449214f8440eec8ad7fa282b67dc9eacbb24a3085b15d60397a17a" "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" @@ -3126,13 +3100,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" -"checksum proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" "checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118" "checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408" "checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a" "checksum racer 2.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "40d44bc30fc8d403b665286b2c9a83466ddbf69297668fb02b785c3e58eb8e0d" "checksum radix_trie 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "03d0d770481e8af620ca61d3d304bf014f965d7f78e923dc58545e6a545070a9" @@ -3188,7 +3160,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum strum 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "099e21b5dd6dd07b5adcf8c4b723a7c0b7efd7a9359bf963d58c0caae8532545" "checksum strum_macros 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd9bd569e88028750e3ae5c25616b8278ac16a8e61aba4339195c72396d49e1" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.12.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c97c05b8ebc34ddd6b967994d5c6e9852fa92f8b82b3858c39451f97346dcce5" "checksum syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91b52877572087400e83d24b9178488541e3d535259e04ff17a63df1e5ceff59" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" From da02fad2d131fd8b9411b94b45aed619bdb675cf Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Tue, 8 May 2018 21:46:55 +0200 Subject: [PATCH 02/19] Update assert_cli This removes skeptic from the dependency tree which in turn removes quite a few other dependencies --- src/Cargo.lock | 86 ++++---------------------------------------------- 1 file changed, 7 insertions(+), 79 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 098960fa36b5c..40e19912371ca 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -79,15 +79,15 @@ dependencies = [ [[package]] name = "assert_cli" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "skeptic 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -183,11 +183,6 @@ dependencies = [ name = "build_helper" version = "0.1.0" -[[package]] -name = "bytecount" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "byteorder" version = "1.2.2" @@ -240,18 +235,6 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "cargo_metadata" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.8.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)", -] - [[package]] name = "cargo_metadata" version = "0.5.4" @@ -564,11 +547,6 @@ name = "diff" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "difference" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "difference" version = "2.0.0" @@ -1549,7 +1527,7 @@ dependencies = [ "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)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2236,7 +2214,7 @@ dependencies = [ name = "rustfmt-nightly" version = "0.6.1" dependencies = [ - "assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "assert_cli 0.5.6 (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.4 (registry+https://github.com/rust-lang/crates.io-index)", "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2259,15 +2237,6 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "same-file" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "same-file" version = "1.0.2" @@ -2295,15 +2264,6 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "semver" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "semver" version = "0.9.0" @@ -2381,21 +2341,6 @@ name = "siphasher" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "skeptic" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytecount 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo_metadata 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "smallvec" version = "0.6.0" @@ -2889,16 +2834,6 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "walkdir" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "walkdir" version = "2.1.4" @@ -2976,7 +2911,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35c7a5669cb64f085739387e1308b74e6d44022464b7f1b63bbd4ceb6379ec31" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72342c21057a3cb5f7c2d849bf7999a83795434dd36d74fa8c24680581bd1930" +"checksum assert_cli 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8ca6beaa44a3520407b28a4a779a19b1364fcadcb2f258c41a7baf3102ced0" "checksum atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4" "checksum backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe525f66f42d207968308ee86bc2dd60aa5fab535b22e616323a173d097d8e" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" @@ -2984,9 +2919,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" -"checksum bytecount 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af27422163679dea46a1a7239dffff64d3dcdc3ba5fe9c49c789fbfe0eb949de" "checksum byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87" -"checksum cargo_metadata 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f56ec3e469bca7c276f2eea015aa05c5e381356febdbb0683c2580189604537" "checksum cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebd6272a2ca4fd39dbabbd6611eb03df45c2259b3b80b39a9ff8fbdcf42a4b3" "checksum cc 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8b9d2900f78631a5876dc5d6c9033ede027253efcd33dd36b1309fc6cab97ee0" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" @@ -3009,7 +2942,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3" "checksum derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ceed73957c449214f8440eec8ad7fa282b67dc9eacbb24a3085b15d60397a17a" "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" -"checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" @@ -3133,12 +3065,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "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.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" "checksum scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8674d439c964889e2476f474a3bf198cc9e199e77499960893bac5de7e9218a4" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bee2bc909ab2d8d60dab26e8cad85b25d795b14603a0dcb627b78b9d30b6454b" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "29465552c9b767d0cb44be3ddf4c3214be15d34975a7750f6cf4f409835f0248" @@ -3149,7 +3079,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum shell-escape 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "170a13e64f2a51b77a45702ba77287f5c6829375b04a69cf2222acd17d0cfab9" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" -"checksum skeptic 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c8431f8fca168e2db4be547bd8329eac70d095dff1444fee4b0fa0fabc7df75a" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" "checksum socket2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ff606e0486e88f5fc6cfeb3966e434fb409abbc7a3ab495238f70a1ca97f789d" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" @@ -3198,7 +3127,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum vcpkg 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ed0f6789c8a85ca41bbc1c9d175422116a9869bd1cf31bb08e1493ecce60380" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" "checksum walkdir 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "63636bd0eb3d00ccb8b9036381b526efac53caf112b7783b730ab3f8e44da369" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" From e333725664c45874262ecb11e511c17cfd4672f0 Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Wed, 9 May 2018 01:41:44 +0200 Subject: [PATCH 03/19] use fmt::Result where applicable --- src/librustc/ich/fingerprint.rs | 2 +- .../control_flow_graph/dominators/mod.rs | 4 ++-- src/librustc_data_structures/owning_ref/mod.rs | 6 +++--- src/librustc_errors/lib.rs | 4 ++-- src/librustc_mir/borrow_check/nll/region_infer/mod.rs | 2 +- src/librustc_mir/transform/elaborate_drops.rs | 2 +- src/librustdoc/html/render.rs | 4 ++-- src/libstd/path.rs | 2 +- src/libstd/sys/redox/syscall/error.rs | 4 ++-- src/libstd/sys_common/wtf8.rs | 4 ++-- src/libsyntax_ext/format_foreign.rs | 2 +- src/test/run-pass/atomic-print.rs | 2 +- src/test/run-pass/union/union-trait-impl.rs | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/librustc/ich/fingerprint.rs b/src/librustc/ich/fingerprint.rs index a7adf28c481b9..f56f4e12e7a02 100644 --- a/src/librustc/ich/fingerprint.rs +++ b/src/librustc/ich/fingerprint.rs @@ -67,7 +67,7 @@ impl Fingerprint { } impl ::std::fmt::Display for Fingerprint { - fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(formatter, "{:x}-{:x}", self.0, self.1) } } diff --git a/src/librustc_data_structures/control_flow_graph/dominators/mod.rs b/src/librustc_data_structures/control_flow_graph/dominators/mod.rs index dc487f1162ca9..54407658e6ccc 100644 --- a/src/librustc_data_structures/control_flow_graph/dominators/mod.rs +++ b/src/librustc_data_structures/control_flow_graph/dominators/mod.rs @@ -175,7 +175,7 @@ impl DominatorTree { } impl fmt::Debug for DominatorTree { - fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&DominatorTreeNode { tree: self, node: self.root, @@ -190,7 +190,7 @@ struct DominatorTreeNode<'tree, Node: Idx> { } impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let subtrees: Vec<_> = self.tree .children(self.node) .iter() diff --git a/src/librustc_data_structures/owning_ref/mod.rs b/src/librustc_data_structures/owning_ref/mod.rs index c466b8f8ad1b5..aa113fac9fb7d 100644 --- a/src/librustc_data_structures/owning_ref/mod.rs +++ b/src/librustc_data_structures/owning_ref/mod.rs @@ -1002,7 +1002,7 @@ impl Debug for OwningRef where O: Debug, T: Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "OwningRef {{ owner: {:?}, reference: {:?} }}", self.owner(), @@ -1014,7 +1014,7 @@ impl Debug for OwningRefMut where O: Debug, T: Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "OwningRefMut {{ owner: {:?}, reference: {:?} }}", self.owner(), @@ -1047,7 +1047,7 @@ unsafe impl Sync for OwningRefMut where O: Sync, for<'a> (&'a mut T): Sync {} impl Debug for Erased { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "",) } } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index c2b442e949758..fd90e1cbe0866 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -232,7 +232,7 @@ impl FatalError { } impl fmt::Display for FatalError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "parser fatal error") } } @@ -249,7 +249,7 @@ impl error::Error for FatalError { pub struct ExplicitBug; impl fmt::Display for ExplicitBug { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "parser internal bug") } } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index 4d1f3e2b4300a..57b8824191f7b 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -1185,7 +1185,7 @@ impl<'tcx> RegionDefinition<'tcx> { } impl fmt::Debug for Constraint { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!( formatter, "({:?}: {:?} @ {:?}) due to {:?}", diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 5397d18cdd720..79252e7654bfa 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -174,7 +174,7 @@ struct Elaborator<'a, 'b: 'a, 'tcx: 'b> { } impl<'a, 'b, 'tcx> fmt::Debug for Elaborator<'a, 'b, 'tcx> { - fn fmt(&self, _f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { Ok(()) } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 21de2db1dfe74..fe9fc3ddd680e 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2579,7 +2579,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, } fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter, - implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> Result<(), fmt::Error> { + implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> fmt::Result { write!(w, "
  • ")?; // If there's already another implementor that has the same abbridged name, use the // full path, for example in `std::iter::ExactSizeIterator` @@ -2612,7 +2612,7 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter, fn render_impls(cx: &Context, w: &mut fmt::Formatter, traits: &[&&Impl], - containing_item: &clean::Item) -> Result<(), fmt::Error> { + containing_item: &clean::Item) -> fmt::Result { for i in traits { let did = i.trait_did().unwrap(); let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods); diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 696711a70d4f6..5d35a7861736a 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1460,7 +1460,7 @@ impl> iter::Extend

    for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for PathBuf { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, formatter) } } diff --git a/src/libstd/sys/redox/syscall/error.rs b/src/libstd/sys/redox/syscall/error.rs index d8d78d550162a..1ef79547431f8 100644 --- a/src/libstd/sys/redox/syscall/error.rs +++ b/src/libstd/sys/redox/syscall/error.rs @@ -48,13 +48,13 @@ impl Error { } impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.text()) } } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.text()) } } diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index fe7e058091ed5..14a2555adf9ba 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -56,7 +56,7 @@ pub struct CodePoint { /// Example: `U+1F4A9` impl fmt::Debug for CodePoint { #[inline] - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "U+{:04X}", self.value) } } @@ -144,7 +144,7 @@ impl ops::DerefMut for Wtf8Buf { /// Example: `"a\u{D800}"` for a string with code points [U+0061, U+D800] impl fmt::Debug for Wtf8Buf { #[inline] - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, formatter) } } diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index e95c6f2e1243f..2b8603c75a57b 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -989,7 +989,7 @@ mod strcursor { } impl<'a> std::fmt::Debug for StrCursor<'a> { - fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { write!(fmt, "StrCursor({:?} | {:?})", self.slice_before(), self.slice_after()) } } diff --git a/src/test/run-pass/atomic-print.rs b/src/test/run-pass/atomic-print.rs index 914b89dfb4dc0..2d478e954e7cb 100644 --- a/src/test/run-pass/atomic-print.rs +++ b/src/test/run-pass/atomic-print.rs @@ -15,7 +15,7 @@ use std::{env, fmt, process, sync, thread}; struct SlowFmt(u32); impl fmt::Debug for SlowFmt { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { thread::sleep_ms(3); self.0.fmt(f) } diff --git a/src/test/run-pass/union/union-trait-impl.rs b/src/test/run-pass/union/union-trait-impl.rs index 1cdaff2cab7c8..c1e408cc02ac6 100644 --- a/src/test/run-pass/union/union-trait-impl.rs +++ b/src/test/run-pass/union/union-trait-impl.rs @@ -15,7 +15,7 @@ union U { } impl fmt::Display for U { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unsafe { write!(f, "Oh hai {}", self.a) } } } From 9d7eda96ee57ed951bd93a420814c6f8c65c1cf2 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 10 May 2018 18:05:29 +1000 Subject: [PATCH 04/19] Mention that fs::canonicalize makes paths absolute. --- src/libstd/fs.rs | 4 ++-- src/libstd/path.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 7bd1adc411ae4..f877c77ad7ff0 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1699,8 +1699,8 @@ pub fn read_link>(path: P) -> io::Result { fs_imp::readlink(path.as_ref()) } -/// Returns the canonical form of a path with all intermediate components -/// normalized and symbolic links resolved. +/// Returns the canonical, absolute form of a path with all intermediate +/// components normalized and symbolic links resolved. /// /// # Platform-specific behavior /// diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 696711a70d4f6..b670ae597b280 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2284,8 +2284,8 @@ impl Path { fs::symlink_metadata(self) } - /// Returns the canonical form of the path with all intermediate components - /// normalized and symbolic links resolved. + /// Returns the canonical, absolute form of the path with all intermediate + /// components normalized and symbolic links resolved. /// /// This is an alias to [`fs::canonicalize`]. /// From 8720314c025cd222fd04d07119e2cf180f53770a Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 10 May 2018 18:06:47 +1000 Subject: [PATCH 05/19] fs::canonicalize has some important portability concerns. --- src/libstd/fs.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index f877c77ad7ff0..732da79a4d4da 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1708,7 +1708,14 @@ pub fn read_link>(path: P) -> io::Result { /// and the `CreateFile` and `GetFinalPathNameByHandle` functions on Windows. /// Note that, this [may change in the future][changes]. /// +/// On Windows, this converts the path to use [extended length path][path] +/// syntax, which allows your program to use longer path names, but means you +/// can only join backslash-delimited paths to it, and it may be incompatible +/// with other applications (if passed to the application on the command-line, +/// or written to a file another application may read). +/// /// [changes]: ../io/index.html#platform-specific-behavior +/// [path]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath /// /// # Errors /// From ca3234036708599aa3dca645a58b819e0f6116e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 10 May 2018 16:27:46 +0200 Subject: [PATCH 06/19] Allocate Symbol strings from an arena --- src/Cargo.lock | 1 + src/libsyntax_pos/Cargo.toml | 1 + src/libsyntax_pos/lib.rs | 1 + src/libsyntax_pos/symbol.rs | 40 ++++++++++++++++++++++++++++-------- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index e2a9a6efbdad4..9f4159444208a 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -2590,6 +2590,7 @@ dependencies = [ name = "syntax_pos" version = "0.0.0" dependencies = [ + "arena 0.0.0", "rustc_data_structures 0.0.0", "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", diff --git a/src/libsyntax_pos/Cargo.toml b/src/libsyntax_pos/Cargo.toml index b9637b1855ef0..a9147b394f7a4 100644 --- a/src/libsyntax_pos/Cargo.toml +++ b/src/libsyntax_pos/Cargo.toml @@ -11,5 +11,6 @@ crate-type = ["dylib"] [dependencies] serialize = { path = "../libserialize" } rustc_data_structures = { path = "../librustc_data_structures" } +arena = { path = "../libarena" } scoped-tls = { version = "0.1.1", features = ["nightly"] } unicode-width = "0.1.4" diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 8b4a3ea26a1ef..d30d3d78ca540 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -35,6 +35,7 @@ use std::path::PathBuf; use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::sync::{Lrc, Lock}; +extern crate arena; extern crate rustc_data_structures; #[macro_use] diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 4a8b1e8b1c1e4..b84ff5697a4c8 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -16,8 +16,10 @@ use hygiene::SyntaxContext; use {Span, DUMMY_SP, GLOBALS}; use rustc_data_structures::fx::FxHashMap; +use arena::DroplessArena; use serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; +use std::str; use std::cmp::{PartialEq, Ordering, PartialOrd, Ord}; use std::hash::{Hash, Hasher}; @@ -198,22 +200,35 @@ impl> PartialEq for Symbol { } } -#[derive(Default)] +// The &'static strs in this type actually point into the arena pub struct Interner { - names: FxHashMap, Symbol>, - strings: Vec>, + arena: DroplessArena, + names: FxHashMap<&'static str, Symbol>, + strings: Vec<&'static str>, gensyms: Vec, } impl Interner { pub fn new() -> Self { - Interner::default() + Interner { + arena: DroplessArena::new(), + names: Default::default(), + strings: Default::default(), + gensyms: Default::default(), + } } fn prefill(init: &[&str]) -> Self { let mut this = Interner::new(); for &string in init { - this.intern(string); + if string == "" { + // We can't allocate empty strings in the arena, so handle this here + let name = Symbol(this.strings.len() as u32); + this.names.insert("", name); + this.strings.push(""); + } else { + this.intern(string); + } } this } @@ -224,8 +239,17 @@ impl Interner { } let name = Symbol(self.strings.len() as u32); - let string = string.to_string().into_boxed_str(); - self.strings.push(string.clone()); + + // from_utf8_unchecked is safe since we just allocated a &str which is known to be utf8 + let string: &str = unsafe { + str::from_utf8_unchecked(self.arena.alloc_slice(string.as_bytes())) + }; + // It is safe to extend the arena allocation to 'static because we only access + // these while the arena is still alive + let string: &'static str = unsafe { + &*(string as *const str) + }; + self.strings.push(string); self.names.insert(string, name); name } @@ -254,7 +278,7 @@ impl Interner { pub fn get(&self, symbol: Symbol) -> &str { match self.strings.get(symbol.0 as usize) { - Some(ref string) => string, + Some(string) => string, None => self.get(self.gensyms[(!0 - symbol.0) as usize]), } } From 4d8d0a6f85ee66c7b65c53de3039aa38d99f05af Mon Sep 17 00:00:00 2001 From: Roman Stoliar Date: Tue, 8 May 2018 23:47:50 +0300 Subject: [PATCH 07/19] const time added rustc_const_unstable attribute extended tests added conversion test fixed tidy test added feature attribute --- src/libcore/tests/time.rs | 42 ++++++++++++++++++- src/libcore/time.rs | 12 ++++-- src/test/ui/const-eval/duration_conversion.rs | 28 +++++++++++++ 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/const-eval/duration_conversion.rs diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs index 042c523f25f25..0f3b95236f069 100644 --- a/src/libcore/tests/time.rs +++ b/src/libcore/tests/time.rs @@ -23,9 +23,43 @@ fn creation() { #[test] fn secs() { assert_eq!(Duration::new(0, 0).as_secs(), 0); + assert_eq!(Duration::new(0, 500_000_005).as_secs(), 0); + assert_eq!(Duration::new(0, 1_050_000_001).as_secs(), 1); assert_eq!(Duration::from_secs(1).as_secs(), 1); assert_eq!(Duration::from_millis(999).as_secs(), 0); assert_eq!(Duration::from_millis(1001).as_secs(), 1); + assert_eq!(Duration::from_micros(999_999).as_secs(), 0); + assert_eq!(Duration::from_micros(1_000_001).as_secs(), 1); + assert_eq!(Duration::from_nanos(999_999_999).as_secs(), 0); + assert_eq!(Duration::from_nanos(1_000_000_001).as_secs(), 1); +} + +#[test] +fn millis() { + assert_eq!(Duration::new(0, 0).subsec_millis(), 0); + assert_eq!(Duration::new(0, 500_000_005).subsec_millis(), 500); + assert_eq!(Duration::new(0, 1_050_000_001).subsec_millis(), 50); + assert_eq!(Duration::from_secs(1).subsec_millis(), 0); + assert_eq!(Duration::from_millis(999).subsec_millis(), 999); + assert_eq!(Duration::from_millis(1001).subsec_millis(), 1); + assert_eq!(Duration::from_micros(999_999).subsec_millis(), 999); + assert_eq!(Duration::from_micros(1_001_000).subsec_millis(), 1); + assert_eq!(Duration::from_nanos(999_999_999).subsec_millis(), 999); + assert_eq!(Duration::from_nanos(1_001_000_000).subsec_millis(), 1); +} + +#[test] +fn micros() { + assert_eq!(Duration::new(0, 0).subsec_micros(), 0); + assert_eq!(Duration::new(0, 500_000_005).subsec_micros(), 500_000); + assert_eq!(Duration::new(0, 1_050_000_001).subsec_micros(), 50_000); + assert_eq!(Duration::from_secs(1).subsec_micros(), 0); + assert_eq!(Duration::from_millis(999).subsec_micros(), 999_000); + assert_eq!(Duration::from_millis(1001).subsec_micros(), 1_000); + assert_eq!(Duration::from_micros(999_999).subsec_micros(), 999_999); + assert_eq!(Duration::from_micros(1_000_001).subsec_micros(), 1); + assert_eq!(Duration::from_nanos(999_999_999).subsec_micros(), 999_999); + assert_eq!(Duration::from_nanos(1_000_001_000).subsec_micros(), 1); } #[test] @@ -34,8 +68,12 @@ fn nanos() { assert_eq!(Duration::new(0, 5).subsec_nanos(), 5); assert_eq!(Duration::new(0, 1_000_000_001).subsec_nanos(), 1); assert_eq!(Duration::from_secs(1).subsec_nanos(), 0); - assert_eq!(Duration::from_millis(999).subsec_nanos(), 999 * 1_000_000); - assert_eq!(Duration::from_millis(1001).subsec_nanos(), 1 * 1_000_000); + assert_eq!(Duration::from_millis(999).subsec_nanos(), 999_000_000); + assert_eq!(Duration::from_millis(1001).subsec_nanos(), 1_000_000); + assert_eq!(Duration::from_micros(999_999).subsec_nanos(), 999_999_000); + assert_eq!(Duration::from_micros(1_000_001).subsec_nanos(), 1000); + assert_eq!(Duration::from_nanos(999_999_999).subsec_nanos(), 999_999_999); + assert_eq!(Duration::from_nanos(1_000_000_001).subsec_nanos(), 1); } #[test] diff --git a/src/libcore/time.rs b/src/libcore/time.rs index 8e8b1691c657a..c0b2b2a0bc682 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -203,8 +203,9 @@ impl Duration { /// /// [`subsec_nanos`]: #method.subsec_nanos #[stable(feature = "duration", since = "1.3.0")] + #[rustc_const_unstable(feature="duration_getters")] #[inline] - pub fn as_secs(&self) -> u64 { self.secs } + pub const fn as_secs(&self) -> u64 { self.secs } /// Returns the fractional part of this `Duration`, in milliseconds. /// @@ -222,8 +223,9 @@ impl Duration { /// assert_eq!(duration.subsec_millis(), 432); /// ``` #[stable(feature = "duration_extras", since = "1.27.0")] + #[rustc_const_unstable(feature="duration_getters")] #[inline] - pub fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI } + pub const fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI } /// Returns the fractional part of this `Duration`, in microseconds. /// @@ -241,8 +243,9 @@ impl Duration { /// assert_eq!(duration.subsec_micros(), 234_567); /// ``` #[stable(feature = "duration_extras", since = "1.27.0")] + #[rustc_const_unstable(feature="duration_getters")] #[inline] - pub fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO } + pub const fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO } /// Returns the fractional part of this `Duration`, in nanoseconds. /// @@ -260,8 +263,9 @@ impl Duration { /// assert_eq!(duration.subsec_nanos(), 10_000_000); /// ``` #[stable(feature = "duration", since = "1.3.0")] + #[rustc_const_unstable(feature="duration_getters")] #[inline] - pub fn subsec_nanos(&self) -> u32 { self.nanos } + pub const fn subsec_nanos(&self) -> u32 { self.nanos } /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. diff --git a/src/test/ui/const-eval/duration_conversion.rs b/src/test/ui/const-eval/duration_conversion.rs new file mode 100644 index 0000000000000..4481b75840487 --- /dev/null +++ b/src/test/ui/const-eval/duration_conversion.rs @@ -0,0 +1,28 @@ +// 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-pass + +#![feature(duration_getters)] + +use std::time::Duration; + +fn main() { + const _ONE_SECOND: Duration = Duration::from_nanos(1_000_000_000); + const _ONE_MILLISECOND: Duration = Duration::from_nanos(1_000_000); + const _ONE_MICROSECOND: Duration = Duration::from_nanos(1_000); + const _ONE_NANOSECOND: Duration = Duration::from_nanos(1); + const _ONE: usize = _ONE_SECOND.as_secs() as usize; + const _TWO: usize = _ONE_MILLISECOND.subsec_millis() as usize; + const _THREE: usize = _ONE_MICROSECOND.subsec_micros() as usize; + const _FOUR: usize = _ONE_NANOSECOND.subsec_nanos() as usize; + const _0: [[u8; _ONE]; _TWO] = [[1; _ONE]; _TWO]; + const _1: [[u8; _THREE]; _FOUR] = [[3; _THREE]; _FOUR]; +} From 89a8f2c10332b059e14999dc19fde4cc03ef7167 Mon Sep 17 00:00:00 2001 From: Isaac Whitfield Date: Tue, 8 May 2018 22:20:09 -0700 Subject: [PATCH 08/19] Remove shared access to DepGraph::work_products --- src/librustc/dep_graph/graph.rs | 25 +--------------- src/librustc_incremental/persist/mod.rs | 2 +- src/librustc_incremental/persist/save.rs | 17 +++++------ .../persist/work_product.rs | 18 ++++++------ src/librustc_trans/back/write.rs | 29 +++++++++++-------- src/librustc_trans/lib.rs | 6 ++-- 6 files changed, 39 insertions(+), 58 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 03aff64100558..797332e699d4b 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -13,7 +13,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::small_vec::SmallVec; -use rustc_data_structures::sync::{Lrc, RwLock, ReadGuard, Lock}; +use rustc_data_structures::sync::{Lrc, Lock}; use std::env; use std::hash::Hash; use ty::{self, TyCtxt}; @@ -80,9 +80,6 @@ struct DepGraphData { /// this map. We can later look for and extract that data. previous_work_products: FxHashMap, - /// Work-products that we generate in this run. - work_products: RwLock>, - dep_node_debug: Lock>, // Used for testing, only populated when -Zquery-dep-graph is specified. @@ -103,7 +100,6 @@ impl DepGraph { DepGraph { data: Some(Lrc::new(DepGraphData { previous_work_products: prev_work_products, - work_products: RwLock::new(FxHashMap()), dep_node_debug: Lock::new(FxHashMap()), current: Lock::new(CurrentDepGraph::new()), previous: prev_graph, @@ -462,19 +458,6 @@ impl DepGraph { self.data.as_ref().unwrap().previous.node_to_index(dep_node) } - /// Indicates that we created the given work-product in this run - /// for `v`. This record will be preserved and loaded in the next - /// run. - pub fn insert_work_product(&self, v: &WorkProductId, data: WorkProduct) { - debug!("insert_work_product({:?}, {:?})", v, data); - self.data - .as_ref() - .unwrap() - .work_products - .borrow_mut() - .insert(v.clone(), data); - } - /// Check whether a previous work product exists for `v` and, if /// so, return the path that leads to it. Used to skip doing work. pub fn previous_work_product(&self, v: &WorkProductId) -> Option { @@ -485,12 +468,6 @@ impl DepGraph { }) } - /// Access the map of work-products created during this run. Only - /// used during saving of the dep-graph. - pub fn work_products(&self) -> ReadGuard> { - self.data.as_ref().unwrap().work_products.borrow() - } - /// Access the map of work-products created during the cached run. Only /// used during saving of the dep-graph. pub fn previous_work_products(&self) -> &FxHashMap { diff --git a/src/librustc_incremental/persist/mod.rs b/src/librustc_incremental/persist/mod.rs index 755a550b5bca3..3c23b7c6417bc 100644 --- a/src/librustc_incremental/persist/mod.rs +++ b/src/librustc_incremental/persist/mod.rs @@ -30,5 +30,5 @@ pub use self::load::load_query_result_cache; pub use self::load::LoadResult; pub use self::save::save_dep_graph; pub use self::save::save_work_products; -pub use self::work_product::save_trans_partition; +pub use self::work_product::create_trans_partition; pub use self::work_product::delete_workproduct_files; diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index e524fcecf9094..497d24fae5bfe 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::dep_graph::{DepGraph, DepKind}; +use rustc::dep_graph::{DepGraph, DepKind, WorkProduct, WorkProductId}; use rustc::session::Session; use rustc::ty::TyCtxt; use rustc::util::common::time; @@ -55,7 +55,9 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { }) } -pub fn save_work_products(sess: &Session, dep_graph: &DepGraph) { +pub fn save_work_products(sess: &Session, + dep_graph: &DepGraph, + new_work_products: FxHashMap) { if sess.opts.incremental.is_none() { return; } @@ -63,14 +65,12 @@ pub fn save_work_products(sess: &Session, dep_graph: &DepGraph) { debug!("save_work_products()"); dep_graph.assert_ignored(); let path = work_products_path(sess); - save_in(sess, path, |e| encode_work_products(dep_graph, e)); + save_in(sess, path, |e| encode_work_products(&new_work_products, e)); // We also need to clean out old work-products, as not all of them are // deleted during invalidation. Some object files don't change their // content, they are just not needed anymore. - let new_work_products = dep_graph.work_products(); let previous_work_products = dep_graph.previous_work_products(); - for (id, wp) in previous_work_products.iter() { if !new_work_products.contains_key(id) { work_product::delete_workproduct_files(sess, wp); @@ -234,10 +234,9 @@ fn encode_dep_graph(tcx: TyCtxt, Ok(()) } -fn encode_work_products(dep_graph: &DepGraph, +fn encode_work_products(work_products: &FxHashMap, encoder: &mut Encoder) -> io::Result<()> { - let work_products: Vec<_> = dep_graph - .work_products() + let serialized_products: Vec<_> = work_products .iter() .map(|(id, work_product)| { SerializedWorkProduct { @@ -247,7 +246,7 @@ fn encode_work_products(dep_graph: &DepGraph, }) .collect(); - work_products.encode(encoder) + serialized_products.encode(encoder) } fn encode_query_cache(tcx: TyCtxt, diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs index 879132bcacfcf..23e3664cdba13 100644 --- a/src/librustc_incremental/persist/work_product.rs +++ b/src/librustc_incremental/persist/work_product.rs @@ -11,21 +11,21 @@ //! This module contains files for saving intermediate work-products. use persist::fs::*; -use rustc::dep_graph::{WorkProduct, WorkProductId, DepGraph, WorkProductFileKind}; +use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind}; use rustc::session::Session; use rustc::util::fs::link_or_copy; use std::path::PathBuf; use std::fs as std_fs; -pub fn save_trans_partition(sess: &Session, - dep_graph: &DepGraph, - cgu_name: &str, - files: &[(WorkProductFileKind, PathBuf)]) { - debug!("save_trans_partition({:?},{:?})", +pub fn create_trans_partition(sess: &Session, + cgu_name: &str, + files: &[(WorkProductFileKind, PathBuf)]) + -> Option<(WorkProductId, WorkProduct)> { + debug!("create_trans_partition({:?},{:?})", cgu_name, files); if sess.opts.incremental.is_none() { - return + return None } let work_product_id = WorkProductId::from_cgu_name(cgu_name); @@ -53,8 +53,8 @@ pub fn save_trans_partition(sess: &Session, }) .collect(); let saved_files = match saved_files { + None => return None, Some(v) => v, - None => return, }; let work_product = WorkProduct { @@ -62,7 +62,7 @@ pub fn save_trans_partition(sess: &Session, saved_files, }; - dep_graph.insert_work_product(&work_product_id, work_product); + Some((work_product_id, work_product)) } pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) { diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 64876e82309f0..70b2796b7755d 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -17,8 +17,8 @@ use back::linker::LinkerInfo; use back::symbol_export::ExportedSymbols; use base; use consts; -use rustc_incremental::{save_trans_partition, in_incr_comp_dir}; -use rustc::dep_graph::{DepGraph, WorkProductFileKind}; +use rustc_incremental::{create_trans_partition, in_incr_comp_dir}; +use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind}; use rustc::middle::cstore::{LinkMeta, EncodedMetadata}; use rustc::session::config::{self, OutputFilenames, OutputType, Passes, SomePasses, AllPasses, Sanitizer, Lto}; @@ -1021,11 +1021,13 @@ pub fn start_async_translation(tcx: TyCtxt, } } -fn copy_module_artifacts_into_incr_comp_cache(sess: &Session, - dep_graph: &DepGraph, - compiled_modules: &CompiledModules) { +fn generate_module_artifacts(sess: &Session, + compiled_modules: &CompiledModules) + -> FxHashMap { + let mut work_products = FxHashMap::default(); + if sess.opts.incremental.is_none() { - return; + return work_products; } for module in compiled_modules.modules.iter() { @@ -1041,8 +1043,12 @@ fn copy_module_artifacts_into_incr_comp_cache(sess: &Session, files.push((WorkProductFileKind::BytecodeCompressed, path.clone())); } - save_trans_partition(sess, dep_graph, &module.name, &files); + if let Some((id, product)) = create_trans_partition(sess, &module.name, &files) { + work_products.insert(id, product); + } } + + work_products } fn produce_final_output_artifacts(sess: &Session, @@ -2236,7 +2242,7 @@ pub struct OngoingCrateTranslation { } impl OngoingCrateTranslation { - pub(crate) fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation { + pub(crate) fn join(self, sess: &Session) -> (CrateTranslation, FxHashMap) { self.shared_emitter_main.check(sess, true); let compiled_modules = match self.future.join() { Ok(Ok(compiled_modules)) => compiled_modules, @@ -2255,9 +2261,8 @@ impl OngoingCrateTranslation { time_graph.dump(&format!("{}-timings", self.crate_name)); } - copy_module_artifacts_into_incr_comp_cache(sess, - dep_graph, - &compiled_modules); + let work_products = generate_module_artifacts(sess, &compiled_modules); + produce_final_output_artifacts(sess, &compiled_modules, &self.output_filenames); @@ -2281,7 +2286,7 @@ impl OngoingCrateTranslation { metadata_module: compiled_modules.metadata_module, }; - trans + (trans, work_products) } pub(crate) fn submit_pre_translated_module_to_llvm(&self, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 7a152d6ded4c5..bc8747ca4f5c7 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -212,16 +212,16 @@ impl TransCrate for LlvmTransCrate { outputs: &OutputFilenames, ) -> Result<(), CompileIncomplete>{ use rustc::util::common::time; - let trans = trans.downcast::<::back::write::OngoingCrateTranslation>() + let (trans, work_products) = trans.downcast::<::back::write::OngoingCrateTranslation>() .expect("Expected LlvmTransCrate's OngoingCrateTranslation, found Box") - .join(sess, dep_graph); + .join(sess); if sess.opts.debugging_opts.incremental_info { back::write::dump_incremental_data(&trans); } time(sess, "serialize work products", - move || rustc_incremental::save_work_products(sess, &dep_graph)); + move || rustc_incremental::save_work_products(sess, &dep_graph, work_products)); sess.compile_status()?; From d23cbc3fbec44fe1ffbc468a396cf65755b56fc8 Mon Sep 17 00:00:00 2001 From: Isaac Whitfield Date: Tue, 8 May 2018 22:26:50 -0700 Subject: [PATCH 09/19] Catch a bad reference in use clauses --- src/librustc_incremental/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index a5e07bcec24bb..af33e87803264 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -36,8 +36,8 @@ pub use persist::dep_graph_tcx_init; pub use persist::load_dep_graph; pub use persist::load_query_result_cache; pub use persist::LoadResult; +pub use persist::create_trans_partition; pub use persist::save_dep_graph; -pub use persist::save_trans_partition; pub use persist::save_work_products; pub use persist::in_incr_comp_dir; pub use persist::prepare_session_directory; From 5c83422a5bdf8eacd4bbc727fb880b99ed66b04f Mon Sep 17 00:00:00 2001 From: Isaac Whitfield Date: Tue, 8 May 2018 23:10:03 -0700 Subject: [PATCH 10/19] Neaten a couple of long signatures --- src/librustc_trans/back/write.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 70b2796b7755d..afa9bca2ba98c 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -1021,9 +1021,10 @@ pub fn start_async_translation(tcx: TyCtxt, } } -fn generate_module_artifacts(sess: &Session, - compiled_modules: &CompiledModules) - -> FxHashMap { +fn generate_module_artifacts( + sess: &Session, + compiled_modules: &CompiledModules +) -> FxHashMap { let mut work_products = FxHashMap::default(); if sess.opts.incremental.is_none() { @@ -2242,7 +2243,10 @@ pub struct OngoingCrateTranslation { } impl OngoingCrateTranslation { - pub(crate) fn join(self, sess: &Session) -> (CrateTranslation, FxHashMap) { + pub(crate) fn join( + self, + sess: &Session + ) -> (CrateTranslation, FxHashMap) { self.shared_emitter_main.check(sess, true); let compiled_modules = match self.future.join() { Ok(Ok(compiled_modules)) => compiled_modules, From 0a4fbe326a4a05ff01d07d362cc554bd8414ce89 Mon Sep 17 00:00:00 2001 From: Isaac Whitfield Date: Wed, 9 May 2018 08:16:08 -0700 Subject: [PATCH 11/19] Update naming in line with PR comments --- src/librustc_incremental/lib.rs | 4 ++-- src/librustc_incremental/persist/mod.rs | 4 ++-- src/librustc_incremental/persist/save.rs | 14 +++++++------- src/librustc_incremental/persist/work_product.rs | 9 +++++---- src/librustc_trans/back/write.rs | 10 ++++++---- src/librustc_trans/lib.rs | 2 +- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index af33e87803264..ababce69e3170 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -36,9 +36,9 @@ pub use persist::dep_graph_tcx_init; pub use persist::load_dep_graph; pub use persist::load_query_result_cache; pub use persist::LoadResult; -pub use persist::create_trans_partition; +pub use persist::copy_cgu_workproducts_to_incr_comp_cache_dir; pub use persist::save_dep_graph; -pub use persist::save_work_products; +pub use persist::save_work_product_index; pub use persist::in_incr_comp_dir; pub use persist::prepare_session_directory; pub use persist::finalize_session_directory; diff --git a/src/librustc_incremental/persist/mod.rs b/src/librustc_incremental/persist/mod.rs index 3c23b7c6417bc..e1f00db56d5cb 100644 --- a/src/librustc_incremental/persist/mod.rs +++ b/src/librustc_incremental/persist/mod.rs @@ -29,6 +29,6 @@ pub use self::load::load_dep_graph; pub use self::load::load_query_result_cache; pub use self::load::LoadResult; pub use self::save::save_dep_graph; -pub use self::save::save_work_products; -pub use self::work_product::create_trans_partition; +pub use self::save::save_work_product_index; +pub use self::work_product::copy_cgu_workproducts_to_incr_comp_cache_dir; pub use self::work_product::delete_workproduct_files; diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 497d24fae5bfe..be725b1793321 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -55,17 +55,17 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { }) } -pub fn save_work_products(sess: &Session, - dep_graph: &DepGraph, - new_work_products: FxHashMap) { +pub fn save_work_product_index(sess: &Session, + dep_graph: &DepGraph, + new_work_products: FxHashMap) { if sess.opts.incremental.is_none() { return; } - debug!("save_work_products()"); + debug!("save_work_product_index()"); dep_graph.assert_ignored(); let path = work_products_path(sess); - save_in(sess, path, |e| encode_work_products(&new_work_products, e)); + save_in(sess, path, |e| encode_work_product_index(&new_work_products, e)); // We also need to clean out old work-products, as not all of them are // deleted during invalidation. Some object files don't change their @@ -234,8 +234,8 @@ fn encode_dep_graph(tcx: TyCtxt, Ok(()) } -fn encode_work_products(work_products: &FxHashMap, - encoder: &mut Encoder) -> io::Result<()> { +fn encode_work_product_index(work_products: &FxHashMap, + encoder: &mut Encoder) -> io::Result<()> { let serialized_products: Vec<_> = work_products .iter() .map(|(id, work_product)| { diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs index 23e3664cdba13..d163ad1f3f322 100644 --- a/src/librustc_incremental/persist/work_product.rs +++ b/src/librustc_incremental/persist/work_product.rs @@ -17,10 +17,11 @@ use rustc::util::fs::link_or_copy; use std::path::PathBuf; use std::fs as std_fs; -pub fn create_trans_partition(sess: &Session, - cgu_name: &str, - files: &[(WorkProductFileKind, PathBuf)]) - -> Option<(WorkProductId, WorkProduct)> { +pub fn copy_cgu_workproducts_to_incr_comp_cache_dir( + sess: &Session, + cgu_name: &str, + files: &[(WorkProductFileKind, PathBuf)] +) -> Option<(WorkProductId, WorkProduct)> { debug!("create_trans_partition({:?},{:?})", cgu_name, files); diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index afa9bca2ba98c..888173d4fc515 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -17,7 +17,7 @@ use back::linker::LinkerInfo; use back::symbol_export::ExportedSymbols; use base; use consts; -use rustc_incremental::{create_trans_partition, in_incr_comp_dir}; +use rustc_incremental::{copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir}; use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind}; use rustc::middle::cstore::{LinkMeta, EncodedMetadata}; use rustc::session::config::{self, OutputFilenames, OutputType, Passes, SomePasses, @@ -1021,7 +1021,7 @@ pub fn start_async_translation(tcx: TyCtxt, } } -fn generate_module_artifacts( +fn copy_all_cgu_workproducts_to_incr_comp_cache_dir( sess: &Session, compiled_modules: &CompiledModules ) -> FxHashMap { @@ -1044,7 +1044,8 @@ fn generate_module_artifacts( files.push((WorkProductFileKind::BytecodeCompressed, path.clone())); } - if let Some((id, product)) = create_trans_partition(sess, &module.name, &files) { + if let Some((id, product)) = + copy_cgu_workproducts_to_incr_comp_cache_dir(sess, &module.name, &files) { work_products.insert(id, product); } } @@ -2265,7 +2266,8 @@ impl OngoingCrateTranslation { time_graph.dump(&format!("{}-timings", self.crate_name)); } - let work_products = generate_module_artifacts(sess, &compiled_modules); + let work_products = copy_all_cgu_workproducts_to_incr_comp_cache_dir(sess, + &compiled_modules); produce_final_output_artifacts(sess, &compiled_modules, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index bc8747ca4f5c7..30780b8c96563 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -221,7 +221,7 @@ impl TransCrate for LlvmTransCrate { time(sess, "serialize work products", - move || rustc_incremental::save_work_products(sess, &dep_graph, work_products)); + move || rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)); sess.compile_status()?; From 8402a58528dc9f3c47208f3ed152132b67f7f217 Mon Sep 17 00:00:00 2001 From: Isaac Whitfield Date: Wed, 9 May 2018 08:32:04 -0700 Subject: [PATCH 12/19] Update an old method name in debug logging --- src/librustc_incremental/persist/work_product.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs index d163ad1f3f322..d0c7766cbae08 100644 --- a/src/librustc_incremental/persist/work_product.rs +++ b/src/librustc_incremental/persist/work_product.rs @@ -22,7 +22,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir( cgu_name: &str, files: &[(WorkProductFileKind, PathBuf)] ) -> Option<(WorkProductId, WorkProduct)> { - debug!("create_trans_partition({:?},{:?})", + debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files); if sess.opts.incremental.is_none() { From bf6804b79c9ecc30009a464b3342df04747381c8 Mon Sep 17 00:00:00 2001 From: Aaron DeVore Date: Thu, 10 May 2018 11:47:31 -0700 Subject: [PATCH 13/19] fs::write: Add example writing a &str --- src/libstd/fs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 732da79a4d4da..442a0873ae075 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -331,6 +331,7 @@ pub fn read_to_string>(path: P) -> io::Result { /// /// fn main() -> std::io::Result<()> { /// fs::write("foo.txt", b"Lorem ipsum")?; +/// fs::write("bar.txt", "dolor sit")?; /// Ok(()) /// } /// ``` From 5d015e1366d4c54f86d02638e2de3c89c43af481 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Sat, 12 May 2018 02:31:38 +0200 Subject: [PATCH 14/19] Do not silently truncate offsets for `read_at`/`write_at` on emscripten Generate an IO error if the offset is out of bounds for the system call. --- src/libstd/sys/unix/fd.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index 5dafc3251e755..67546d06b4e55 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -75,8 +75,15 @@ impl FileDesc { unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: usize, offset: i64) -> io::Result { + use convert::TryInto; use libc::pread64; - cvt(pread64(fd, buf, count, offset as i32)) + // pread64 on emscripten actually takes a 32 bit offset + if let Ok(o) = offset.try_into() { + cvt(pread64(fd, buf, count, o)) + } else { + Err(io::Error::new(io::ErrorKind::InvalidInput, + "cannot pread >2GB")) + } } #[cfg(not(any(target_os = "android", target_os = "emscripten")))] @@ -116,8 +123,15 @@ impl FileDesc { unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: usize, offset: i64) -> io::Result { + use convert::TryInto; use libc::pwrite64; - cvt(pwrite64(fd, buf, count, offset as i32)) + // pwrite64 on emscripten actually takes a 32 bit offset + if let Ok(o) = offset.try_into() { + cvt(pwrite64(fd, buf, count, o)) + } else { + Err(io::Error::new(io::ErrorKind::InvalidInput, + "cannot pwrite >2GB")) + } } #[cfg(not(any(target_os = "android", target_os = "emscripten")))] From 9d690d40d08026065feb52bee8c88b411381bcaa Mon Sep 17 00:00:00 2001 From: kennytm Date: Fri, 11 May 2018 12:30:50 +0800 Subject: [PATCH 15/19] AppVeyor: Dump crash log on failure. --- appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index a92f4a1781181..60f5b4be8def8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -211,6 +211,11 @@ test_script: - set NO_CCACHE=1 - sh src/ci/run.sh +on_failure: + # Dump crash log + - set PATH=%PATH%;"C:\Program Files (x86)\Windows Kits\10\Debuggers\X64" + - if exist %LOCALAPPDATA%\CrashDumps for %%f in (%LOCALAPPDATA%\CrashDumps\*) do cdb -c "k;q" -G -z "%%f" + branches: only: - auto From ae41d6c32fb5177a4ef4974cbad0ed16a9b0ec67 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 11 May 2018 17:04:50 +0100 Subject: [PATCH 16/19] Ignore non .rs files for tidy libcoretest Previously, any file would be read, which is both unnecessary, and causes issues if irrelevant non-Unicode files were read (e.g. `.DS_STORE`). --- src/tools/tidy/src/libcoretest.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/tools/tidy/src/libcoretest.rs b/src/tools/tidy/src/libcoretest.rs index ef8b55186b104..f6864c7f84e5a 100644 --- a/src/tools/tidy/src/libcoretest.rs +++ b/src/tools/tidy/src/libcoretest.rs @@ -22,12 +22,15 @@ pub fn check(path: &Path, bad: &mut bool) { &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() - ); + if subpath.ends_with(".rs") { + if t!(read_to_string(subpath)).contains("#[test]") { + tidy_error!( + bad, + "{} contains #[test]; libcore tests must be placed inside \ + `src/libcore/tests/`", + subpath.display() + ); + } } }, ); From bd441779ff60668d29b857e3b85e77aac773ebd3 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 11 May 2018 21:36:24 +0100 Subject: [PATCH 17/19] Display the name of the failed file in tidy/libcoretest --- src/tools/tidy/src/libcoretest.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/tools/tidy/src/libcoretest.rs b/src/tools/tidy/src/libcoretest.rs index f6864c7f84e5a..363d01d964eb5 100644 --- a/src/tools/tidy/src/libcoretest.rs +++ b/src/tools/tidy/src/libcoretest.rs @@ -22,14 +22,21 @@ pub fn check(path: &Path, bad: &mut bool) { &libcore_path, &mut |subpath| t!(subpath.strip_prefix(&libcore_path)).starts_with("tests"), &mut |subpath| { - if subpath.ends_with(".rs") { - if t!(read_to_string(subpath)).contains("#[test]") { - tidy_error!( - bad, - "{} contains #[test]; libcore tests must be placed inside \ - `src/libcore/tests/`", - subpath.display() - ); + if let Some("rs") = subpath.extension().and_then(|e| e.to_str()) { + match read_to_string(subpath) { + Ok(contents) => { + if contents.contains("#[test]") { + tidy_error!( + bad, + "{} contains #[test]; libcore tests must be placed inside \ + `src/libcore/tests/`", + subpath.display() + ); + } + } + Err(err) => { + panic!("failed to read file {:?}: {}", subpath, err); + } } } }, From 28856327066b9d15662ffd185196366de02c6240 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 May 2018 09:14:23 -0700 Subject: [PATCH 18/19] rustc: Allow an edition's feature on that edition This commit fixes a hard error where the `#![feature(rust_2018_preview)]` feature was forbidden to be mentioned when the `--edition 2018` flag was passed. This instead silently accepts that feature gate despite it not being necessary. It's intended that this will help ease the transition into the 2018 edition as users will, for the time being, start off with the `rust_2018_preview` feature and no longer immediately need to remove it. Closes #50662 --- src/libsyntax/feature_gate.rs | 87 +++++++++++---------- src/test/compile-fail/edition-feature-ok.rs | 16 ++++ 2 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 src/test/compile-fail/edition-feature-ok.rs diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index a137faf689fb7..b27568a61f85c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1861,56 +1861,61 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], continue } - match attr.meta_item_list() { + let list = match attr.meta_item_list() { + Some(list) => list, None => { span_err!(span_handler, attr.span, E0555, "malformed feature attribute, expected #![feature(...)]"); + continue + } + }; + + for mi in list { + let name = if let Some(word) = mi.word() { + word.name() + } else { + span_err!(span_handler, mi.span, E0556, + "malformed feature, expected just one word"); + continue + }; + + if let Some((.., set)) = ACTIVE_FEATURES.iter().find(|f| name == f.0) { + set(&mut features, mi.span); + feature_checker.collect(&features, mi.span); + continue } - Some(list) => { - for mi in list { - let name = if let Some(word) = mi.word() { - word.name() - } else { - span_err!(span_handler, mi.span, E0556, - "malformed feature, expected just one word"); - continue - }; - - if let Some(&(_, _, _, _, set)) = ACTIVE_FEATURES.iter() - .find(|& &(n, ..)| name == n) { - set(&mut features, mi.span); - feature_checker.collect(&features, mi.span); - } - else if let Some(&(.., reason)) = REMOVED_FEATURES.iter() - .find(|& &(n, ..)| name == n) - .or_else(|| STABLE_REMOVED_FEATURES.iter() - .find(|& &(n, ..)| name == n)) { - feature_removed(span_handler, mi.span, reason); - } - else if let Some(&(..)) = ACCEPTED_FEATURES.iter() - .find(|& &(n, ..)| name == n) { - features.declared_stable_lang_features.push((name, mi.span)); - } else if let Some(&edition) = ALL_EDITIONS.iter() - .find(|e| name == e.feature_name()) { - if edition <= crate_edition { - feature_removed(span_handler, mi.span, None); - } else { - for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { - if let Some(f_edition) = f_edition { - if edition >= f_edition { - // FIXME(Manishearth) there is currently no way to set - // lib features by edition - set(&mut features, DUMMY_SP); - } - } - } + let removed = REMOVED_FEATURES.iter().find(|f| name == f.0); + let stable_removed = STABLE_REMOVED_FEATURES.iter().find(|f| name == f.0); + if let Some((.., reason)) = removed.or(stable_removed) { + feature_removed(span_handler, mi.span, *reason); + continue + } + + if ACCEPTED_FEATURES.iter().any(|f| name == f.0) { + features.declared_stable_lang_features.push((name, mi.span)); + continue + } + + if let Some(edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) { + if *edition <= crate_edition { + continue + } + + for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { + if let Some(f_edition) = f_edition { + if *edition >= f_edition { + // FIXME(Manishearth) there is currently no way to set + // lib features by edition + set(&mut features, DUMMY_SP); } - } else { - features.declared_lib_features.push((name, mi.span)); } } + + continue } + + features.declared_lib_features.push((name, mi.span)); } } diff --git a/src/test/compile-fail/edition-feature-ok.rs b/src/test/compile-fail/edition-feature-ok.rs new file mode 100644 index 0000000000000..3a3a6ff95f97e --- /dev/null +++ b/src/test/compile-fail/edition-feature-ok.rs @@ -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. + +// compile-flags:--edition 2018 +// compile-pass + +#![feature(rust_2018_preview)] + +fn main() {} From da79ff3cc2265514483d2a5e1f4238c85baa70e9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 May 2018 11:31:08 -0700 Subject: [PATCH 19/19] rustc: Only suggest deleting `extern crate` if it works This commit updates one of the edition lints to only suggest deleting `extern crate` if it actually works. Otherwise this can yield some confusing behavior with rustfix specifically where if you accidentally deny the `rust_2018_idioms` lint in the 2015 edition it's suggesting features that don't work! --- src/librustc_lint/builtin.rs | 3 +++ .../auxiliary/edition-extern-crate-allowed.rs | 11 ++++++++++ .../edition-extern-crate-allowed.rs | 19 ++++++++++++++++ .../ui-fulldeps/unnecessary-extern-crate.rs | 2 ++ .../unnecessary-extern-crate.stderr | 22 +++++++++---------- 5 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs create mode 100644 src/test/compile-fail/edition-extern-crate-allowed.rs diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 251b95a6fcb79..0fb78b9f1b81d 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1548,6 +1548,9 @@ impl LintPass for ExternCrate { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExternCrate { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + if !cx.tcx.features().extern_absolute_paths { + return + } if let hir::ItemExternCrate(ref orig) = it.node { if it.attrs.iter().any(|a| a.check_name("macro_use")) { return diff --git a/src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs b/src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs new file mode 100644 index 0000000000000..d26ab6d351830 --- /dev/null +++ b/src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs @@ -0,0 +1,11 @@ +// Copyright 2014 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. + +// intentionally empty diff --git a/src/test/compile-fail/edition-extern-crate-allowed.rs b/src/test/compile-fail/edition-extern-crate-allowed.rs new file mode 100644 index 0000000000000..286ee896161a6 --- /dev/null +++ b/src/test/compile-fail/edition-extern-crate-allowed.rs @@ -0,0 +1,19 @@ +// 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. + +// aux-build:edition-extern-crate-allowed.rs +// compile-flags: --edition 2015 +// compile-pass + +#![deny(rust_2018_idioms)] + +extern crate edition_extern_crate_allowed; + +fn main() {} diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.rs b/src/test/ui-fulldeps/unnecessary-extern-crate.rs index 9d678d91578bc..0f532d3da6a73 100644 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.rs +++ b/src/test/ui-fulldeps/unnecessary-extern-crate.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: --edition 2018 + #![deny(unnecessary_extern_crate)] #![feature(alloc, test, libc)] diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr b/src/test/ui-fulldeps/unnecessary-extern-crate.stderr index 7718808be58ba..b0b56f527e64f 100644 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr +++ b/src/test/ui-fulldeps/unnecessary-extern-crate.stderr @@ -1,65 +1,65 @@ error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:14:1 + --> $DIR/unnecessary-extern-crate.rs:16:1 | LL | extern crate alloc; | ^^^^^^^^^^^^^^^^^^^ help: remove it | note: lint level defined here - --> $DIR/unnecessary-extern-crate.rs:11:9 + --> $DIR/unnecessary-extern-crate.rs:13:9 | LL | #![deny(unnecessary_extern_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:17:1 + --> $DIR/unnecessary-extern-crate.rs:19:1 | LL | extern crate alloc as x; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:23:1 + --> $DIR/unnecessary-extern-crate.rs:25:1 | LL | pub extern crate test as y; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test as y` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:26:1 + --> $DIR/unnecessary-extern-crate.rs:28:1 | LL | pub extern crate libc; | ^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use libc` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:32:5 + --> $DIR/unnecessary-extern-crate.rs:34:5 | LL | extern crate alloc; | ^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:35:5 + --> $DIR/unnecessary-extern-crate.rs:37:5 | LL | extern crate alloc as x; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:38:5 + --> $DIR/unnecessary-extern-crate.rs:40:5 | LL | pub extern crate test; | ^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:41:5 + --> $DIR/unnecessary-extern-crate.rs:43:5 | LL | pub extern crate test as y; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test as y` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:45:9 + --> $DIR/unnecessary-extern-crate.rs:47:9 | LL | extern crate alloc; | ^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc` error: `extern crate` is unnecessary in the new edition - --> $DIR/unnecessary-extern-crate.rs:48:9 + --> $DIR/unnecessary-extern-crate.rs:50:9 | LL | extern crate alloc as x; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x`