Skip to content

Commit c9ae688

Browse files
committed
Deny rust_2018_idioms in libcore tests
1 parent 110a73d commit c9ae688

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

src/libcore/tests/cell.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ fn ref_clone_updates_flag() {
139139
fn ref_map_does_not_update_flag() {
140140
let x = RefCell::new(Some(5));
141141
{
142-
let b1: Ref<Option<u32>> = x.borrow();
142+
let b1: Ref<'_, Option<u32>> = x.borrow();
143143
assert!(x.try_borrow().is_ok());
144144
assert!(x.try_borrow_mut().is_err());
145145
{
146-
let b2: Ref<u32> = Ref::map(b1, |o| o.as_ref().unwrap());
146+
let b2: Ref<'_, u32> = Ref::map(b1, |o| o.as_ref().unwrap());
147147
assert_eq!(*b2, 5);
148148
assert!(x.try_borrow().is_ok());
149149
assert!(x.try_borrow_mut().is_err());
@@ -217,26 +217,26 @@ fn ref_mut_map_split() {
217217
fn ref_map_accessor() {
218218
struct X(RefCell<(u32, char)>);
219219
impl X {
220-
fn accessor(&self) -> Ref<u32> {
220+
fn accessor(&self) -> Ref<'_, u32> {
221221
Ref::map(self.0.borrow(), |tuple| &tuple.0)
222222
}
223223
}
224224
let x = X(RefCell::new((7, 'z')));
225-
let d: Ref<u32> = x.accessor();
225+
let d: Ref<'_, u32> = x.accessor();
226226
assert_eq!(*d, 7);
227227
}
228228

229229
#[test]
230230
fn ref_mut_map_accessor() {
231231
struct X(RefCell<(u32, char)>);
232232
impl X {
233-
fn accessor(&self) -> RefMut<u32> {
233+
fn accessor(&self) -> RefMut<'_, u32> {
234234
RefMut::map(self.0.borrow_mut(), |tuple| &mut tuple.0)
235235
}
236236
}
237237
let x = X(RefCell::new((7, 'z')));
238238
{
239-
let mut d: RefMut<u32> = x.accessor();
239+
let mut d: RefMut<'_ ,u32> = x.accessor();
240240
assert_eq!(*d, 7);
241241
*d += 1;
242242
}
@@ -333,16 +333,16 @@ fn refcell_unsized() {
333333
fn refcell_ref_coercion() {
334334
let cell: RefCell<[i32; 3]> = RefCell::new([1, 2, 3]);
335335
{
336-
let mut cellref: RefMut<[i32; 3]> = cell.borrow_mut();
336+
let mut cellref: RefMut<'_, [i32; 3]> = cell.borrow_mut();
337337
cellref[0] = 4;
338-
let mut coerced: RefMut<[i32]> = cellref;
338+
let mut coerced: RefMut<'_, [i32]> = cellref;
339339
coerced[2] = 5;
340340
}
341341
{
342342
let comp: &mut [i32] = &mut [4, 2, 5];
343-
let cellref: Ref<[i32; 3]> = cell.borrow();
343+
let cellref: Ref<'_, [i32; 3]> = cell.borrow();
344344
assert_eq!(&*cellref, comp);
345-
let coerced: Ref<[i32]> = cellref;
345+
let coerced: Ref<'_, [i32]> = cellref;
346346
assert_eq!(&*coerced, comp);
347347
}
348348
}

src/libcore/tests/fmt/builders.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod debug_struct {
66
struct Foo;
77

88
impl fmt::Debug for Foo {
9-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
9+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1010
fmt.debug_struct("Foo").finish()
1111
}
1212
}
@@ -20,7 +20,7 @@ mod debug_struct {
2020
struct Foo;
2121

2222
impl fmt::Debug for Foo {
23-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
23+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2424
fmt.debug_struct("Foo")
2525
.field("bar", &true)
2626
.finish()
@@ -40,7 +40,7 @@ mod debug_struct {
4040
struct Foo;
4141

4242
impl fmt::Debug for Foo {
43-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
43+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
4444
fmt.debug_struct("Foo")
4545
.field("bar", &true)
4646
.field("baz", &format_args!("{}/{}", 10, 20))
@@ -62,7 +62,7 @@ mod debug_struct {
6262
struct Foo;
6363

6464
impl fmt::Debug for Foo {
65-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
65+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
6666
fmt.debug_struct("Foo")
6767
.field("bar", &true)
6868
.field("baz", &format_args!("{}/{}", 10, 20))
@@ -73,7 +73,7 @@ mod debug_struct {
7373
struct Bar;
7474

7575
impl fmt::Debug for Bar {
76-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
76+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
7777
fmt.debug_struct("Bar")
7878
.field("foo", &Foo)
7979
.field("hello", &"world")
@@ -103,7 +103,7 @@ mod debug_tuple {
103103
struct Foo;
104104

105105
impl fmt::Debug for Foo {
106-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
106+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
107107
fmt.debug_tuple("Foo").finish()
108108
}
109109
}
@@ -117,7 +117,7 @@ mod debug_tuple {
117117
struct Foo;
118118

119119
impl fmt::Debug for Foo {
120-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
120+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
121121
fmt.debug_tuple("Foo")
122122
.field(&true)
123123
.finish()
@@ -137,7 +137,7 @@ mod debug_tuple {
137137
struct Foo;
138138

139139
impl fmt::Debug for Foo {
140-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
140+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
141141
fmt.debug_tuple("Foo")
142142
.field(&true)
143143
.field(&format_args!("{}/{}", 10, 20))
@@ -159,7 +159,7 @@ mod debug_tuple {
159159
struct Foo;
160160

161161
impl fmt::Debug for Foo {
162-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
162+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
163163
fmt.debug_tuple("Foo")
164164
.field(&true)
165165
.field(&format_args!("{}/{}", 10, 20))
@@ -170,7 +170,7 @@ mod debug_tuple {
170170
struct Bar;
171171

172172
impl fmt::Debug for Bar {
173-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
173+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
174174
fmt.debug_tuple("Bar")
175175
.field(&Foo)
176176
.field(&"world")
@@ -200,7 +200,7 @@ mod debug_map {
200200
struct Foo;
201201

202202
impl fmt::Debug for Foo {
203-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
203+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
204204
fmt.debug_map().finish()
205205
}
206206
}
@@ -214,7 +214,7 @@ mod debug_map {
214214
struct Foo;
215215

216216
impl fmt::Debug for Foo {
217-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
217+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
218218
fmt.debug_map()
219219
.entry(&"bar", &true)
220220
.finish()
@@ -234,7 +234,7 @@ mod debug_map {
234234
struct Foo;
235235

236236
impl fmt::Debug for Foo {
237-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
237+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
238238
fmt.debug_map()
239239
.entry(&"bar", &true)
240240
.entry(&10, &format_args!("{}/{}", 10, 20))
@@ -256,7 +256,7 @@ mod debug_map {
256256
struct Foo;
257257

258258
impl fmt::Debug for Foo {
259-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
259+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
260260
fmt.debug_map()
261261
.entry(&"bar", &true)
262262
.entry(&10, &format_args!("{}/{}", 10, 20))
@@ -267,7 +267,7 @@ mod debug_map {
267267
struct Bar;
268268

269269
impl fmt::Debug for Bar {
270-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
270+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
271271
fmt.debug_map()
272272
.entry(&"foo", &Foo)
273273
.entry(&Foo, &"world")
@@ -301,7 +301,7 @@ mod debug_set {
301301
struct Foo;
302302

303303
impl fmt::Debug for Foo {
304-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
304+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
305305
fmt.debug_set().finish()
306306
}
307307
}
@@ -315,7 +315,7 @@ mod debug_set {
315315
struct Foo;
316316

317317
impl fmt::Debug for Foo {
318-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
318+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
319319
fmt.debug_set()
320320
.entry(&true)
321321
.finish()
@@ -335,7 +335,7 @@ mod debug_set {
335335
struct Foo;
336336

337337
impl fmt::Debug for Foo {
338-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
338+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
339339
fmt.debug_set()
340340
.entry(&true)
341341
.entry(&format_args!("{}/{}", 10, 20))
@@ -357,7 +357,7 @@ mod debug_set {
357357
struct Foo;
358358

359359
impl fmt::Debug for Foo {
360-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
360+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
361361
fmt.debug_set()
362362
.entry(&true)
363363
.entry(&format_args!("{}/{}", 10, 20))
@@ -368,7 +368,7 @@ mod debug_set {
368368
struct Bar;
369369

370370
impl fmt::Debug for Bar {
371-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
371+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
372372
fmt.debug_set()
373373
.entry(&Foo)
374374
.entry(&"world")
@@ -398,7 +398,7 @@ mod debug_list {
398398
struct Foo;
399399

400400
impl fmt::Debug for Foo {
401-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
401+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
402402
fmt.debug_list().finish()
403403
}
404404
}
@@ -412,7 +412,7 @@ mod debug_list {
412412
struct Foo;
413413

414414
impl fmt::Debug for Foo {
415-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
415+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
416416
fmt.debug_list()
417417
.entry(&true)
418418
.finish()
@@ -432,7 +432,7 @@ mod debug_list {
432432
struct Foo;
433433

434434
impl fmt::Debug for Foo {
435-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
435+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
436436
fmt.debug_list()
437437
.entry(&true)
438438
.entry(&format_args!("{}/{}", 10, 20))
@@ -454,7 +454,7 @@ mod debug_list {
454454
struct Foo;
455455

456456
impl fmt::Debug for Foo {
457-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
457+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
458458
fmt.debug_list()
459459
.entry(&true)
460460
.entry(&format_args!("{}/{}", 10, 20))
@@ -465,7 +465,7 @@ mod debug_list {
465465
struct Bar;
466466

467467
impl fmt::Debug for Bar {
468-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
468+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
469469
fmt.debug_list()
470470
.entry(&Foo)
471471
.entry(&"world")

src/libcore/tests/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,12 @@ fn test_iterator_peekable_fold() {
567567
/// This is an iterator that follows the Iterator contract,
568568
/// but it is not fused. After having returned None once, it will start
569569
/// producing elements if .next() is called again.
570-
pub struct CycleIter<'a, T: 'a> {
570+
pub struct CycleIter<'a, T> {
571571
index: usize,
572572
data: &'a [T],
573573
}
574574

575-
pub fn cycle<T>(data: &[T]) -> CycleIter<T> {
575+
pub fn cycle<T>(data: &[T]) -> CycleIter<'_, T> {
576576
CycleIter {
577577
index: 0,
578578
data,

src/libcore/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#![feature(slice_partition_dedup)]
3333
#![feature(copy_within)]
3434
#![feature(int_error_matching)]
35+
#![deny(rust_2018_idioms)]
3536

36-
extern crate core;
3737
extern crate test;
3838

3939
mod any;

0 commit comments

Comments
 (0)