mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Auto merge of #3795 - mikerite:test-rustfmt, r=phansch
Allow rustfmt to run on more tests
This commit is contained in:
commit
36e92a521f
3 changed files with 127 additions and 75 deletions
|
@ -59,7 +59,7 @@ rustup override set nightly
|
|||
# avoid loop spam and allow cmds with exit status != 0
|
||||
set +ex
|
||||
|
||||
for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
|
||||
for file in `find tests -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
|
||||
rustfmt ${file} --check
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${file} needs reformatting!"
|
||||
|
|
|
@ -22,8 +22,8 @@ use std::collections::BTreeMap;
|
|||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::ops::Mul;
|
||||
use std::iter::FromIterator;
|
||||
use std::ops::Mul;
|
||||
use std::rc::{self, Rc};
|
||||
use std::sync::{self, Arc};
|
||||
|
||||
|
@ -32,22 +32,51 @@ use option_helpers::IteratorFalsePositives;
|
|||
pub struct T;
|
||||
|
||||
impl T {
|
||||
pub fn add(self, other: T) -> T { self }
|
||||
pub fn add(self, other: T) -> T {
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn drop(&mut self) { } // no error, not public interfact
|
||||
fn neg(self) -> Self { self } // no error, private function
|
||||
fn eq(&self, other: T) -> bool { true } // no error, private function
|
||||
// no error, not public interface
|
||||
pub(crate) fn drop(&mut self) {}
|
||||
|
||||
fn sub(&self, other: T) -> &T { self } // no error, self is a ref
|
||||
fn div(self) -> T { self } // no error, different #arguments
|
||||
fn rem(self, other: T) { } // no error, wrong return type
|
||||
// no error, private function
|
||||
fn neg(self) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
fn into_u32(self) -> u32 { 0 } // fine
|
||||
fn into_u16(&self) -> u16 { 0 }
|
||||
// no error, private function
|
||||
fn eq(&self, other: T) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn to_something(self) -> u32 { 0 }
|
||||
// no error, self is a ref
|
||||
fn sub(&self, other: T) -> &T {
|
||||
self
|
||||
}
|
||||
|
||||
fn new(self) -> Self { unimplemented!(); }
|
||||
// no error, different #arguments
|
||||
fn div(self) -> T {
|
||||
self
|
||||
}
|
||||
|
||||
fn rem(self, other: T) {} // no error, wrong return type
|
||||
|
||||
// fine
|
||||
fn into_u32(self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
fn into_u16(&self) -> u16 {
|
||||
0
|
||||
}
|
||||
|
||||
fn to_something(self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
fn new(self) -> Self {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
struct Lt<'a> {
|
||||
|
@ -57,7 +86,9 @@ struct Lt<'a> {
|
|||
impl<'a> Lt<'a> {
|
||||
// The lifetime is different, but that’s irrelevant, see #734
|
||||
#[allow(clippy::needless_lifetimes)]
|
||||
pub fn new<'b>(s: &'b str) -> Lt<'b> { unimplemented!() }
|
||||
pub fn new<'b>(s: &'b str) -> Lt<'b> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
struct Lt2<'a> {
|
||||
|
@ -66,7 +97,9 @@ struct Lt2<'a> {
|
|||
|
||||
impl<'a> Lt2<'a> {
|
||||
// The lifetime is different, but that’s irrelevant, see #734
|
||||
pub fn new(s: &str) -> Lt2 { unimplemented!() }
|
||||
pub fn new(s: &str) -> Lt2 {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
struct Lt3<'a> {
|
||||
|
@ -75,34 +108,47 @@ struct Lt3<'a> {
|
|||
|
||||
impl<'a> Lt3<'a> {
|
||||
// The lifetime is different, but that’s irrelevant, see #734
|
||||
pub fn new() -> Lt3<'static> { unimplemented!() }
|
||||
pub fn new() -> Lt3<'static> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone,Copy)]
|
||||
#[derive(Clone, Copy)]
|
||||
struct U;
|
||||
|
||||
impl U {
|
||||
fn new() -> Self { U }
|
||||
fn to_something(self) -> u32 { 0 } // ok because U is Copy
|
||||
fn new() -> Self {
|
||||
U
|
||||
}
|
||||
// ok because U is Copy
|
||||
fn to_something(self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
struct V<T> {
|
||||
_dummy: T
|
||||
_dummy: T,
|
||||
}
|
||||
|
||||
impl<T> V<T> {
|
||||
fn new() -> Option<V<T>> { None }
|
||||
fn new() -> Option<V<T>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<T> for T {
|
||||
type Output = T;
|
||||
fn mul(self, other: T) -> T { self } // no error, obviously
|
||||
// no error, obviously
|
||||
fn mul(self, other: T) -> T {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks implementation of the following lints:
|
||||
/// * `OPTION_MAP_UNWRAP_OR`
|
||||
/// * `OPTION_MAP_UNWRAP_OR_ELSE`
|
||||
/// * `OPTION_MAP_OR_NONE`
|
||||
#[rustfmt::skip]
|
||||
fn option_methods() {
|
||||
let opt = Some(1);
|
||||
|
||||
|
@ -175,6 +221,7 @@ impl HasIter {
|
|||
}
|
||||
|
||||
/// Checks implementation of `FILTER_NEXT` lint
|
||||
#[rustfmt::skip]
|
||||
fn filter_next() {
|
||||
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||
|
||||
|
@ -193,6 +240,7 @@ fn filter_next() {
|
|||
}
|
||||
|
||||
/// Checks implementation of `SEARCH_IS_SOME` lint
|
||||
#[rustfmt::skip]
|
||||
fn search_is_some() {
|
||||
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||
|
||||
|
@ -235,16 +283,18 @@ fn or_fun_call() {
|
|||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn new() -> Foo { Foo }
|
||||
fn new() -> Foo {
|
||||
Foo
|
||||
}
|
||||
}
|
||||
|
||||
enum Enum {
|
||||
A(i32),
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn make<T>() -> T { unimplemented!(); }
|
||||
fn make<T>() -> T {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
let with_enum = Some(Enum::A(1));
|
||||
with_enum.unwrap_or(Enum::A(5));
|
||||
|
@ -261,10 +311,10 @@ fn or_fun_call() {
|
|||
let with_const_args = Some(vec![1]);
|
||||
with_const_args.unwrap_or(Vec::with_capacity(12));
|
||||
|
||||
let with_err : Result<_, ()> = Ok(vec![1]);
|
||||
let with_err: Result<_, ()> = Ok(vec![1]);
|
||||
with_err.unwrap_or(make());
|
||||
|
||||
let with_err_args : Result<_, ()> = Ok(vec![1]);
|
||||
let with_err_args: Result<_, ()> = Ok(vec![1]);
|
||||
with_err_args.unwrap_or(Vec::with_capacity(12));
|
||||
|
||||
let with_default_trait = Some(1);
|
||||
|
|
|
@ -1,33 +1,35 @@
|
|||
error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name
|
||||
--> $DIR/methods.rs:35:5
|
||||
|
|
||||
LL | pub fn add(self, other: T) -> T { self }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | / pub fn add(self, other: T) -> T {
|
||||
LL | | self
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: `-D clippy::should-implement-trait` implied by `-D warnings`
|
||||
|
||||
error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
|
||||
--> $DIR/methods.rs:46:17
|
||||
--> $DIR/methods.rs:69:17
|
||||
|
|
||||
LL | fn into_u16(&self) -> u16 { 0 }
|
||||
LL | fn into_u16(&self) -> u16 {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::wrong-self-convention` implied by `-D warnings`
|
||||
|
||||
error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
|
||||
--> $DIR/methods.rs:48:21
|
||||
--> $DIR/methods.rs:73:21
|
||||
|
|
||||
LL | fn to_something(self) -> u32 { 0 }
|
||||
LL | fn to_something(self) -> u32 {
|
||||
| ^^^^
|
||||
|
||||
error: methods called `new` usually take no self; consider choosing a less ambiguous name
|
||||
--> $DIR/methods.rs:50:12
|
||||
--> $DIR/methods.rs:77:12
|
||||
|
|
||||
LL | fn new(self) -> Self { unimplemented!(); }
|
||||
LL | fn new(self) -> Self {
|
||||
| ^^^^
|
||||
|
||||
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
|
||||
--> $DIR/methods.rs:111:13
|
||||
--> $DIR/methods.rs:157:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -39,7 +41,7 @@ LL | | .unwrap_or(0); // should lint even though this call is on
|
|||
= note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
|
||||
|
||||
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
|
||||
--> $DIR/methods.rs:115:13
|
||||
--> $DIR/methods.rs:161:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| {
|
||||
| _____________^
|
||||
|
@ -49,7 +51,7 @@ LL | | ).unwrap_or(0);
|
|||
| |____________________________^
|
||||
|
||||
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
|
||||
--> $DIR/methods.rs:119:13
|
||||
--> $DIR/methods.rs:165:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -59,7 +61,7 @@ LL | | });
|
|||
| |__________________^
|
||||
|
||||
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
|
||||
--> $DIR/methods.rs:124:13
|
||||
--> $DIR/methods.rs:170:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -67,7 +69,7 @@ LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
|
|||
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
|
||||
|
||||
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
|
||||
--> $DIR/methods.rs:126:13
|
||||
--> $DIR/methods.rs:172:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| {
|
||||
| _____________^
|
||||
|
@ -77,7 +79,7 @@ LL | | ).unwrap_or(None);
|
|||
| |_____________________^
|
||||
|
||||
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
|
||||
--> $DIR/methods.rs:130:13
|
||||
--> $DIR/methods.rs:176:13
|
||||
|
|
||||
LL | let _ = opt
|
||||
| _____________^
|
||||
|
@ -88,7 +90,7 @@ LL | | .unwrap_or(None);
|
|||
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
|
||||
|
||||
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
|
||||
--> $DIR/methods.rs:138:13
|
||||
--> $DIR/methods.rs:184:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -100,7 +102,7 @@ LL | | .unwrap_or_else(|| 0); // should lint even though this cal
|
|||
= note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
|
||||
|
||||
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
|
||||
--> $DIR/methods.rs:142:13
|
||||
--> $DIR/methods.rs:188:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| {
|
||||
| _____________^
|
||||
|
@ -110,7 +112,7 @@ LL | | ).unwrap_or_else(|| 0);
|
|||
| |____________________________________^
|
||||
|
||||
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
|
||||
--> $DIR/methods.rs:146:13
|
||||
--> $DIR/methods.rs:192:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -120,7 +122,7 @@ LL | | );
|
|||
| |_________________^
|
||||
|
||||
error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
|
||||
--> $DIR/methods.rs:155:13
|
||||
--> $DIR/methods.rs:201:13
|
||||
|
|
||||
LL | let _ = opt.map_or(None, |x| Some(x + 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
|
||||
|
@ -128,7 +130,7 @@ LL | let _ = opt.map_or(None, |x| Some(x + 1));
|
|||
= note: `-D clippy::option-map-or-none` implied by `-D warnings`
|
||||
|
||||
error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
|
||||
--> $DIR/methods.rs:157:13
|
||||
--> $DIR/methods.rs:203:13
|
||||
|
|
||||
LL | let _ = opt.map_or(None, |x| {
|
||||
| _____________^
|
||||
|
@ -144,7 +146,7 @@ LL | });
|
|||
|
|
||||
|
||||
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
|
||||
--> $DIR/methods.rs:182:13
|
||||
--> $DIR/methods.rs:229:13
|
||||
|
|
||||
LL | let _ = v.iter().filter(|&x| *x < 0).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -153,7 +155,7 @@ LL | let _ = v.iter().filter(|&x| *x < 0).next();
|
|||
= note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
|
||||
|
||||
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
|
||||
--> $DIR/methods.rs:185:13
|
||||
--> $DIR/methods.rs:232:13
|
||||
|
|
||||
LL | let _ = v.iter().filter(|&x| {
|
||||
| _____________^
|
||||
|
@ -163,7 +165,7 @@ LL | | ).next();
|
|||
| |___________________________^
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
|
||||
--> $DIR/methods.rs:200:13
|
||||
--> $DIR/methods.rs:248:13
|
||||
|
|
||||
LL | let _ = v.iter().find(|&x| *x < 0).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -172,7 +174,7 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some();
|
|||
= note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
|
||||
--> $DIR/methods.rs:203:13
|
||||
--> $DIR/methods.rs:251:13
|
||||
|
|
||||
LL | let _ = v.iter().find(|&x| {
|
||||
| _____________^
|
||||
|
@ -182,7 +184,7 @@ LL | | ).is_some();
|
|||
| |______________________________^
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
|
||||
--> $DIR/methods.rs:209:13
|
||||
--> $DIR/methods.rs:257:13
|
||||
|
|
||||
LL | let _ = v.iter().position(|&x| x < 0).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -190,7 +192,7 @@ LL | let _ = v.iter().position(|&x| x < 0).is_some();
|
|||
= note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
|
||||
--> $DIR/methods.rs:212:13
|
||||
--> $DIR/methods.rs:260:13
|
||||
|
|
||||
LL | let _ = v.iter().position(|&x| {
|
||||
| _____________^
|
||||
|
@ -200,7 +202,7 @@ LL | | ).is_some();
|
|||
| |______________________________^
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
|
||||
--> $DIR/methods.rs:218:13
|
||||
--> $DIR/methods.rs:266:13
|
||||
|
|
||||
LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -208,7 +210,7 @@ LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
|
|||
= note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
|
||||
--> $DIR/methods.rs:221:13
|
||||
--> $DIR/methods.rs:269:13
|
||||
|
|
||||
LL | let _ = v.iter().rposition(|&x| {
|
||||
| _____________^
|
||||
|
@ -218,7 +220,7 @@ LL | | ).is_some();
|
|||
| |______________________________^
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:256:22
|
||||
--> $DIR/methods.rs:306:22
|
||||
|
|
||||
LL | with_constructor.unwrap_or(make());
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
|
||||
|
@ -226,73 +228,73 @@ LL | with_constructor.unwrap_or(make());
|
|||
= note: `-D clippy::or-fun-call` implied by `-D warnings`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `new`
|
||||
--> $DIR/methods.rs:259:5
|
||||
--> $DIR/methods.rs:309:5
|
||||
|
|
||||
LL | with_new.unwrap_or(Vec::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:262:21
|
||||
--> $DIR/methods.rs:312:21
|
||||
|
|
||||
LL | with_const_args.unwrap_or(Vec::with_capacity(12));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:265:14
|
||||
--> $DIR/methods.rs:315:14
|
||||
|
|
||||
LL | with_err.unwrap_or(make());
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:268:19
|
||||
--> $DIR/methods.rs:318:19
|
||||
|
|
||||
LL | with_err_args.unwrap_or(Vec::with_capacity(12));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `default`
|
||||
--> $DIR/methods.rs:271:5
|
||||
--> $DIR/methods.rs:321:5
|
||||
|
|
||||
LL | with_default_trait.unwrap_or(Default::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `default`
|
||||
--> $DIR/methods.rs:274:5
|
||||
--> $DIR/methods.rs:324:5
|
||||
|
|
||||
LL | with_default_type.unwrap_or(u64::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:277:14
|
||||
--> $DIR/methods.rs:327:14
|
||||
|
|
||||
LL | with_vec.unwrap_or(vec![]);
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:282:21
|
||||
--> $DIR/methods.rs:332:21
|
||||
|
|
||||
LL | without_default.unwrap_or(Foo::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
|
||||
|
||||
error: use of `or_insert` followed by a function call
|
||||
--> $DIR/methods.rs:285:19
|
||||
--> $DIR/methods.rs:335:19
|
||||
|
|
||||
LL | map.entry(42).or_insert(String::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
|
||||
|
||||
error: use of `or_insert` followed by a function call
|
||||
--> $DIR/methods.rs:288:21
|
||||
--> $DIR/methods.rs:338:21
|
||||
|
|
||||
LL | btree.entry(42).or_insert(String::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/methods.rs:291:21
|
||||
--> $DIR/methods.rs:341:21
|
||||
|
|
||||
LL | let _ = stringy.unwrap_or("".to_owned());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
|
||||
|
||||
error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
|
||||
--> $DIR/methods.rs:302:23
|
||||
--> $DIR/methods.rs:352:23
|
||||
|
|
||||
LL | let bad_vec = some_vec.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -300,43 +302,43 @@ LL | let bad_vec = some_vec.iter().nth(3);
|
|||
= note: `-D clippy::iter-nth` implied by `-D warnings`
|
||||
|
||||
error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
|
||||
--> $DIR/methods.rs:303:26
|
||||
--> $DIR/methods.rs:353:26
|
||||
|
|
||||
LL | let bad_slice = &some_vec[..].iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
|
||||
--> $DIR/methods.rs:304:31
|
||||
--> $DIR/methods.rs:354:31
|
||||
|
|
||||
LL | let bad_boxed_slice = boxed_slice.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
|
||||
--> $DIR/methods.rs:305:29
|
||||
--> $DIR/methods.rs:355:29
|
||||
|
|
||||
LL | let bad_vec_deque = some_vec_deque.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
|
||||
--> $DIR/methods.rs:310:23
|
||||
--> $DIR/methods.rs:360:23
|
||||
|
|
||||
LL | let bad_vec = some_vec.iter_mut().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
|
||||
--> $DIR/methods.rs:313:26
|
||||
--> $DIR/methods.rs:363:26
|
||||
|
|
||||
LL | let bad_slice = &some_vec[..].iter_mut().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
|
||||
--> $DIR/methods.rs:316:29
|
||||
--> $DIR/methods.rs:366:29
|
||||
|
|
||||
LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message
|
||||
--> $DIR/methods.rs:328:13
|
||||
--> $DIR/methods.rs:378:13
|
||||
|
|
||||
LL | let _ = opt.unwrap();
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
Loading…
Reference in a new issue