Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix
Enable NLL migrate mode on the 2015 edition
## What is in this PR?
* Remove the `-Zborrowck=ast` flag option from rustc.
* The default in the 2015 edition is now `-Zborrowck=migrate`.
* The 2018 edition default is unchanged: it's still `-Zborrowck=migrate`.
* Enable two-phase borrows (currently toggled via the `-Ztwo-phase-borrows` flag) on all editions.
* Remove most dead code that handled these options.
* Update tests for the above changes.
## What is *not* in this PR?
These are left for future PRs
* Use `-Zborrowck=mir` in NLL compare mode tests (#56993)
* Remove the `-Zborrowck=compare` option (#59193)
* Remove the `-Ztwo-phase-borrows` flag. It's kept, as a flag that does nothing so that perf.rlo has time to stop using it (cc @Mark-Simulacrum)
* Remove MIR typeck as its own MIR pass - it's now run by NLL.
* Enabling `-Zborrowck=mir` by default (#58781)
* Replace `allow_bind_by_move_patterns_with_guards` and `check_for_mutation_in_guard_via_ast_walk` with just using the feature gate. (#59192)
Soundness issues that are fixed by NLL will stay open until full NLL is emitting hard errors. However, these diagnostics and completeness issues can now be closed:
Closes #18330
Closes #22323
Closes #23591
Closes #26736
Closes #27487
Closes #28092
Closes #28970
Closes #29733
Closes #30104
Closes #38915
Closes #39908
Closes #43407
Closes #47524
Closes #48540
Closes #49073
Closes #52614
Closes #55085
Closes #56093
Closes #56496
Closes #57804
cc #43234
r? @pnkfelix
cc @rust-lang/lang
cc @rust-lang/wg-compiler-nll
diff --git a/Cargo.lock b/Cargo.lock
index 72a0575..4c493b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1367,7 +1367,7 @@
[[package]]
name = "lsp-types"
-version = "0.55.4"
+version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2029,7 +2029,7 @@
[[package]]
name = "racer"
-version = "2.1.21"
+version = "2.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2039,7 +2039,7 @@
"humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-syntax 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2221,7 +2221,7 @@
[[package]]
name = "rls"
-version = "1.35.0"
+version = "1.36.0"
dependencies = [
"cargo 0.37.0",
"cargo_metadata 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2238,19 +2238,19 @@
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lsp-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "lsp-types 0.55.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lsp-types 0.57.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "racer 2.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
+ "racer 2.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-analysis 0.16.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-analysis 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-rustc 0.6.0",
- "rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-vfs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-workspace-hack 1.0.0",
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2270,7 +2270,7 @@
[[package]]
name = "rls-analysis"
-version = "0.16.12"
+version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2278,9 +2278,10 @@
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
"json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2290,13 +2291,11 @@
[[package]]
name = "rls-data"
-version = "0.18.2"
+version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2305,21 +2304,19 @@
[[package]]
name = "rls-span"
-version = "0.4.1"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rls-vfs"
-version = "0.7.0"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2930,14 +2927,14 @@
version = "0.0.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_codegen_utils 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_target 0.0.0",
"rustc_typeck 0.0.0",
+ "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]
@@ -4125,7 +4122,7 @@
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum log_settings 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19af41f0565d7c19b2058153ad0b42d4d5ce89ec4dbf06ed6741114a8b63e7cd"
"checksum lsp-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "169d737ad89cf8ddd82d1804d9122f54568c49377665157277cc90d747b1d31a"
-"checksum lsp-types 0.55.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6392b5843615b8a2adeebe87b83fdd29567c0870baba3407a67e6dbfee4712f8"
+"checksum lsp-types 0.57.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d220de1fbbb12b60df17898272579c22329375fc4baa960402fbd17cf0cdd165"
"checksum lzma-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d1eaa027402541975218bb0eec67d6b0412f6233af96e0d096d31dbdfd22e614"
"checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
"checksum macro-utils 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2c4deaccc2ead6a28c16c0ba82f07d52b6475397415ce40876e559b0b0ea510"
@@ -4191,7 +4188,7 @@
"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.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
-"checksum racer 2.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "37c88638777cc178684cf648ca0e1dad56646ce105b8593dfe665c436300adc3"
+"checksum racer 2.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4323343f25bc372dc9293ac6b5cd3034b32784af1e7de9366b4db71466d8c7"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a"
"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
@@ -4210,11 +4207,11 @@
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
"checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
-"checksum rls-analysis 0.16.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ae18d8ad01dec3b2014f4d7ae3c607d7adbcff79e5d3b48ea42ea71c10d43a71"
+"checksum rls-analysis 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d53d49a28f75da9d02790d9256fecf6c0481e0871374326023c7a33131295579"
"checksum rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ce1fdac03e138c4617ff87b194e1ff57a39bb985a044ccbd8673d30701e411"
-"checksum rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f80b84551b32e26affaf7f12374913b5061730c0dcd185d9e8fa5a15e36e65c"
-"checksum rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "33d66f1d6c6ccd5c98029f162544131698f6ebb61d8c697681cac409dcd08805"
-"checksum rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72d56425bd5aa86d9d4372b76f0381d3b4bda9c0220e71956c9fcc929f45c1f1"
+"checksum rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76c72ea97e045be5f6290bb157ebdc5ee9f2b093831ff72adfaf59025cf5c491"
+"checksum rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f1cb4694410d8d2ce43ccff3682f1c782158a018d5a9a92185675677f7533eb3"
+"checksum rls-vfs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce4b57b25b4330ed5ec14028fc02141e083ddafda327e7eb598dc0569c8c83c9"
"checksum rustc-ap-arena 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5aab2fb5e5becf1c9183f6c63b8714817a3e780a20b4fe6b3920751c98a18225"
"checksum rustc-ap-graphviz 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0235ff613d4f96176ea56748010b5d8e978605cc47856ba9bb5372f4f38e9c03"
"checksum rustc-ap-rustc_cratesio_shim 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63e04a90b0dd8597da83633961698c61a2948f50c9d4b9a71e8afafc0ba0f158"
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index a8f0d24..50d170b 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -308,6 +308,7 @@
{
cmd.arg("-Dwarnings");
cmd.arg("-Dbare_trait_objects");
+ cmd.arg("-Drust_2018_idioms");
}
if verbose > 1 {
diff --git a/src/liballoc/tests/cow_str.rs b/src/liballoc/tests/cow_str.rs
index eb6adb1..6f357ed 100644
--- a/src/liballoc/tests/cow_str.rs
+++ b/src/liballoc/tests/cow_str.rs
@@ -7,9 +7,9 @@
let borrowed2 = Cow::Borrowed("World!");
let borrow_empty = Cow::Borrowed("");
- let owned1: Cow<str> = Cow::Owned(String::from("Hi, "));
- let owned2: Cow<str> = Cow::Owned(String::from("Rustaceans!"));
- let owned_empty: Cow<str> = Cow::Owned(String::new());
+ let owned1: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
+ let owned2: Cow<'_, str> = Cow::Owned(String::from("Rustaceans!"));
+ let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
assert_eq!("Hello, World!", borrowed1.clone() + borrowed2.clone());
assert_eq!("Hello, Rustaceans!", borrowed1.clone() + owned2.clone());
@@ -36,8 +36,8 @@
let borrowed = Cow::Borrowed("Hello, ");
let borrow_empty = Cow::Borrowed("");
- let owned: Cow<str> = Cow::Owned(String::from("Hi, "));
- let owned_empty: Cow<str> = Cow::Owned(String::new());
+ let owned: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
+ let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
assert_eq!("Hello, World!", borrowed.clone() + "World!");
@@ -60,9 +60,9 @@
let borrowed2 = Cow::Borrowed("World!");
let borrow_empty = Cow::Borrowed("");
- let mut owned1: Cow<str> = Cow::Owned(String::from("Hi, "));
- let owned2: Cow<str> = Cow::Owned(String::from("Rustaceans!"));
- let owned_empty: Cow<str> = Cow::Owned(String::new());
+ let mut owned1: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
+ let owned2: Cow<'_, str> = Cow::Owned(String::from("Rustaceans!"));
+ let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
let mut s = borrowed1.clone();
s += borrow_empty.clone();
@@ -101,8 +101,8 @@
let mut borrowed = Cow::Borrowed("Hello, ");
let borrow_empty = Cow::Borrowed("");
- let mut owned: Cow<str> = Cow::Owned(String::from("Hi, "));
- let owned_empty: Cow<str> = Cow::Owned(String::new());
+ let mut owned: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
+ let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
let mut s = borrowed.clone();
s += "";
@@ -132,10 +132,10 @@
#[test]
fn check_cow_clone_from() {
- let mut c1: Cow<str> = Cow::Owned(String::with_capacity(25));
+ let mut c1: Cow<'_, str> = Cow::Owned(String::with_capacity(25));
let s: String = "hi".to_string();
assert!(s.capacity() < 25);
- let c2: Cow<str> = Cow::Owned(s);
+ let c2: Cow<'_, str> = Cow::Owned(s);
c1.clone_from(&c2);
assert!(c1.into_owned().capacity() >= 25);
}
diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs
index 90921b6..b736750 100644
--- a/src/liballoc/tests/lib.rs
+++ b/src/liballoc/tests/lib.rs
@@ -7,6 +7,7 @@
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(vecdeque_rotate)]
+#![deny(rust_2018_idioms)]
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs
index 7e75b8c..765210e 100644
--- a/src/liballoc/tests/string.rs
+++ b/src/liballoc/tests/string.rs
@@ -54,11 +54,11 @@
#[test]
fn test_from_utf8_lossy() {
let xs = b"hello";
- let ys: Cow<str> = "hello".into_cow();
+ let ys: Cow<'_, str> = "hello".into_cow();
assert_eq!(String::from_utf8_lossy(xs), ys);
let xs = "ศไทย中华Việt Nam".as_bytes();
- let ys: Cow<str> = "ศไทย中华Việt Nam".into_cow();
+ let ys: Cow<'_, str> = "ศไทย中华Việt Nam".into_cow();
assert_eq!(String::from_utf8_lossy(xs), ys);
let xs = b"Hello\xC2 There\xFF Goodbye";
diff --git a/src/libcore/tests/cell.rs b/src/libcore/tests/cell.rs
index 7bd7d18..4dfd884 100644
--- a/src/libcore/tests/cell.rs
+++ b/src/libcore/tests/cell.rs
@@ -139,11 +139,11 @@
fn ref_map_does_not_update_flag() {
let x = RefCell::new(Some(5));
{
- let b1: Ref<Option<u32>> = x.borrow();
+ let b1: Ref<'_, Option<u32>> = x.borrow();
assert!(x.try_borrow().is_ok());
assert!(x.try_borrow_mut().is_err());
{
- let b2: Ref<u32> = Ref::map(b1, |o| o.as_ref().unwrap());
+ let b2: Ref<'_, u32> = Ref::map(b1, |o| o.as_ref().unwrap());
assert_eq!(*b2, 5);
assert!(x.try_borrow().is_ok());
assert!(x.try_borrow_mut().is_err());
@@ -217,12 +217,12 @@
fn ref_map_accessor() {
struct X(RefCell<(u32, char)>);
impl X {
- fn accessor(&self) -> Ref<u32> {
+ fn accessor(&self) -> Ref<'_, u32> {
Ref::map(self.0.borrow(), |tuple| &tuple.0)
}
}
let x = X(RefCell::new((7, 'z')));
- let d: Ref<u32> = x.accessor();
+ let d: Ref<'_, u32> = x.accessor();
assert_eq!(*d, 7);
}
@@ -230,13 +230,13 @@
fn ref_mut_map_accessor() {
struct X(RefCell<(u32, char)>);
impl X {
- fn accessor(&self) -> RefMut<u32> {
+ fn accessor(&self) -> RefMut<'_, u32> {
RefMut::map(self.0.borrow_mut(), |tuple| &mut tuple.0)
}
}
let x = X(RefCell::new((7, 'z')));
{
- let mut d: RefMut<u32> = x.accessor();
+ let mut d: RefMut<'_ ,u32> = x.accessor();
assert_eq!(*d, 7);
*d += 1;
}
@@ -333,16 +333,16 @@
fn refcell_ref_coercion() {
let cell: RefCell<[i32; 3]> = RefCell::new([1, 2, 3]);
{
- let mut cellref: RefMut<[i32; 3]> = cell.borrow_mut();
+ let mut cellref: RefMut<'_, [i32; 3]> = cell.borrow_mut();
cellref[0] = 4;
- let mut coerced: RefMut<[i32]> = cellref;
+ let mut coerced: RefMut<'_, [i32]> = cellref;
coerced[2] = 5;
}
{
let comp: &mut [i32] = &mut [4, 2, 5];
- let cellref: Ref<[i32; 3]> = cell.borrow();
+ let cellref: Ref<'_, [i32; 3]> = cell.borrow();
assert_eq!(&*cellref, comp);
- let coerced: Ref<[i32]> = cellref;
+ let coerced: Ref<'_, [i32]> = cellref;
assert_eq!(&*coerced, comp);
}
}
diff --git a/src/libcore/tests/fmt/builders.rs b/src/libcore/tests/fmt/builders.rs
index e4b75fe..62fe09c 100644
--- a/src/libcore/tests/fmt/builders.rs
+++ b/src/libcore/tests/fmt/builders.rs
@@ -6,7 +6,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo").finish()
}
}
@@ -20,7 +20,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &true)
.finish()
@@ -40,7 +40,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &true)
.field("baz", &format_args!("{}/{}", 10, 20))
@@ -62,7 +62,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &true)
.field("baz", &format_args!("{}/{}", 10, 20))
@@ -73,7 +73,7 @@
struct Bar;
impl fmt::Debug for Bar {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("foo", &Foo)
.field("hello", &"world")
@@ -103,7 +103,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo").finish()
}
}
@@ -117,7 +117,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&true)
.finish()
@@ -137,7 +137,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&true)
.field(&format_args!("{}/{}", 10, 20))
@@ -159,7 +159,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&true)
.field(&format_args!("{}/{}", 10, 20))
@@ -170,7 +170,7 @@
struct Bar;
impl fmt::Debug for Bar {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Bar")
.field(&Foo)
.field(&"world")
@@ -200,7 +200,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map().finish()
}
}
@@ -214,7 +214,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.entry(&"bar", &true)
.finish()
@@ -234,7 +234,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.entry(&"bar", &true)
.entry(&10, &format_args!("{}/{}", 10, 20))
@@ -256,7 +256,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.entry(&"bar", &true)
.entry(&10, &format_args!("{}/{}", 10, 20))
@@ -267,7 +267,7 @@
struct Bar;
impl fmt::Debug for Bar {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.entry(&"foo", &Foo)
.entry(&Foo, &"world")
@@ -301,7 +301,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set().finish()
}
}
@@ -315,7 +315,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entry(&true)
.finish()
@@ -335,7 +335,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entry(&true)
.entry(&format_args!("{}/{}", 10, 20))
@@ -357,7 +357,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entry(&true)
.entry(&format_args!("{}/{}", 10, 20))
@@ -368,7 +368,7 @@
struct Bar;
impl fmt::Debug for Bar {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entry(&Foo)
.entry(&"world")
@@ -398,7 +398,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list().finish()
}
}
@@ -412,7 +412,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entry(&true)
.finish()
@@ -432,7 +432,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entry(&true)
.entry(&format_args!("{}/{}", 10, 20))
@@ -454,7 +454,7 @@
struct Foo;
impl fmt::Debug for Foo {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entry(&true)
.entry(&format_args!("{}/{}", 10, 20))
@@ -465,7 +465,7 @@
struct Bar;
impl fmt::Debug for Bar {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entry(&Foo)
.entry(&"world")
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs
index 5247331..7dfb1ad 100644
--- a/src/libcore/tests/iter.rs
+++ b/src/libcore/tests/iter.rs
@@ -567,12 +567,12 @@
/// This is an iterator that follows the Iterator contract,
/// but it is not fused. After having returned None once, it will start
/// producing elements if .next() is called again.
-pub struct CycleIter<'a, T: 'a> {
+pub struct CycleIter<'a, T> {
index: usize,
data: &'a [T],
}
-pub fn cycle<T>(data: &[T]) -> CycleIter<T> {
+pub fn cycle<T>(data: &[T]) -> CycleIter<'_, T> {
CycleIter {
index: 0,
data,
diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs
index fcdeb57..2e4a8a1 100644
--- a/src/libcore/tests/lib.rs
+++ b/src/libcore/tests/lib.rs
@@ -32,8 +32,8 @@
#![feature(slice_partition_dedup)]
#![feature(copy_within)]
#![feature(int_error_matching)]
+#![deny(rust_2018_idioms)]
-extern crate core;
extern crate test;
mod any;
diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml
index 8bb2e72..767c726 100644
--- a/src/librustc_save_analysis/Cargo.toml
+++ b/src/librustc_save_analysis/Cargo.toml
@@ -16,9 +16,8 @@
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_target = { path = "../librustc_target" }
rustc_typeck = { path = "../librustc_typeck" }
+serde_json = "1"
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
-rls-data = "0.18.1"
-rls-span = "0.4"
-# FIXME(#40527) should move rustc serialize out of tree
-rustc-serialize = "0.3"
+rls-data = "0.19"
+rls-span = "0.5"
diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs
index 1840cf6..82b78369 100644
--- a/src/librustc_save_analysis/json_dumper.rs
+++ b/src/librustc_save_analysis/json_dumper.rs
@@ -1,7 +1,5 @@
use std::io::Write;
-use rustc_serialize::json::as_json;
-
use rls_data::config::Config;
use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import,
MacroRef, Ref, RefKind, Relation};
@@ -31,8 +29,8 @@
impl<'b, W: Write> DumpOutput for WriteOutput<'b, W> {
fn dump(&mut self, result: &Analysis) {
- if write!(self.output, "{}", as_json(&result)).is_err() {
- error!("Error writing output");
+ if let Err(e) = serde_json::to_writer(self.output.by_ref(), result) {
+ error!("Can't serialize save-analysis: {:?}", e);
}
}
}
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index d901fb2..c173d51 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -1141,10 +1141,15 @@
if let Some(config) = supplied {
return config;
}
+
match env::var_os("RUST_SAVE_ANALYSIS_CONFIG") {
- Some(config_string) => rustc_serialize::json::decode(config_string.to_str().unwrap())
- .expect("Could not deserialize save-analysis config"),
None => Config::default(),
+ Some(config) => config.to_str()
+ .ok_or(())
+ .map_err(|_| error!("`RUST_SAVE_ANALYSIS_CONFIG` isn't UTF-8"))
+ .and_then(|cfg| serde_json::from_str(cfg)
+ .map_err(|_| error!("Could not deserialize save-analysis config"))
+ ).unwrap_or_default()
}
}
diff --git a/src/libserialize/tests/json.rs b/src/libserialize/tests/json.rs
index 3fb6bda..0fe3d4c 100644
--- a/src/libserialize/tests/json.rs
+++ b/src/libserialize/tests/json.rs
@@ -1,3 +1,4 @@
+#[allow(unused_extern_crates)]
extern crate serialize as rustc_serialize;
use rustc_serialize::{Encodable, Decodable};
diff --git a/src/libserialize/tests/opaque.rs b/src/libserialize/tests/opaque.rs
index fff6fc6..62a8f25 100644
--- a/src/libserialize/tests/opaque.rs
+++ b/src/libserialize/tests/opaque.rs
@@ -1,3 +1,4 @@
+#[allow(unused_extern_crates)]
extern crate serialize as rustc_serialize;
use rustc_serialize::{Encodable, Decodable};
diff --git a/src/test/run-pass-fulldeps/newtype_index.rs b/src/test/run-pass-fulldeps/newtype_index.rs
index 3cd622a..18b845e 100644
--- a/src/test/run-pass-fulldeps/newtype_index.rs
+++ b/src/test/run-pass-fulldeps/newtype_index.rs
@@ -1,7 +1,7 @@
#![feature(rustc_attrs, rustc_private, step_trait)]
#[macro_use] extern crate rustc_data_structures;
-extern crate rustc_serialize;
+extern crate serialize as rustc_serialize;
use rustc_data_structures::indexed_vec::Idx;
diff --git a/src/tools/clippy b/src/tools/clippy
index cafbe7f..d420589 160000
--- a/src/tools/clippy
+++ b/src/tools/clippy
@@ -1 +1 @@
-Subproject commit cafbe7f2d9bdf9e94946e3f6f62b781b05b7d556
+Subproject commit d420589e1a8208c85368d07c1644c6725367650b
diff --git a/src/tools/rls b/src/tools/rls
index b202e14..20e3268 160000
--- a/src/tools/rls
+++ b/src/tools/rls
@@ -1 +1 @@
-Subproject commit b202e14dbf53949d05822e680ee5166b33468853
+Subproject commit 20e32686df573fc44ac1052bf3e6982b0da27cfc