Skip to content

Commit 110a73d

Browse files
committed
Deny rust_2018_idioms in liballoc tests
1 parent d5d1ee8 commit 110a73d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/liballoc/tests/cow_str.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ fn check_cow_add_cow() {
77
let borrowed2 = Cow::Borrowed("World!");
88
let borrow_empty = Cow::Borrowed("");
99

10-
let owned1: Cow<str> = Cow::Owned(String::from("Hi, "));
11-
let owned2: Cow<str> = Cow::Owned(String::from("Rustaceans!"));
12-
let owned_empty: Cow<str> = Cow::Owned(String::new());
10+
let owned1: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
11+
let owned2: Cow<'_, str> = Cow::Owned(String::from("Rustaceans!"));
12+
let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
1313

1414
assert_eq!("Hello, World!", borrowed1.clone() + borrowed2.clone());
1515
assert_eq!("Hello, Rustaceans!", borrowed1.clone() + owned2.clone());
@@ -36,8 +36,8 @@ fn check_cow_add_str() {
3636
let borrowed = Cow::Borrowed("Hello, ");
3737
let borrow_empty = Cow::Borrowed("");
3838

39-
let owned: Cow<str> = Cow::Owned(String::from("Hi, "));
40-
let owned_empty: Cow<str> = Cow::Owned(String::new());
39+
let owned: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
40+
let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
4141

4242
assert_eq!("Hello, World!", borrowed.clone() + "World!");
4343

@@ -60,9 +60,9 @@ fn check_cow_add_assign_cow() {
6060
let borrowed2 = Cow::Borrowed("World!");
6161
let borrow_empty = Cow::Borrowed("");
6262

63-
let mut owned1: Cow<str> = Cow::Owned(String::from("Hi, "));
64-
let owned2: Cow<str> = Cow::Owned(String::from("Rustaceans!"));
65-
let owned_empty: Cow<str> = Cow::Owned(String::new());
63+
let mut owned1: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
64+
let owned2: Cow<'_, str> = Cow::Owned(String::from("Rustaceans!"));
65+
let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
6666

6767
let mut s = borrowed1.clone();
6868
s += borrow_empty.clone();
@@ -101,8 +101,8 @@ fn check_cow_add_assign_str() {
101101
let mut borrowed = Cow::Borrowed("Hello, ");
102102
let borrow_empty = Cow::Borrowed("");
103103

104-
let mut owned: Cow<str> = Cow::Owned(String::from("Hi, "));
105-
let owned_empty: Cow<str> = Cow::Owned(String::new());
104+
let mut owned: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
105+
let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
106106

107107
let mut s = borrowed.clone();
108108
s += "";
@@ -132,10 +132,10 @@ fn check_cow_add_assign_str() {
132132

133133
#[test]
134134
fn check_cow_clone_from() {
135-
let mut c1: Cow<str> = Cow::Owned(String::with_capacity(25));
135+
let mut c1: Cow<'_, str> = Cow::Owned(String::with_capacity(25));
136136
let s: String = "hi".to_string();
137137
assert!(s.capacity() < 25);
138-
let c2: Cow<str> = Cow::Owned(s);
138+
let c2: Cow<'_, str> = Cow::Owned(s);
139139
c1.clone_from(&c2);
140140
assert!(c1.into_owned().capacity() >= 25);
141141
}

src/liballoc/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![feature(try_reserve)]
88
#![feature(unboxed_closures)]
99
#![feature(vecdeque_rotate)]
10+
#![deny(rust_2018_idioms)]
1011

1112
use std::hash::{Hash, Hasher};
1213
use std::collections::hash_map::DefaultHasher;

src/liballoc/tests/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ fn test_from_utf8() {
5454
#[test]
5555
fn test_from_utf8_lossy() {
5656
let xs = b"hello";
57-
let ys: Cow<str> = "hello".into_cow();
57+
let ys: Cow<'_, str> = "hello".into_cow();
5858
assert_eq!(String::from_utf8_lossy(xs), ys);
5959

6060
let xs = "ศไทย中华Việt Nam".as_bytes();
61-
let ys: Cow<str> = "ศไทย中华Việt Nam".into_cow();
61+
let ys: Cow<'_, str> = "ศไทย中华Việt Nam".into_cow();
6262
assert_eq!(String::from_utf8_lossy(xs), ys);
6363

6464
let xs = b"Hello\xC2 There\xFF Goodbye";

0 commit comments

Comments
 (0)