1
Fork 0

Deny rust_2018_idioms in liballoc tests

This commit is contained in:
Philipp Hansch 2019-04-20 16:05:25 +02:00
parent d5d1ee86bb
commit 110a73d6c6
No known key found for this signature in database
GPG key ID: 82AA61CAA11397E6
3 changed files with 15 additions and 14 deletions

View file

@ -7,9 +7,9 @@ fn check_cow_add_cow() {
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 @@ fn check_cow_add_str() {
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 @@ fn check_cow_add_assign_cow() {
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 @@ fn check_cow_add_assign_str() {
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 @@ fn check_cow_add_assign_str() {
#[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);
}

View file

@ -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;

View file

@ -54,11 +54,11 @@ fn test_from_utf8() {
#[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";