diff --git a/src/liballoc/tests/cow_str.rs b/src/liballoc/tests/cow_str.rs index eb6adb159b0..6f357eda9b8 100644 --- a/src/liballoc/tests/cow_str.rs +++ b/src/liballoc/tests/cow_str.rs @@ -7,9 +7,9 @@ fn check_cow_add_cow() { let borrowed2 = Cow::Borrowed("World!"); let borrow_empty = Cow::Borrowed(""); - let owned1: Cow = Cow::Owned(String::from("Hi, ")); - let owned2: Cow = Cow::Owned(String::from("Rustaceans!")); - let owned_empty: Cow = 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 @@ fn check_cow_add_str() { let borrowed = Cow::Borrowed("Hello, "); let borrow_empty = Cow::Borrowed(""); - let owned: Cow = Cow::Owned(String::from("Hi, ")); - let owned_empty: Cow = 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 @@ fn check_cow_add_assign_cow() { let borrowed2 = Cow::Borrowed("World!"); let borrow_empty = Cow::Borrowed(""); - let mut owned1: Cow = Cow::Owned(String::from("Hi, ")); - let owned2: Cow = Cow::Owned(String::from("Rustaceans!")); - let owned_empty: Cow = 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 @@ fn check_cow_add_assign_str() { let mut borrowed = Cow::Borrowed("Hello, "); let borrow_empty = Cow::Borrowed(""); - let mut owned: Cow = Cow::Owned(String::from("Hi, ")); - let owned_empty: Cow = 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 @@ fn check_cow_add_assign_str() { #[test] fn check_cow_clone_from() { - let mut c1: Cow = 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 = 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 90921b6af9f..b736750c576 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 7e75b8c4f28..765210e5aa6 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -54,11 +54,11 @@ fn test_from_utf8() { #[test] fn test_from_utf8_lossy() { let xs = b"hello"; - let ys: Cow = "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 = "ศไทย中华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";