Deny rust_2018_idioms in libcore tests

This commit is contained in:
Philipp Hansch 2019-04-20 18:44:29 +02:00
parent 110a73d6c6
commit c9ae68812f
No known key found for this signature in database
GPG Key ID: 82AA61CAA11397E6
4 changed files with 38 additions and 38 deletions

View File

@ -139,11 +139,11 @@ fn ref_clone_updates_flag() {
fn ref_map_does_not_update_flag() { fn ref_map_does_not_update_flag() {
let x = RefCell::new(Some(5)); 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().is_ok());
assert!(x.try_borrow_mut().is_err()); 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_eq!(*b2, 5);
assert!(x.try_borrow().is_ok()); assert!(x.try_borrow().is_ok());
assert!(x.try_borrow_mut().is_err()); assert!(x.try_borrow_mut().is_err());
@ -217,12 +217,12 @@ fn ref_mut_map_split() {
fn ref_map_accessor() { fn ref_map_accessor() {
struct X(RefCell<(u32, char)>); struct X(RefCell<(u32, char)>);
impl X { impl X {
fn accessor(&self) -> Ref<u32> { fn accessor(&self) -> Ref<'_, u32> {
Ref::map(self.0.borrow(), |tuple| &tuple.0) Ref::map(self.0.borrow(), |tuple| &tuple.0)
} }
} }
let x = X(RefCell::new((7, 'z'))); let x = X(RefCell::new((7, 'z')));
let d: Ref<u32> = x.accessor(); let d: Ref<'_, u32> = x.accessor();
assert_eq!(*d, 7); assert_eq!(*d, 7);
} }
@ -230,13 +230,13 @@ fn ref_map_accessor() {
fn ref_mut_map_accessor() { fn ref_mut_map_accessor() {
struct X(RefCell<(u32, char)>); struct X(RefCell<(u32, char)>);
impl X { impl X {
fn accessor(&self) -> RefMut<u32> { fn accessor(&self) -> RefMut<'_, u32> {
RefMut::map(self.0.borrow_mut(), |tuple| &mut tuple.0) RefMut::map(self.0.borrow_mut(), |tuple| &mut tuple.0)
} }
} }
let x = X(RefCell::new((7, 'z'))); 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); assert_eq!(*d, 7);
*d += 1; *d += 1;
} }
@ -333,16 +333,16 @@ fn refcell_unsized() {
fn refcell_ref_coercion() { fn refcell_ref_coercion() {
let cell: RefCell<[i32; 3]> = RefCell::new([1, 2, 3]); 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; cellref[0] = 4;
let mut coerced: RefMut<[i32]> = cellref; let mut coerced: RefMut<'_, [i32]> = cellref;
coerced[2] = 5; coerced[2] = 5;
} }
{ {
let comp: &mut [i32] = &mut [4, 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); assert_eq!(&*cellref, comp);
let coerced: Ref<[i32]> = cellref; let coerced: Ref<'_, [i32]> = cellref;
assert_eq!(&*coerced, comp); assert_eq!(&*coerced, comp);
} }
} }

View File

@ -6,7 +6,7 @@ mod debug_struct {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_struct("Foo").finish()
} }
} }
@ -20,7 +20,7 @@ mod debug_struct {
struct Foo; struct Foo;
impl fmt::Debug for 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") fmt.debug_struct("Foo")
.field("bar", &true) .field("bar", &true)
.finish() .finish()
@ -40,7 +40,7 @@ mod debug_struct {
struct Foo; struct Foo;
impl fmt::Debug for 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") fmt.debug_struct("Foo")
.field("bar", &true) .field("bar", &true)
.field("baz", &format_args!("{}/{}", 10, 20)) .field("baz", &format_args!("{}/{}", 10, 20))
@ -62,7 +62,7 @@ mod debug_struct {
struct Foo; struct Foo;
impl fmt::Debug for 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") fmt.debug_struct("Foo")
.field("bar", &true) .field("bar", &true)
.field("baz", &format_args!("{}/{}", 10, 20)) .field("baz", &format_args!("{}/{}", 10, 20))
@ -73,7 +73,7 @@ mod debug_struct {
struct Bar; struct Bar;
impl fmt::Debug for 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") fmt.debug_struct("Bar")
.field("foo", &Foo) .field("foo", &Foo)
.field("hello", &"world") .field("hello", &"world")
@ -103,7 +103,7 @@ mod debug_tuple {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_tuple("Foo").finish()
} }
} }
@ -117,7 +117,7 @@ mod debug_tuple {
struct Foo; struct Foo;
impl fmt::Debug for 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") fmt.debug_tuple("Foo")
.field(&true) .field(&true)
.finish() .finish()
@ -137,7 +137,7 @@ mod debug_tuple {
struct Foo; struct Foo;
impl fmt::Debug for 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") fmt.debug_tuple("Foo")
.field(&true) .field(&true)
.field(&format_args!("{}/{}", 10, 20)) .field(&format_args!("{}/{}", 10, 20))
@ -159,7 +159,7 @@ mod debug_tuple {
struct Foo; struct Foo;
impl fmt::Debug for 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") fmt.debug_tuple("Foo")
.field(&true) .field(&true)
.field(&format_args!("{}/{}", 10, 20)) .field(&format_args!("{}/{}", 10, 20))
@ -170,7 +170,7 @@ mod debug_tuple {
struct Bar; struct Bar;
impl fmt::Debug for 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") fmt.debug_tuple("Bar")
.field(&Foo) .field(&Foo)
.field(&"world") .field(&"world")
@ -200,7 +200,7 @@ mod debug_map {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_map().finish()
} }
} }
@ -214,7 +214,7 @@ mod debug_map {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_map()
.entry(&"bar", &true) .entry(&"bar", &true)
.finish() .finish()
@ -234,7 +234,7 @@ mod debug_map {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_map()
.entry(&"bar", &true) .entry(&"bar", &true)
.entry(&10, &format_args!("{}/{}", 10, 20)) .entry(&10, &format_args!("{}/{}", 10, 20))
@ -256,7 +256,7 @@ mod debug_map {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_map()
.entry(&"bar", &true) .entry(&"bar", &true)
.entry(&10, &format_args!("{}/{}", 10, 20)) .entry(&10, &format_args!("{}/{}", 10, 20))
@ -267,7 +267,7 @@ mod debug_map {
struct Bar; struct Bar;
impl fmt::Debug for 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() fmt.debug_map()
.entry(&"foo", &Foo) .entry(&"foo", &Foo)
.entry(&Foo, &"world") .entry(&Foo, &"world")
@ -301,7 +301,7 @@ mod debug_set {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_set().finish()
} }
} }
@ -315,7 +315,7 @@ mod debug_set {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_set()
.entry(&true) .entry(&true)
.finish() .finish()
@ -335,7 +335,7 @@ mod debug_set {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_set()
.entry(&true) .entry(&true)
.entry(&format_args!("{}/{}", 10, 20)) .entry(&format_args!("{}/{}", 10, 20))
@ -357,7 +357,7 @@ mod debug_set {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_set()
.entry(&true) .entry(&true)
.entry(&format_args!("{}/{}", 10, 20)) .entry(&format_args!("{}/{}", 10, 20))
@ -368,7 +368,7 @@ mod debug_set {
struct Bar; struct Bar;
impl fmt::Debug for 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() fmt.debug_set()
.entry(&Foo) .entry(&Foo)
.entry(&"world") .entry(&"world")
@ -398,7 +398,7 @@ mod debug_list {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_list().finish()
} }
} }
@ -412,7 +412,7 @@ mod debug_list {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_list()
.entry(&true) .entry(&true)
.finish() .finish()
@ -432,7 +432,7 @@ mod debug_list {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_list()
.entry(&true) .entry(&true)
.entry(&format_args!("{}/{}", 10, 20)) .entry(&format_args!("{}/{}", 10, 20))
@ -454,7 +454,7 @@ mod debug_list {
struct Foo; struct Foo;
impl fmt::Debug for 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() fmt.debug_list()
.entry(&true) .entry(&true)
.entry(&format_args!("{}/{}", 10, 20)) .entry(&format_args!("{}/{}", 10, 20))
@ -465,7 +465,7 @@ mod debug_list {
struct Bar; struct Bar;
impl fmt::Debug for 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() fmt.debug_list()
.entry(&Foo) .entry(&Foo)
.entry(&"world") .entry(&"world")

View File

@ -567,12 +567,12 @@ fn test_iterator_peekable_fold() {
/// This is an iterator that follows the Iterator contract, /// This is an iterator that follows the Iterator contract,
/// but it is not fused. After having returned None once, it will start /// but it is not fused. After having returned None once, it will start
/// producing elements if .next() is called again. /// producing elements if .next() is called again.
pub struct CycleIter<'a, T: 'a> { pub struct CycleIter<'a, T> {
index: usize, index: usize,
data: &'a [T], data: &'a [T],
} }
pub fn cycle<T>(data: &[T]) -> CycleIter<T> { pub fn cycle<T>(data: &[T]) -> CycleIter<'_, T> {
CycleIter { CycleIter {
index: 0, index: 0,
data, data,

View File

@ -32,8 +32,8 @@
#![feature(slice_partition_dedup)] #![feature(slice_partition_dedup)]
#![feature(copy_within)] #![feature(copy_within)]
#![feature(int_error_matching)] #![feature(int_error_matching)]
#![deny(rust_2018_idioms)]
extern crate core;
extern crate test; extern crate test;
mod any; mod any;