Merge remote-tracking branch 'upstream/master' into rustup
This commit is contained in:
commit
415fdb2d1a
522 changed files with 5251 additions and 2556 deletions
|
|
@ -7,11 +7,18 @@ fn foo<T>(x: T) {
|
|||
// Should not lint - purposefully ignoring generic args.
|
||||
let a = Arc::new(x);
|
||||
}
|
||||
fn issue11076<T>() {
|
||||
let a: Arc<Vec<T>> = Arc::new(Vec::new());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// This is safe, as `i32` implements `Send` and `Sync`.
|
||||
let a = Arc::new(42);
|
||||
let _ = Arc::new(42);
|
||||
|
||||
// This is not safe, as `RefCell` does not implement `Sync`.
|
||||
let b = Arc::new(RefCell::new(42));
|
||||
// !Sync
|
||||
let _ = Arc::new(RefCell::new(42));
|
||||
let mutex = Mutex::new(1);
|
||||
// !Send
|
||||
let _ = Arc::new(mutex.lock().unwrap());
|
||||
// !Send + !Sync
|
||||
let _ = Arc::new(&42 as *const i32);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,34 @@
|
|||
error: usage of `Arc<T>` where `T` is not `Send` or `Sync`
|
||||
--> $DIR/arc_with_non_send_sync.rs:16:13
|
||||
error: usage of an `Arc` that is not `Send` or `Sync`
|
||||
--> $DIR/arc_with_non_send_sync.rs:18:13
|
||||
|
|
||||
LL | let b = Arc::new(RefCell::new(42));
|
||||
LL | let _ = Arc::new(RefCell::new(42));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider using `Rc<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
|
||||
= note: the trait `Sync` is not implemented for `RefCell<i32>`
|
||||
= note: required for `Arc<RefCell<i32>>` to implement `Send` and `Sync`
|
||||
= help: consider using an `Rc` instead or wrapping the inner type with a `Mutex`
|
||||
= note: `-D clippy::arc-with-non-send-sync` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: usage of an `Arc` that is not `Send` or `Sync`
|
||||
--> $DIR/arc_with_non_send_sync.rs:21:13
|
||||
|
|
||||
LL | let _ = Arc::new(mutex.lock().unwrap());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the trait `Send` is not implemented for `MutexGuard<'_, i32>`
|
||||
= note: required for `Arc<MutexGuard<'_, i32>>` to implement `Send` and `Sync`
|
||||
= help: consider using an `Rc` instead or wrapping the inner type with a `Mutex`
|
||||
|
||||
error: usage of an `Arc` that is not `Send` or `Sync`
|
||||
--> $DIR/arc_with_non_send_sync.rs:23:13
|
||||
|
|
||||
LL | let _ = Arc::new(&42 as *const i32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the trait `Send` is not implemented for `*const i32`
|
||||
= note: the trait `Sync` is not implemented for `*const i32`
|
||||
= note: required for `Arc<*const i32>` to implement `Send` and `Sync`
|
||||
= help: consider using an `Rc` instead or wrapping the inner type with a `Mutex`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -481,4 +481,9 @@ pub fn issue_10792() {
|
|||
let _ = 10 / TWO.c;
|
||||
}
|
||||
|
||||
pub fn issue_11145() {
|
||||
let mut x: Wrapping<u32> = Wrapping(0_u32);
|
||||
x += 1;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![allow(clippy::borrow_as_ptr, unused)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::external;
|
||||
use proc_macros::with_span;
|
||||
use proc_macros::{external, with_span};
|
||||
|
||||
fn main() {
|
||||
let i = 0u32 as u64;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: using a potentially dangerous silent `as` conversion
|
||||
--> $DIR/as_conversions.rs:11:13
|
||||
--> $DIR/as_conversions.rs:10:13
|
||||
|
|
||||
LL | let i = 0u32 as u64;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | let i = 0u32 as u64;
|
|||
= note: `-D clippy::as-conversions` implied by `-D warnings`
|
||||
|
||||
error: using a potentially dangerous silent `as` conversion
|
||||
--> $DIR/as_conversions.rs:13:13
|
||||
--> $DIR/as_conversions.rs:12:13
|
||||
|
|
||||
LL | let j = &i as *const u64 as *mut u64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -16,7 +16,7 @@ LL | let j = &i as *const u64 as *mut u64;
|
|||
= help: consider using a safe wrapper for this conversion
|
||||
|
||||
error: using a potentially dangerous silent `as` conversion
|
||||
--> $DIR/as_conversions.rs:13:13
|
||||
--> $DIR/as_conversions.rs:12:13
|
||||
|
|
||||
LL | let j = &i as *const u64 as *mut u64;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ pub mod inner {
|
|||
|
||||
// RE-EXPORT
|
||||
// this will stick in `inner` module
|
||||
pub use macro_rules::mut_mut;
|
||||
pub use macro_rules::try_err;
|
||||
pub use macro_rules::{mut_mut, try_err};
|
||||
|
||||
pub mod nested {
|
||||
pub use macro_rules::string_add;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ extern crate syn;
|
|||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::{quote, quote_spanned};
|
||||
use syn::parse_macro_input;
|
||||
use syn::spanned::Spanned;
|
||||
use syn::token::Star;
|
||||
use syn::{
|
||||
parse_quote, FnArg, ImplItem, ItemImpl, ItemTrait, Lifetime, Pat, PatIdent, PatType, Signature, TraitItem, Type,
|
||||
parse_macro_input, parse_quote, FnArg, ImplItem, ItemImpl, ItemTrait, Lifetime, Pat, PatIdent, PatType, Signature,
|
||||
TraitItem, Type,
|
||||
};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
|
|
|
|||
|
|
@ -5,13 +5,10 @@
|
|||
extern crate proc_macro;
|
||||
|
||||
use core::mem;
|
||||
use proc_macro::{
|
||||
token_stream::IntoIter,
|
||||
Delimiter::{self, Brace, Parenthesis},
|
||||
Group, Ident, Literal, Punct,
|
||||
Spacing::{self, Alone, Joint},
|
||||
Span, TokenStream, TokenTree as TT,
|
||||
};
|
||||
use proc_macro::token_stream::IntoIter;
|
||||
use proc_macro::Delimiter::{self, Brace, Parenthesis};
|
||||
use proc_macro::Spacing::{self, Alone, Joint};
|
||||
use proc_macro::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree as TT};
|
||||
|
||||
type Result<T> = core::result::Result<T, TokenStream>;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed
|
|||
--> $DIR/bind_instead_of_map.rs:10:13
|
||||
|
|
||||
LL | let _ = x.and_then(|o| Some(o + 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.map(|o| o + 1)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)`
|
||||
|
||||
error: using `Result.and_then(Ok)`, which is a no-op
|
||||
--> $DIR/bind_instead_of_map.rs:16:13
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ note: the lint level is defined here
|
|||
|
|
||||
LL | #![deny(clippy::bind_instead_of_map)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL | let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
||||
| ~~~ ~ ~~~~~~~
|
||||
|
|
@ -20,7 +20,7 @@ error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as
|
|||
LL | let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL | let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
||||
| ~~~ ~ ~~~~~~~
|
||||
|
|
@ -31,7 +31,7 @@ error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as
|
|||
LL | let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL | let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 } else { s.len() });
|
||||
| ~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~
|
||||
|
|
@ -48,7 +48,7 @@ LL | | }
|
|||
LL | | });
|
||||
| |______^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ Some("42").map(|s| {
|
||||
LL | if {
|
||||
|
|
@ -82,7 +82,7 @@ error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed
|
|||
LL | let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL | let _ = Some("").map(|s| if s.len() == 20 { m!() } else { Some(20) });
|
||||
| ~~~ ~~~~ ~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#![allow(clippy::needless_if)]
|
||||
#![warn(clippy::bool_comparison)]
|
||||
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
|
||||
|
||||
fn main() {
|
||||
let x = true;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#![allow(clippy::needless_if)]
|
||||
#![warn(clippy::bool_comparison)]
|
||||
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
|
||||
|
||||
fn main() {
|
||||
let x = true;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: equality checks against true are unnecessary
|
||||
--> $DIR/bool_comparison.rs:8:8
|
||||
--> $DIR/bool_comparison.rs:9:8
|
||||
|
|
||||
LL | if x == true {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
|
@ -7,127 +7,127 @@ LL | if x == true {
|
|||
= note: `-D clippy::bool-comparison` implied by `-D warnings`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:13:8
|
||||
--> $DIR/bool_comparison.rs:14:8
|
||||
|
|
||||
LL | if x == false {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> $DIR/bool_comparison.rs:18:8
|
||||
--> $DIR/bool_comparison.rs:19:8
|
||||
|
|
||||
LL | if true == x {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:23:8
|
||||
--> $DIR/bool_comparison.rs:24:8
|
||||
|
|
||||
LL | if false == x {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: inequality checks against true can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:28:8
|
||||
--> $DIR/bool_comparison.rs:29:8
|
||||
|
|
||||
LL | if x != true {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: inequality checks against false are unnecessary
|
||||
--> $DIR/bool_comparison.rs:33:8
|
||||
--> $DIR/bool_comparison.rs:34:8
|
||||
|
|
||||
LL | if x != false {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: inequality checks against true can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:38:8
|
||||
--> $DIR/bool_comparison.rs:39:8
|
||||
|
|
||||
LL | if true != x {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: inequality checks against false are unnecessary
|
||||
--> $DIR/bool_comparison.rs:43:8
|
||||
--> $DIR/bool_comparison.rs:44:8
|
||||
|
|
||||
LL | if false != x {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: less than comparison against true can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:48:8
|
||||
--> $DIR/bool_comparison.rs:49:8
|
||||
|
|
||||
LL | if x < true {
|
||||
| ^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: greater than checks against false are unnecessary
|
||||
--> $DIR/bool_comparison.rs:53:8
|
||||
--> $DIR/bool_comparison.rs:54:8
|
||||
|
|
||||
LL | if false < x {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: greater than checks against false are unnecessary
|
||||
--> $DIR/bool_comparison.rs:58:8
|
||||
--> $DIR/bool_comparison.rs:59:8
|
||||
|
|
||||
LL | if x > false {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: less than comparison against true can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:63:8
|
||||
--> $DIR/bool_comparison.rs:64:8
|
||||
|
|
||||
LL | if true > x {
|
||||
| ^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: order comparisons between booleans can be simplified
|
||||
--> $DIR/bool_comparison.rs:69:8
|
||||
--> $DIR/bool_comparison.rs:70:8
|
||||
|
|
||||
LL | if x < y {
|
||||
| ^^^^^ help: try simplifying it as shown: `!x & y`
|
||||
|
||||
error: order comparisons between booleans can be simplified
|
||||
--> $DIR/bool_comparison.rs:74:8
|
||||
--> $DIR/bool_comparison.rs:75:8
|
||||
|
|
||||
LL | if x > y {
|
||||
| ^^^^^ help: try simplifying it as shown: `x & !y`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> $DIR/bool_comparison.rs:122:8
|
||||
--> $DIR/bool_comparison.rs:123:8
|
||||
|
|
||||
LL | if a == !b {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `a != b`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> $DIR/bool_comparison.rs:123:8
|
||||
--> $DIR/bool_comparison.rs:124:8
|
||||
|
|
||||
LL | if !a == b {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `a != b`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> $DIR/bool_comparison.rs:127:8
|
||||
--> $DIR/bool_comparison.rs:128:8
|
||||
|
|
||||
LL | if b == !a {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `b != a`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> $DIR/bool_comparison.rs:128:8
|
||||
--> $DIR/bool_comparison.rs:129:8
|
||||
|
|
||||
LL | if !b == a {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `b != a`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:152:8
|
||||
--> $DIR/bool_comparison.rs:153:8
|
||||
|
|
||||
LL | if false == m!(func) {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> $DIR/bool_comparison.rs:153:8
|
||||
--> $DIR/bool_comparison.rs:154:8
|
||||
|
|
||||
LL | if m!(func) == false {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> $DIR/bool_comparison.rs:154:8
|
||||
--> $DIR/bool_comparison.rs:155:8
|
||||
|
|
||||
LL | if true == m!(func) {}
|
||||
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> $DIR/bool_comparison.rs:155:8
|
||||
--> $DIR/bool_comparison.rs:156:8
|
||||
|
|
||||
LL | if m!(func) == true {}
|
||||
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
#![deny(clippy::borrowed_box)]
|
||||
#![allow(dead_code, unused_variables)]
|
||||
#![allow(clippy::uninlined_format_args, clippy::disallowed_names)]
|
||||
#![allow(
|
||||
clippy::uninlined_format_args,
|
||||
clippy::disallowed_names,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:20:14
|
||||
--> $DIR/borrow_box.rs:24:14
|
||||
|
|
||||
LL | let foo: &Box<bool>;
|
||||
| ^^^^^^^^^^ help: try: `&bool`
|
||||
|
|
@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:24:10
|
||||
--> $DIR/borrow_box.rs:28:10
|
||||
|
|
||||
LL | foo: &'a Box<bool>,
|
||||
| ^^^^^^^^^^^^^ help: try: `&'a bool`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:28:17
|
||||
--> $DIR/borrow_box.rs:32:17
|
||||
|
|
||||
LL | fn test4(a: &Box<bool>);
|
||||
| ^^^^^^^^^^ help: try: `&bool`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:94:25
|
||||
--> $DIR/borrow_box.rs:98:25
|
||||
|
|
||||
LL | pub fn test14(_display: &Box<dyn Display>) {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:95:25
|
||||
--> $DIR/borrow_box.rs:99:25
|
||||
|
|
||||
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:96:29
|
||||
--> $DIR/borrow_box.rs:100:29
|
||||
|
|
||||
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:98:25
|
||||
--> $DIR/borrow_box.rs:102:25
|
||||
|
|
||||
LL | pub fn test17(_display: &Box<impl Display>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:99:25
|
||||
--> $DIR/borrow_box.rs:103:25
|
||||
|
|
||||
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:100:29
|
||||
--> $DIR/borrow_box.rs:104:29
|
||||
|
|
||||
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:105:25
|
||||
--> $DIR/borrow_box.rs:109:25
|
||||
|
|
||||
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: redundant pattern matching, consider using `is_ok()`
|
|||
--> $DIR/ice-7169.rs:10:12
|
||||
|
|
||||
LL | if let Ok(_) = Ok::<_, ()>(A::<String>::default()) {}
|
||||
| -------^^^^^-------------------------------------- help: try this: `if Ok::<_, ()>(A::<String>::default()).is_ok()`
|
||||
| -------^^^^^-------------------------------------- help: try: `if Ok::<_, ()>(A::<String>::default()).is_ok()`
|
||||
|
|
||||
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: unnecessary use of `splitn`
|
|||
--> $DIR/ice-8250.rs:2:13
|
||||
|
|
||||
LL | let _ = s[1..].splitn(2, '.').next()?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s[1..].split('.')`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `s[1..].split('.')`
|
||||
|
|
||||
= note: `-D clippy::needless-splitn` implied by `-D warnings`
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@
|
|||
extern crate proc_macros;
|
||||
|
||||
use proc_macros::with_span;
|
||||
use std::default;
|
||||
use std::default::Default as D2;
|
||||
use std::string;
|
||||
use std::{default, string};
|
||||
|
||||
fn main() {
|
||||
let s1: String = String::default();
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@
|
|||
extern crate proc_macros;
|
||||
|
||||
use proc_macros::with_span;
|
||||
use std::default;
|
||||
use std::default::Default as D2;
|
||||
use std::string;
|
||||
use std::{default, string};
|
||||
|
||||
fn main() {
|
||||
let s1: String = Default::default();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: calling `String::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:15:22
|
||||
--> $DIR/default_trait_access.rs:14:22
|
||||
|
|
||||
LL | let s1: String = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `String::default()`
|
||||
|
|
@ -11,43 +11,43 @@ LL | #![deny(clippy::default_trait_access)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: calling `String::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:19:22
|
||||
--> $DIR/default_trait_access.rs:18:22
|
||||
|
|
||||
LL | let s3: String = D2::default();
|
||||
| ^^^^^^^^^^^^^ help: try: `String::default()`
|
||||
|
||||
error: calling `String::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:21:22
|
||||
--> $DIR/default_trait_access.rs:20:22
|
||||
|
|
||||
LL | let s4: String = std::default::Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()`
|
||||
|
||||
error: calling `String::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:25:22
|
||||
--> $DIR/default_trait_access.rs:24:22
|
||||
|
|
||||
LL | let s6: String = default::Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()`
|
||||
|
||||
error: calling `GenericDerivedDefault::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:35:46
|
||||
--> $DIR/default_trait_access.rs:34:46
|
||||
|
|
||||
LL | let s11: GenericDerivedDefault<String> = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()`
|
||||
|
||||
error: calling `TupleDerivedDefault::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:41:36
|
||||
--> $DIR/default_trait_access.rs:40:36
|
||||
|
|
||||
LL | let s14: TupleDerivedDefault = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()`
|
||||
|
||||
error: calling `ArrayDerivedDefault::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:43:36
|
||||
--> $DIR/default_trait_access.rs:42:36
|
||||
|
|
||||
LL | let s15: ArrayDerivedDefault = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()`
|
||||
|
||||
error: calling `TupleStructDerivedDefault::default()` is more clear than this expression
|
||||
--> $DIR/default_trait_access.rs:47:42
|
||||
--> $DIR/default_trait_access.rs:46:42
|
||||
|
|
||||
LL | let s17: TupleStructDerivedDefault = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: immediately dereferencing a reference
|
|||
--> $DIR/deref_addrof.rs:24:13
|
||||
|
|
||||
LL | let b = *&a;
|
||||
| ^^^ help: try this: `a`
|
||||
| ^^^ help: try: `a`
|
||||
|
|
||||
= note: `-D clippy::deref-addrof` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,49 +10,49 @@ error: immediately dereferencing a reference
|
|||
--> $DIR/deref_addrof.rs:26:13
|
||||
|
|
||||
LL | let b = *&get_number();
|
||||
| ^^^^^^^^^^^^^^ help: try this: `get_number()`
|
||||
| ^^^^^^^^^^^^^^ help: try: `get_number()`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:31:13
|
||||
|
|
||||
LL | let b = *&bytes[1..2][0];
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]`
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `bytes[1..2][0]`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:35:13
|
||||
|
|
||||
LL | let b = *&(a);
|
||||
| ^^^^^ help: try this: `(a)`
|
||||
| ^^^^^ help: try: `(a)`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:37:13
|
||||
|
|
||||
LL | let b = *(&a);
|
||||
| ^^^^^ help: try this: `a`
|
||||
| ^^^^^ help: try: `a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:40:13
|
||||
|
|
||||
LL | let b = *((&a));
|
||||
| ^^^^^^^ help: try this: `a`
|
||||
| ^^^^^^^ help: try: `a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:42:13
|
||||
|
|
||||
LL | let b = *&&a;
|
||||
| ^^^^ help: try this: `&a`
|
||||
| ^^^^ help: try: `&a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:44:14
|
||||
|
|
||||
LL | let b = **&aref;
|
||||
| ^^^^^^ help: try this: `aref`
|
||||
| ^^^^^^ help: try: `aref`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof.rs:54:17
|
||||
|
|
||||
LL | inline!(*& $(@expr self))
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `$(@expr self)`
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `$(@expr self)`
|
||||
|
|
||||
= note: this error originates in the macro `__inline_mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ error: immediately dereferencing a reference
|
|||
--> $DIR/deref_addrof.rs:58:17
|
||||
|
|
||||
LL | inline!(*&mut $(@expr self))
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try this: `$(@expr self)`
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try: `$(@expr self)`
|
||||
|
|
||||
= note: this error originates in the macro `__inline_mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: immediately dereferencing a reference
|
|||
--> $DIR/deref_addrof_double_trigger.rs:10:14
|
||||
|
|
||||
LL | let b = **&&a;
|
||||
| ^^^^ help: try this: `&a`
|
||||
| ^^^^ help: try: `&a`
|
||||
|
|
||||
= note: `-D clippy::deref-addrof` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,13 +10,13 @@ error: immediately dereferencing a reference
|
|||
--> $DIR/deref_addrof_double_trigger.rs:14:17
|
||||
|
|
||||
LL | let y = *&mut x;
|
||||
| ^^^^^^^ help: try this: `x`
|
||||
| ^^^^^^^ help: try: `x`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/deref_addrof_double_trigger.rs:21:18
|
||||
|
|
||||
LL | let y = **&mut &mut x;
|
||||
| ^^^^^^^^^^^^ help: try this: `&mut x`
|
||||
| ^^^^^^^^^^^^ help: try: `&mut x`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
#![allow(clippy::incorrect_clone_impl_on_copy_type, dead_code)]
|
||||
#![allow(
|
||||
clippy::incorrect_clone_impl_on_copy_type,
|
||||
clippy::incorrect_partial_ord_impl_on_ord_type,
|
||||
dead_code
|
||||
)]
|
||||
#![warn(clippy::expl_impl_clone_on_copy)]
|
||||
|
||||
|
||||
#[derive(Copy)]
|
||||
struct Qux;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> $DIR/derive.rs:8:1
|
||||
--> $DIR/derive.rs:11:1
|
||||
|
|
||||
LL | / impl Clone for Qux {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -9,7 +9,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> $DIR/derive.rs:8:1
|
||||
--> $DIR/derive.rs:11:1
|
||||
|
|
||||
LL | / impl Clone for Qux {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -20,7 +20,7 @@ LL | | }
|
|||
= note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings`
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> $DIR/derive.rs:32:1
|
||||
--> $DIR/derive.rs:35:1
|
||||
|
|
||||
LL | / impl<'a> Clone for Lt<'a> {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -30,7 +30,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> $DIR/derive.rs:32:1
|
||||
--> $DIR/derive.rs:35:1
|
||||
|
|
||||
LL | / impl<'a> Clone for Lt<'a> {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -40,7 +40,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> $DIR/derive.rs:43:1
|
||||
--> $DIR/derive.rs:46:1
|
||||
|
|
||||
LL | / impl Clone for BigArray {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -50,7 +50,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> $DIR/derive.rs:43:1
|
||||
--> $DIR/derive.rs:46:1
|
||||
|
|
||||
LL | / impl Clone for BigArray {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -60,7 +60,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> $DIR/derive.rs:54:1
|
||||
--> $DIR/derive.rs:57:1
|
||||
|
|
||||
LL | / impl Clone for FnPtr {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -70,7 +70,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> $DIR/derive.rs:54:1
|
||||
--> $DIR/derive.rs:57:1
|
||||
|
|
||||
LL | / impl Clone for FnPtr {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -80,7 +80,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> $DIR/derive.rs:74:1
|
||||
--> $DIR/derive.rs:77:1
|
||||
|
|
||||
LL | / impl<T: Clone> Clone for Generic2<T> {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
@ -90,7 +90,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> $DIR/derive.rs:74:1
|
||||
--> $DIR/derive.rs:77:1
|
||||
|
|
||||
LL | / impl<T: Clone> Clone for Generic2<T> {
|
||||
LL | | fn clone(&self) -> Self {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#![warn(clippy::derive_ord_xor_partial_ord)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:21:10
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:22:10
|
||||
|
|
||||
LL | #[derive(Ord, PartialEq, Eq)]
|
||||
| ^^^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:24:1
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:25:1
|
||||
|
|
||||
LL | impl PartialOrd for DeriveOrd {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -13,20 +13,20 @@ LL | impl PartialOrd for DeriveOrd {
|
|||
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:30:10
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:31:10
|
||||
|
|
||||
LL | #[derive(Ord, PartialEq, Eq)]
|
||||
| ^^^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:33:1
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:34:1
|
||||
|
|
||||
LL | impl PartialOrd<DeriveOrdWithExplicitTypeVariable> for DeriveOrdWithExplicitTypeVariable {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: you are implementing `Ord` explicitly but have derived `PartialOrd`
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:42:1
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:43:1
|
||||
|
|
||||
LL | / impl std::cmp::Ord for DerivePartialOrd {
|
||||
LL | | fn cmp(&self, other: &Self) -> Ordering {
|
||||
|
|
@ -36,14 +36,14 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:39:10
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:40:10
|
||||
|
|
||||
LL | #[derive(PartialOrd, PartialEq, Eq)]
|
||||
| ^^^^^^^^^^
|
||||
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: you are implementing `Ord` explicitly but have derived `PartialOrd`
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:62:5
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:63:5
|
||||
|
|
||||
LL | / impl Ord for DerivePartialOrdInUseOrd {
|
||||
LL | | fn cmp(&self, other: &Self) -> Ordering {
|
||||
|
|
@ -53,7 +53,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:59:14
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:60:14
|
||||
|
|
||||
LL | #[derive(PartialOrd, PartialEq, Eq)]
|
||||
| ^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
//@aux-build:proc_macro_attr.rs:proc-macro
|
||||
// Flaky test, see https://github.com/rust-lang/rust/issues/113585.
|
||||
//@ignore-32bit
|
||||
//@ignore-64bit
|
||||
#![warn(clippy::empty_line_after_doc_comments)]
|
||||
#![allow(clippy::assertions_on_constants)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
//@aux-build:proc_macro_attr.rs:proc-macro
|
||||
// Flaky test, see https://github.com/rust-lang/rust/issues/113585.
|
||||
//@ignore-32bit
|
||||
//@ignore-64bit
|
||||
#![warn(clippy::empty_line_after_outer_attr)]
|
||||
#![allow(clippy::assertions_on_constants)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|||
LL | / if !m.contains_key(&k) {
|
||||
LL | | m.insert(k, v);
|
||||
LL | | }
|
||||
| |_____^ help: try this: `m.entry(k).or_insert(v);`
|
||||
| |_____^ help: try: `m.entry(k).or_insert(v);`
|
||||
|
|
||||
= note: `-D clippy::map-entry` implied by `-D warnings`
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ LL | | }
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ m.entry(k).or_insert_with(|| {
|
||||
LL + if true {
|
||||
|
|
@ -43,7 +43,7 @@ LL | | };
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ m.entry(k).or_insert_with(|| {
|
||||
LL + if true {
|
||||
|
|
@ -66,7 +66,7 @@ LL | | }
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
||||
LL + if true {
|
||||
|
|
@ -87,7 +87,7 @@ LL | | m.insert(k, v);
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ m.entry(k).or_insert_with(|| {
|
||||
LL + foo();
|
||||
|
|
@ -107,7 +107,7 @@ LL | | };
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ m.entry(k).or_insert_with(|| {
|
||||
LL + match 0 {
|
||||
|
|
@ -133,7 +133,7 @@ LL | | };
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
||||
LL + match 0 {
|
||||
|
|
@ -157,7 +157,7 @@ LL | | }
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ m.entry(k).or_insert_with(|| {
|
||||
LL + foo();
|
||||
|
|
@ -192,7 +192,7 @@ error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|||
LL | / if !m.contains_key(&m!(k)) {
|
||||
LL | | m.insert(m!(k), m!(v));
|
||||
LL | | }
|
||||
| |_____^ help: try this: `m.entry(m!(k)).or_insert_with(|| m!(v));`
|
||||
| |_____^ help: try: `m.entry(m!(k)).or_insert_with(|| m!(v));`
|
||||
|
||||
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
--> $DIR/entry.rs:152:5
|
||||
|
|
@ -204,7 +204,7 @@ LL | | m.insert(k, v);
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ m.entry(k).or_insert_with(|| {
|
||||
LL + let x = (String::new(), String::new());
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
|
||||
= note: `-D clippy::map-entry` implied by `-D warnings`
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
|
||||
LL + e.insert(v);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
|
||||
= note: `-D clippy::map-entry` implied by `-D warnings`
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ match m.entry(k) {
|
||||
LL + std::collections::hash_map::Entry::Vacant(e) => {
|
||||
|
|
@ -31,7 +31,7 @@ LL | | m.insert(k, v2);
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ match m.entry(k) {
|
||||
LL + std::collections::hash_map::Entry::Occupied(mut e) => {
|
||||
|
|
@ -53,7 +53,7 @@ LL | | foo();
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
||||
LL + e.insert(v);
|
||||
|
|
@ -72,7 +72,7 @@ LL | | m.insert(k, v);
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) {
|
||||
LL + e.insert(v);
|
||||
|
|
@ -91,7 +91,7 @@ LL | | m.insert(k, v2);
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ match m.entry(k) {
|
||||
LL + std::collections::hash_map::Entry::Vacant(e) => {
|
||||
|
|
@ -113,7 +113,7 @@ LL | | m.insert(k, v)
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ match m.entry(k) {
|
||||
LL + std::collections::hash_map::Entry::Occupied(mut e) => {
|
||||
|
|
@ -137,7 +137,7 @@ LL | | None
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) {
|
||||
LL + foo();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: use of `expect` followed by a function call
|
|||
--> $DIR/expect_fun_call.rs:38:26
|
||||
|
|
||||
LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
|
||||
|
|
||||
= note: `-D clippy::expect-fun-call` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,85 +10,85 @@ error: use of `expect` followed by a function call
|
|||
--> $DIR/expect_fun_call.rs:41:26
|
||||
|
|
||||
LL | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:44:37
|
||||
|
|
||||
LL | with_none_and_format_with_macro.expect(format!("Error {}: fake error", one!()).as_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", one!()))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", one!()))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:54:25
|
||||
|
|
||||
LL | with_err_and_format.expect(&format!("Error {}: fake error", error_code));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:57:25
|
||||
|
|
||||
LL | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:69:17
|
||||
|
|
||||
LL | Some("foo").expect(format!("{} {}", 1, 2).as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{} {}", 1, 2))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{} {}", 1, 2))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:90:21
|
||||
|
|
||||
LL | Some("foo").expect(&get_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:91:21
|
||||
|
|
||||
LL | Some("foo").expect(get_string().as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:92:21
|
||||
|
|
||||
LL | Some("foo").expect(get_string().as_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:94:21
|
||||
|
|
||||
LL | Some("foo").expect(get_static_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_static_str()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_static_str()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:95:21
|
||||
|
|
||||
LL | Some("foo").expect(get_non_static_str(&0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:99:16
|
||||
|
|
||||
LL | Some(true).expect(&format!("key {}, {}", 1, 2));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:105:17
|
||||
|
|
||||
LL | opt_ref.expect(&format!("{:?}", opt_ref));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{:?}", opt_ref))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{:?}", opt_ref))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:109:20
|
||||
|
|
||||
LL | format_capture.expect(&format!("{error_code}"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{error_code}"))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{error_code}"))`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:112:30
|
||||
|
|
||||
LL | format_capture_and_value.expect(&format!("{error_code}, {}", 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{error_code}, {}", 1))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{error_code}, {}", 1))`
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ mod rustc_ok {
|
|||
|
||||
#[expect(illegal_floating_point_literal_pattern)]
|
||||
match x {
|
||||
5.0 => {}
|
||||
6.0 => {}
|
||||
_ => {}
|
||||
5.0 => {},
|
||||
6.0 => {},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,9 +38,9 @@ mod rustc_warn {
|
|||
|
||||
#[expect(illegal_floating_point_literal_pattern)]
|
||||
match x {
|
||||
5 => {}
|
||||
6 => {}
|
||||
_ => {}
|
||||
5 => {},
|
||||
6 => {},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: deref which would be done by auto-deref
|
|||
--> $DIR/explicit_auto_deref.rs:70:19
|
||||
|
|
||||
LL | let _: &str = &*s;
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
|
||||
= note: `-D clippy::explicit-auto-deref` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,229 +10,229 @@ error: deref which would be done by auto-deref
|
|||
--> $DIR/explicit_auto_deref.rs:71:19
|
||||
|
|
||||
LL | let _: &str = &*{ String::new() };
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try this: `&{ String::new() }`
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try: `&{ String::new() }`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:72:19
|
||||
|
|
||||
LL | let _: &str = &mut *{ String::new() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut { String::new() }`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut { String::new() }`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:76:11
|
||||
|
|
||||
LL | f_str(&*s);
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:80:13
|
||||
|
|
||||
LL | f_str_t(&*s, &*s); // Don't lint second param.
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:83:24
|
||||
|
|
||||
LL | let _: &Box<i32> = &**b;
|
||||
| ^^^^ help: try this: `&b`
|
||||
| ^^^^ help: try: `&b`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:89:7
|
||||
|
|
||||
LL | c(&*s);
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:95:9
|
||||
|
|
||||
LL | &**x
|
||||
| ^^^^ help: try this: `x`
|
||||
| ^^^^ help: try: `x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:99:11
|
||||
|
|
||||
LL | { &**x }
|
||||
| ^^^^ help: try this: `x`
|
||||
| ^^^^ help: try: `x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:103:9
|
||||
|
|
||||
LL | &**{ x }
|
||||
| ^^^^^^^^ help: try this: `{ x }`
|
||||
| ^^^^^^^^ help: try: `{ x }`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:107:9
|
||||
|
|
||||
LL | &***x
|
||||
| ^^^^^ help: try this: `x`
|
||||
| ^^^^^ help: try: `x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:124:12
|
||||
|
|
||||
LL | f1(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:125:12
|
||||
|
|
||||
LL | f2(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:126:12
|
||||
|
|
||||
LL | f3(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:127:27
|
||||
|
|
||||
LL | f4.callable_str()(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:128:12
|
||||
|
|
||||
LL | f5(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:129:12
|
||||
|
|
||||
LL | f6(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:130:27
|
||||
|
|
||||
LL | f7.callable_str()(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:131:25
|
||||
|
|
||||
LL | f8.callable_t()(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:132:12
|
||||
|
|
||||
LL | f9(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:133:13
|
||||
|
|
||||
LL | f10(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:134:26
|
||||
|
|
||||
LL | f11.callable_t()(&*x);
|
||||
| ^^^ help: try this: `&x`
|
||||
| ^^^ help: try: `&x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:138:16
|
||||
|
|
||||
LL | let _ = S1(&*s);
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:143:21
|
||||
|
|
||||
LL | let _ = S2 { s: &*s };
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:159:30
|
||||
|
|
||||
LL | let _ = Self::S1(&**s);
|
||||
| ^^^^ help: try this: `s`
|
||||
| ^^^^ help: try: `s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:160:35
|
||||
|
|
||||
LL | let _ = Self::S2 { s: &**s };
|
||||
| ^^^^ help: try this: `s`
|
||||
| ^^^^ help: try: `s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:163:20
|
||||
|
|
||||
LL | let _ = E1::S1(&*s);
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:164:25
|
||||
|
|
||||
LL | let _ = E1::S2 { s: &*s };
|
||||
| ^^^ help: try this: `&s`
|
||||
| ^^^ help: try: `&s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:182:13
|
||||
|
|
||||
LL | let _ = (*b).foo;
|
||||
| ^^^^ help: try this: `b`
|
||||
| ^^^^ help: try: `b`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:183:13
|
||||
|
|
||||
LL | let _ = (**b).foo;
|
||||
| ^^^^^ help: try this: `b`
|
||||
| ^^^^^ help: try: `b`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:198:19
|
||||
|
|
||||
LL | let _ = f_str(*ref_str);
|
||||
| ^^^^^^^^ help: try this: `ref_str`
|
||||
| ^^^^^^^^ help: try: `ref_str`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:200:19
|
||||
|
|
||||
LL | let _ = f_str(**ref_ref_str);
|
||||
| ^^^^^^^^^^^^^ help: try this: `ref_ref_str`
|
||||
| ^^^^^^^^^^^^^ help: try: `ref_ref_str`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:210:13
|
||||
|
|
||||
LL | f_str(&&*ref_str); // `needless_borrow` will suggest removing both references
|
||||
| ^^^^^^^^ help: try this: `ref_str`
|
||||
| ^^^^^^^^ help: try: `ref_str`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:211:12
|
||||
|
|
||||
LL | f_str(&&**ref_str); // `needless_borrow` will suggest removing only one reference
|
||||
| ^^^^^^^^^^ help: try this: `ref_str`
|
||||
| ^^^^^^^^^^ help: try: `ref_str`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:220:41
|
||||
|
|
||||
LL | let _ = || -> &'static str { return *s };
|
||||
| ^^ help: try this: `s`
|
||||
| ^^ help: try: `s`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:239:9
|
||||
|
|
||||
LL | &**x
|
||||
| ^^^^ help: try this: `x`
|
||||
| ^^^^ help: try: `x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:262:8
|
||||
|
|
||||
LL | c1(*x);
|
||||
| ^^ help: try this: `x`
|
||||
| ^^ help: try: `x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:265:20
|
||||
|
|
||||
LL | return *x;
|
||||
| ^^ help: try this: `x`
|
||||
| ^^ help: try: `x`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:267:9
|
||||
|
|
||||
LL | *x
|
||||
| ^^ help: try this: `x`
|
||||
| ^^ help: try: `x`
|
||||
|
||||
error: aborting due to 39 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: explicit `deref` method call
|
|||
--> $DIR/explicit_deref_methods.rs:54:19
|
||||
|
|
||||
LL | let b: &str = a.deref();
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
|
||||
= note: `-D clippy::explicit-deref-methods` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,67 +10,67 @@ error: explicit `deref_mut` method call
|
|||
--> $DIR/explicit_deref_methods.rs:56:23
|
||||
|
|
||||
LL | let b: &mut str = a.deref_mut();
|
||||
| ^^^^^^^^^^^^^ help: try this: `&mut **a`
|
||||
| ^^^^^^^^^^^^^ help: try: `&mut **a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:59:39
|
||||
|
|
||||
LL | let b: String = format!("{}, {}", a.deref(), a.deref());
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:59:50
|
||||
|
|
||||
LL | let b: String = format!("{}, {}", a.deref(), a.deref());
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:61:20
|
||||
|
|
||||
LL | println!("{}", a.deref());
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:64:11
|
||||
|
|
||||
LL | match a.deref() {
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:68:28
|
||||
|
|
||||
LL | let b: String = concat(a.deref());
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:70:13
|
||||
|
|
||||
LL | let b = just_return(a).deref();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `just_return(a)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:72:28
|
||||
|
|
||||
LL | let b: String = concat(just_return(a).deref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `just_return(a)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:74:19
|
||||
|
|
||||
LL | let b: &str = a.deref().deref();
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `&**a`
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `&**a`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:77:13
|
||||
|
|
||||
LL | let b = opt_a.unwrap().deref();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&*opt_a.unwrap()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*opt_a.unwrap()`
|
||||
|
||||
error: explicit `deref` method call
|
||||
--> $DIR/explicit_deref_methods.rs:114:31
|
||||
|
|
||||
LL | let b: &str = expr_deref!(a.deref());
|
||||
| ^^^^^^^^^ help: try this: `&*a`
|
||||
| ^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: use of `write!(stdout(), ...).unwrap()`
|
|||
--> $DIR/explicit_write.rs:24:9
|
||||
|
|
||||
LL | write!(std::io::stdout(), "test").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")`
|
||||
|
|
||||
= note: `-D clippy::explicit-write` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,73 +10,73 @@ error: use of `write!(stderr(), ...).unwrap()`
|
|||
--> $DIR/explicit_write.rs:25:9
|
||||
|
|
||||
LL | write!(std::io::stderr(), "test").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprint!("test")`
|
||||
|
||||
error: use of `writeln!(stdout(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:26:9
|
||||
|
|
||||
LL | writeln!(std::io::stdout(), "test").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `println!("test")`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:27:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "test").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("test")`
|
||||
|
||||
error: use of `stdout().write_fmt(...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:28:9
|
||||
|
|
||||
LL | std::io::stdout().write_fmt(format_args!("test")).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")`
|
||||
|
||||
error: use of `stderr().write_fmt(...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:29:9
|
||||
|
|
||||
LL | std::io::stderr().write_fmt(format_args!("test")).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprint!("test")`
|
||||
|
||||
error: use of `writeln!(stdout(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:32:9
|
||||
|
|
||||
LL | writeln!(std::io::stdout(), "test/ntest").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test/ntest")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `println!("test/ntest")`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:33:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "test/ntest").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test/ntest")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("test/ntest")`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:36:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "with {}", value).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {}", value)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {}", value)`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:37:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "with {} {}", 2, value).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {} {}", 2, value)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {} {}", 2, value)`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:38:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "with {value}").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {value}")`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {value}")`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:39:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("macro arg {}", one!())`
|
||||
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:41:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{:w$}", value, w = width)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("{:w$}", value, w = width)`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: use of `extend` instead of `append` for adding the full range of a second
|
|||
--> $DIR/extend_with_drain.rs:9:5
|
||||
|
|
||||
LL | vec2.extend(vec1.drain(..));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec2.append(&mut vec1)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec2.append(&mut vec1)`
|
||||
|
|
||||
= note: `-D clippy::extend-with-drain` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,19 +10,19 @@ error: use of `extend` instead of `append` for adding the full range of a second
|
|||
--> $DIR/extend_with_drain.rs:14:5
|
||||
|
|
||||
LL | vec4.extend(vec3.drain(..));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec4.append(&mut vec3)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec4.append(&mut vec3)`
|
||||
|
||||
error: use of `extend` instead of `append` for adding the full range of a second vector
|
||||
--> $DIR/extend_with_drain.rs:18:5
|
||||
|
|
||||
LL | vec11.extend(return_vector().drain(..));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec11.append(&mut return_vector())`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec11.append(&mut return_vector())`
|
||||
|
||||
error: use of `extend` instead of `append` for adding the full range of a second vector
|
||||
--> $DIR/extend_with_drain.rs:49:5
|
||||
|
|
||||
LL | y.extend(ref_x.drain(..));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `y.append(ref_x)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `y.append(ref_x)`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly
|
|||
--> $DIR/filter_map_next_fixable.rs:9:32
|
||||
|
|
||||
LL | let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `a.iter().find_map(|s| s.parse().ok())`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())`
|
||||
|
|
||||
= note: `-D clippy::filter-map-next` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly
|
|||
--> $DIR/filter_map_next_fixable.rs:22:26
|
||||
|
|
||||
LL | let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `a.iter().find_map(|s| s.parse().ok())`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
//@run-rustfix
|
||||
#![warn(clippy::get_first)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, HashMap, VecDeque};
|
||||
|
||||
struct Bar {
|
||||
arr: [u32; 3],
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
//@run-rustfix
|
||||
#![warn(clippy::get_first)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, HashMap, VecDeque};
|
||||
|
||||
struct Bar {
|
||||
arr: [u32; 3],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: accessing first element with `x.get(0)`
|
||||
--> $DIR/get_first.rs:20:13
|
||||
--> $DIR/get_first.rs:18:13
|
||||
|
|
||||
LL | let _ = x.get(0); // Use x.first()
|
||||
| ^^^^^^^^ help: try: `x.first()`
|
||||
|
|
@ -7,13 +7,13 @@ LL | let _ = x.get(0); // Use x.first()
|
|||
= note: `-D clippy::get-first` implied by `-D warnings`
|
||||
|
||||
error: accessing first element with `y.get(0)`
|
||||
--> $DIR/get_first.rs:25:13
|
||||
--> $DIR/get_first.rs:23:13
|
||||
|
|
||||
LL | let _ = y.get(0); // Use y.first()
|
||||
| ^^^^^^^^ help: try: `y.first()`
|
||||
|
||||
error: accessing first element with `z.get(0)`
|
||||
--> $DIR/get_first.rs:30:13
|
||||
--> $DIR/get_first.rs:28:13
|
||||
|
|
||||
LL | let _ = z.get(0); // Use z.first()
|
||||
| ^^^^^^^^ help: try: `z.first()`
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
#![warn(clippy::unwrap_used)]
|
||||
#![deny(clippy::get_unwrap)]
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, HashMap, VecDeque};
|
||||
|
||||
struct GetFalsePositive {
|
||||
arr: [u32; 3],
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
#![warn(clippy::unwrap_used)]
|
||||
#![deny(clippy::get_unwrap)]
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, HashMap, VecDeque};
|
||||
|
||||
struct GetFalsePositive {
|
||||
arr: [u32; 3],
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:40:17
|
||||
--> $DIR/get_unwrap.rs:38:17
|
||||
|
|
||||
LL | let _ = boxed_slice.get(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/get_unwrap.rs:10:9
|
||||
|
|
@ -11,7 +11,7 @@ LL | #![deny(clippy::get_unwrap)]
|
|||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:40:17
|
||||
--> $DIR/get_unwrap.rs:38:17
|
||||
|
|
||||
LL | let _ = boxed_slice.get(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -20,13 +20,13 @@ LL | let _ = boxed_slice.get(1).unwrap();
|
|||
= note: `-D clippy::unwrap-used` implied by `-D warnings`
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:41:17
|
||||
--> $DIR/get_unwrap.rs:39:17
|
||||
|
|
||||
LL | let _ = some_slice.get(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_slice[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:41:17
|
||||
--> $DIR/get_unwrap.rs:39:17
|
||||
|
|
||||
LL | let _ = some_slice.get(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -34,13 +34,13 @@ LL | let _ = some_slice.get(0).unwrap();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:42:17
|
||||
--> $DIR/get_unwrap.rs:40:17
|
||||
|
|
||||
LL | let _ = some_vec.get(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vec[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:42:17
|
||||
--> $DIR/get_unwrap.rs:40:17
|
||||
|
|
||||
LL | let _ = some_vec.get(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -48,13 +48,13 @@ LL | let _ = some_vec.get(0).unwrap();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:43:17
|
||||
--> $DIR/get_unwrap.rs:41:17
|
||||
|
|
||||
LL | let _ = some_vecdeque.get(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vecdeque[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:43:17
|
||||
--> $DIR/get_unwrap.rs:41:17
|
||||
|
|
||||
LL | let _ = some_vecdeque.get(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -62,13 +62,13 @@ LL | let _ = some_vecdeque.get(0).unwrap();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:44:17
|
||||
--> $DIR/get_unwrap.rs:42:17
|
||||
|
|
||||
LL | let _ = some_hashmap.get(&1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_hashmap[&1]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:44:17
|
||||
--> $DIR/get_unwrap.rs:42:17
|
||||
|
|
||||
LL | let _ = some_hashmap.get(&1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -76,13 +76,13 @@ LL | let _ = some_hashmap.get(&1).unwrap();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:45:17
|
||||
--> $DIR/get_unwrap.rs:43:17
|
||||
|
|
||||
LL | let _ = some_btreemap.get(&1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_btreemap[&1]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:45:17
|
||||
--> $DIR/get_unwrap.rs:43:17
|
||||
|
|
||||
LL | let _ = some_btreemap.get(&1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -90,13 +90,13 @@ LL | let _ = some_btreemap.get(&1).unwrap();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:49:21
|
||||
--> $DIR/get_unwrap.rs:47:21
|
||||
|
|
||||
LL | let _: u8 = *boxed_slice.get(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[1]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:49:22
|
||||
--> $DIR/get_unwrap.rs:47:22
|
||||
|
|
||||
LL | let _: u8 = *boxed_slice.get(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -104,13 +104,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:54:9
|
||||
--> $DIR/get_unwrap.rs:52:9
|
||||
|
|
||||
LL | *boxed_slice.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:54:10
|
||||
--> $DIR/get_unwrap.rs:52:10
|
||||
|
|
||||
LL | *boxed_slice.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -118,13 +118,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1;
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:55:9
|
||||
--> $DIR/get_unwrap.rs:53:9
|
||||
|
|
||||
LL | *some_slice.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_slice[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:55:10
|
||||
--> $DIR/get_unwrap.rs:53:10
|
||||
|
|
||||
LL | *some_slice.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -132,13 +132,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1;
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:56:9
|
||||
--> $DIR/get_unwrap.rs:54:9
|
||||
|
|
||||
LL | *some_vec.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:56:10
|
||||
--> $DIR/get_unwrap.rs:54:10
|
||||
|
|
||||
LL | *some_vec.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -146,13 +146,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1;
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:57:9
|
||||
--> $DIR/get_unwrap.rs:55:9
|
||||
|
|
||||
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vecdeque[0]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:57:10
|
||||
--> $DIR/get_unwrap.rs:55:10
|
||||
|
|
||||
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -160,13 +160,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1;
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:69:17
|
||||
--> $DIR/get_unwrap.rs:67:17
|
||||
|
|
||||
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:69:17
|
||||
--> $DIR/get_unwrap.rs:67:17
|
||||
|
|
||||
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -174,13 +174,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:70:17
|
||||
--> $DIR/get_unwrap.rs:68:17
|
||||
|
|
||||
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]`
|
||||
|
||||
error: used `unwrap()` on an `Option` value
|
||||
--> $DIR/get_unwrap.rs:70:17
|
||||
--> $DIR/get_unwrap.rs:68:17
|
||||
|
|
||||
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -188,28 +188,28 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:80:24
|
||||
--> $DIR/get_unwrap.rs:78:24
|
||||
|
|
||||
LL | let _x: &i32 = f.get(1 + 2).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `&f[1 + 2]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `&f[1 + 2]`
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:83:18
|
||||
--> $DIR/get_unwrap.rs:81:18
|
||||
|
|
||||
LL | let _x = f.get(1 + 2).unwrap().to_string();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `f[1 + 2]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `f[1 + 2]`
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:86:18
|
||||
--> $DIR/get_unwrap.rs:84:18
|
||||
|
|
||||
LL | let _x = f.get(1 + 2).unwrap().abs();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `f[1 + 2]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `f[1 + 2]`
|
||||
|
||||
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/get_unwrap.rs:103:33
|
||||
--> $DIR/get_unwrap.rs:101:33
|
||||
|
|
||||
LL | let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut rest[linidx(j, k) - linidx(i, k) - 1]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut rest[linidx(j, k) - linidx(i, k) - 1]`
|
||||
|
||||
error: aborting due to 30 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ LL | / fn clone_from(&mut self, source: &Self) {
|
|||
LL | | source.clone();
|
||||
LL | | *self = source.clone();
|
||||
LL | | }
|
||||
| |_____^ help: remove this
|
||||
| |_____^ help: remove it
|
||||
|
||||
error: incorrect implementation of `clone` on a `Copy` type
|
||||
--> $DIR/incorrect_clone_impl_on_copy_type.rs:81:29
|
||||
|
|
@ -34,7 +34,7 @@ LL | / fn clone_from(&mut self, source: &Self) {
|
|||
LL | | source.clone();
|
||||
LL | | *self = source.clone();
|
||||
LL | | }
|
||||
| |_____^ help: remove this
|
||||
| |_____^ help: remove it
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
114
tests/ui/incorrect_partial_ord_impl_on_ord_type.fixed
Normal file
114
tests/ui/incorrect_partial_ord_impl_on_ord_type.fixed
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
//@run-rustfix
|
||||
#![allow(unused)]
|
||||
#![no_main]
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
// lint
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct A(u32);
|
||||
|
||||
impl Ord for A {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for A {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||
}
|
||||
|
||||
// do not lint
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct B(u32);
|
||||
|
||||
impl Ord for B {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for B {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
// lint, and give `_` a name
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct C(u32);
|
||||
|
||||
impl Ord for C {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for C {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||
}
|
||||
|
||||
// do not lint derived
|
||||
|
||||
#[derive(Eq, Ord, PartialEq, PartialOrd)]
|
||||
struct D(u32);
|
||||
|
||||
// do not lint if ord is not manually implemented
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct E(u32);
|
||||
|
||||
impl PartialOrd for E {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint since ord has more restrictive bounds
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Uwu<A>(A);
|
||||
|
||||
impl<A: std::fmt::Debug + Ord + PartialOrd> Ord for Uwu<A> {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Ord + PartialOrd> PartialOrd for Uwu<A> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint since `Rhs` is not `Self`
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct F(u32);
|
||||
|
||||
impl Ord for F {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for F {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<u32> for F {
|
||||
fn eq(&self, other: &u32) -> bool {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd<u32> for F {
|
||||
fn partial_cmp(&self, other: &u32) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
118
tests/ui/incorrect_partial_ord_impl_on_ord_type.rs
Normal file
118
tests/ui/incorrect_partial_ord_impl_on_ord_type.rs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
//@run-rustfix
|
||||
#![allow(unused)]
|
||||
#![no_main]
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
// lint
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct A(u32);
|
||||
|
||||
impl Ord for A {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for A {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct B(u32);
|
||||
|
||||
impl Ord for B {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for B {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
// lint, and give `_` a name
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct C(u32);
|
||||
|
||||
impl Ord for C {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for C {
|
||||
fn partial_cmp(&self, _: &Self) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint derived
|
||||
|
||||
#[derive(Eq, Ord, PartialEq, PartialOrd)]
|
||||
struct D(u32);
|
||||
|
||||
// do not lint if ord is not manually implemented
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct E(u32);
|
||||
|
||||
impl PartialOrd for E {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint since ord has more restrictive bounds
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Uwu<A>(A);
|
||||
|
||||
impl<A: std::fmt::Debug + Ord + PartialOrd> Ord for Uwu<A> {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Ord + PartialOrd> PartialOrd for Uwu<A> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint since `Rhs` is not `Self`
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct F(u32);
|
||||
|
||||
impl Ord for F {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for F {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<u32> for F {
|
||||
fn eq(&self, other: &u32) -> bool {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd<u32> for F {
|
||||
fn partial_cmp(&self, other: &u32) -> Option<Ordering> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
31
tests/ui/incorrect_partial_ord_impl_on_ord_type.stderr
Normal file
31
tests/ui/incorrect_partial_ord_impl_on_ord_type.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error: incorrect implementation of `partial_cmp` on an `Ord` type
|
||||
--> $DIR/incorrect_partial_ord_impl_on_ord_type.rs:18:1
|
||||
|
|
||||
LL | / impl PartialOrd for A {
|
||||
LL | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
| | _____________________________________________________________-
|
||||
LL | || todo!();
|
||||
LL | || }
|
||||
| ||_____- help: change this to: `{ Some(self.cmp(other)) }`
|
||||
LL | | }
|
||||
| |__^
|
||||
|
|
||||
= note: `#[deny(clippy::incorrect_partial_ord_impl_on_ord_type)]` on by default
|
||||
|
||||
error: incorrect implementation of `partial_cmp` on an `Ord` type
|
||||
--> $DIR/incorrect_partial_ord_impl_on_ord_type.rs:52:1
|
||||
|
|
||||
LL | / impl PartialOrd for C {
|
||||
LL | | fn partial_cmp(&self, _: &Self) -> Option<Ordering> {
|
||||
LL | | todo!();
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
help: change this to
|
||||
|
|
||||
LL | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||
| ~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ error: you seem to be trying to use `match` to destructure a single infallible p
|
|||
LL | / let data = match wrapper {
|
||||
LL | | SingleVariantEnum::Variant(i) => i,
|
||||
LL | | };
|
||||
| |______^ help: try this: `let SingleVariantEnum::Variant(data) = wrapper;`
|
||||
| |______^ help: try: `let SingleVariantEnum::Variant(data) = wrapper;`
|
||||
|
|
||||
= note: `-D clippy::infallible-destructuring-match` implied by `-D warnings`
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ error: you seem to be trying to use `match` to destructure a single infallible p
|
|||
LL | / let data = match wrapper {
|
||||
LL | | TupleStruct(i) => i,
|
||||
LL | | };
|
||||
| |______^ help: try this: `let TupleStruct(data) = wrapper;`
|
||||
| |______^ help: try: `let TupleStruct(data) = wrapper;`
|
||||
|
||||
error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let`
|
||||
--> $DIR/infallible_destructuring_match.rs:85:5
|
||||
|
|
@ -22,7 +22,7 @@ error: you seem to be trying to use `match` to destructure a single infallible p
|
|||
LL | / let data = match wrapper {
|
||||
LL | | TupleStructWithNonCopy(ref n) => n,
|
||||
LL | | };
|
||||
| |______^ help: try this: `let TupleStructWithNonCopy(ref data) = wrapper;`
|
||||
| |______^ help: try: `let TupleStructWithNonCopy(ref data) = wrapper;`
|
||||
|
||||
error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let`
|
||||
--> $DIR/infallible_destructuring_match.rs:104:5
|
||||
|
|
@ -30,7 +30,7 @@ error: you seem to be trying to use `match` to destructure a single infallible p
|
|||
LL | / let data = match wrapper {
|
||||
LL | | Ok(i) => i,
|
||||
LL | | };
|
||||
| |______^ help: try this: `let Ok(data) = wrapper;`
|
||||
| |______^ help: try: `let Ok(data) = wrapper;`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/infinite_loop.rs:7:17
|
||||
|
|
||||
LL | fn fn_mutref(i: &mut i32) {
|
||||
| ^^^^^^^^ help: consider changing to: `&i32`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> $DIR/infinite_loop.rs:20:11
|
||||
|
|
||||
|
|
@ -91,5 +99,5 @@ LL | while y < 10 {
|
|||
= note: this loop contains `return`s or `break`s
|
||||
= help: rewrite it as `if cond { loop { } }`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
use std::{borrow::Cow, collections::BTreeMap, marker::PhantomData, sync::Arc};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn byte_view<'a>(s: &'a ByteView<'_>) -> BTreeMap<&'a str, ByteView<'a>> {
|
||||
panic!()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: sub-expression diverges
|
||||
--> $DIR/issue-7447.rs:23:15
|
||||
--> $DIR/issue-7447.rs:26:15
|
||||
|
|
||||
LL | byte_view(panic!());
|
||||
| ^^^^^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | byte_view(panic!());
|
|||
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: sub-expression diverges
|
||||
--> $DIR/issue-7447.rs:24:19
|
||||
--> $DIR/issue-7447.rs:27:19
|
||||
|
|
||||
LL | group_entries(panic!());
|
||||
| ^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
#![allow(unused)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
|
||||
fn main() {
|
||||
let v = [1, 2, 3, 4, 5];
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
#![allow(unused)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
|
||||
fn main() {
|
||||
let v = [1, 2, 3, 4, 5];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
|
||||
--> $DIR/iter_cloned_collect.rs:11:27
|
||||
--> $DIR/iter_cloned_collect.rs:10:27
|
||||
|
|
||||
LL | let v2: Vec<isize> = v.iter().cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
||||
|
|
@ -7,13 +7,13 @@ LL | let v2: Vec<isize> = v.iter().cloned().collect();
|
|||
= note: `-D clippy::iter-cloned-collect` implied by `-D warnings`
|
||||
|
||||
error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
|
||||
--> $DIR/iter_cloned_collect.rs:16:38
|
||||
--> $DIR/iter_cloned_collect.rs:15:38
|
||||
|
|
||||
LL | let _: Vec<isize> = vec![1, 2, 3].iter().cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
||||
|
||||
error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
|
||||
--> $DIR/iter_cloned_collect.rs:21:24
|
||||
--> $DIR/iter_cloned_collect.rs:20:24
|
||||
|
|
||||
LL | .to_bytes()
|
||||
| ________________________^
|
||||
|
|
@ -23,13 +23,13 @@ LL | | .collect();
|
|||
| |______________________^ help: try: `.to_vec()`
|
||||
|
||||
error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
|
||||
--> $DIR/iter_cloned_collect.rs:29:24
|
||||
--> $DIR/iter_cloned_collect.rs:28:24
|
||||
|
|
||||
LL | let _: Vec<_> = arr.iter().cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
||||
|
||||
error: called `iter().copied().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
|
||||
--> $DIR/iter_cloned_collect.rs:32:26
|
||||
--> $DIR/iter_cloned_collect.rs:31:26
|
||||
|
|
||||
LL | let _: Vec<isize> = v.iter().copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: unnecessarily eager cloning of iterator items
|
|||
LL | let _: Option<String> = vec.iter().cloned().last();
|
||||
| ^^^^^^^^^^----------------
|
||||
| |
|
||||
| help: try this: `.last().cloned()`
|
||||
| help: try: `.last().cloned()`
|
||||
|
|
||||
= note: `-D clippy::iter-overeager-cloned` implied by `-D warnings`
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ error: unnecessarily eager cloning of iterator items
|
|||
LL | let _: Option<String> = vec.iter().chain(vec.iter()).cloned().next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
|
||||
| |
|
||||
| help: try this: `.next().cloned()`
|
||||
| help: try: `.next().cloned()`
|
||||
|
||||
error: unneeded cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:12:20
|
||||
|
|
@ -22,7 +22,7 @@ error: unneeded cloning of iterator items
|
|||
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------
|
||||
| |
|
||||
| help: try this: `.count()`
|
||||
| help: try: `.count()`
|
||||
|
|
||||
= note: `-D clippy::redundant-clone` implied by `-D warnings`
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ error: unnecessarily eager cloning of iterator items
|
|||
LL | let _: Vec<_> = vec.iter().cloned().take(2).collect();
|
||||
| ^^^^^^^^^^-----------------
|
||||
| |
|
||||
| help: try this: `.take(2).cloned()`
|
||||
| help: try: `.take(2).cloned()`
|
||||
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:16:21
|
||||
|
|
@ -40,7 +40,7 @@ error: unnecessarily eager cloning of iterator items
|
|||
LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect();
|
||||
| ^^^^^^^^^^-----------------
|
||||
| |
|
||||
| help: try this: `.skip(2).cloned()`
|
||||
| help: try: `.skip(2).cloned()`
|
||||
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:18:13
|
||||
|
|
@ -48,7 +48,7 @@ error: unnecessarily eager cloning of iterator items
|
|||
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
|
||||
| |
|
||||
| help: try this: `.nth(2).cloned()`
|
||||
| help: try: `.nth(2).cloned()`
|
||||
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:20:13
|
||||
|
|
@ -60,7 +60,7 @@ LL | | .cloned()
|
|||
LL | | .flatten();
|
||||
| |__________________^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ .iter()
|
||||
LL ~ .flatten().cloned();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: `drain(..)` used on a `Vec`
|
|||
--> $DIR/iter_with_drain.rs:11:34
|
||||
|
|
||||
LL | let mut a: BinaryHeap<_> = a.drain(..).collect();
|
||||
| ^^^^^^^^^ help: try this: `into_iter()`
|
||||
| ^^^^^^^^^ help: try: `into_iter()`
|
||||
|
|
||||
= note: `-D clippy::iter-with-drain` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,31 +10,31 @@ error: `drain(..)` used on a `VecDeque`
|
|||
--> $DIR/iter_with_drain.rs:14:27
|
||||
|
|
||||
LL | let mut a: Vec<_> = a.drain(..).collect();
|
||||
| ^^^^^^^^^ help: try this: `into_iter()`
|
||||
| ^^^^^^^^^ help: try: `into_iter()`
|
||||
|
||||
error: `drain(..)` used on a `Vec`
|
||||
--> $DIR/iter_with_drain.rs:15:34
|
||||
|
|
||||
LL | let mut a: HashMap<_, _> = a.drain(..).map(|x| (x.clone(), x)).collect();
|
||||
| ^^^^^^^^^ help: try this: `into_iter()`
|
||||
| ^^^^^^^^^ help: try: `into_iter()`
|
||||
|
||||
error: `drain(..)` used on a `Vec`
|
||||
--> $DIR/iter_with_drain.rs:21:34
|
||||
|
|
||||
LL | let mut a: BinaryHeap<_> = a.drain(0..).collect();
|
||||
| ^^^^^^^^^^ help: try this: `into_iter()`
|
||||
| ^^^^^^^^^^ help: try: `into_iter()`
|
||||
|
||||
error: `drain(..)` used on a `VecDeque`
|
||||
--> $DIR/iter_with_drain.rs:24:27
|
||||
|
|
||||
LL | let mut a: Vec<_> = a.drain(..a.len()).collect();
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `into_iter()`
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `into_iter()`
|
||||
|
||||
error: `drain(..)` used on a `Vec`
|
||||
--> $DIR/iter_with_drain.rs:25:34
|
||||
|
|
||||
LL | let mut a: HashMap<_, _> = a.drain(0..a.len()).map(|x| (x.clone(), x)).collect();
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `into_iter()`
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `into_iter()`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#![allow(unused)]
|
||||
#![warn(clippy::let_and_return)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
fn test() -> i32 {
|
||||
let _y = 0; // no warning
|
||||
let x = 5;
|
||||
|
|
@ -65,45 +67,46 @@ macro_rules! tuple_encode {
|
|||
);
|
||||
}
|
||||
|
||||
fn issue_3792() -> String {
|
||||
use std::io::{self, BufRead, Stdin};
|
||||
|
||||
let stdin = io::stdin();
|
||||
// `Stdin::lock` returns `StdinLock<'static>` so `line` doesn't borrow from `stdin`
|
||||
// https://github.com/rust-lang/rust/pull/93965
|
||||
let line = stdin.lock().lines().next().unwrap().unwrap();
|
||||
line
|
||||
}
|
||||
|
||||
tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7);
|
||||
|
||||
mod no_lint_if_stmt_borrows {
|
||||
mod issue_3792 {
|
||||
use std::io::{self, BufRead, Stdin};
|
||||
use std::cell::RefCell;
|
||||
use std::rc::{Rc, Weak};
|
||||
struct Bar;
|
||||
|
||||
fn read_line() -> String {
|
||||
let stdin = io::stdin();
|
||||
let line = stdin.lock().lines().next().unwrap().unwrap();
|
||||
line
|
||||
impl Bar {
|
||||
fn new() -> Self {
|
||||
Bar {}
|
||||
}
|
||||
fn baz(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
mod issue_3324 {
|
||||
use std::cell::RefCell;
|
||||
use std::rc::{Rc, Weak};
|
||||
fn issue_3324(value: Weak<RefCell<Bar>>) -> u32 {
|
||||
let value = value.upgrade().unwrap();
|
||||
let ret = value.borrow().baz();
|
||||
ret
|
||||
}
|
||||
|
||||
fn test(value: Weak<RefCell<Bar>>) -> u32 {
|
||||
let value = value.upgrade().unwrap();
|
||||
let ret = value.borrow().baz();
|
||||
ret
|
||||
fn borrows_in_closure(value: Weak<RefCell<Bar>>) -> u32 {
|
||||
fn f(mut x: impl FnMut() -> u32) -> impl FnMut() -> u32 {
|
||||
x
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Bar {
|
||||
fn new() -> Self {
|
||||
Bar {}
|
||||
}
|
||||
fn baz(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = Rc::new(RefCell::new(Bar::new()));
|
||||
let b = Rc::downgrade(&a);
|
||||
test(b);
|
||||
}
|
||||
let value = value.upgrade().unwrap();
|
||||
let ret = f(|| value.borrow().baz())();
|
||||
ret
|
||||
}
|
||||
|
||||
mod free_function {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: returning the result of a `let` binding from a block
|
||||
--> $DIR/let_and_return.rs:7:5
|
||||
--> $DIR/let_and_return.rs:9:5
|
||||
|
|
||||
LL | let x = 5;
|
||||
| ---------- unnecessary `let` binding
|
||||
|
|
@ -14,7 +14,7 @@ LL ~ 5
|
|||
|
|
||||
|
||||
error: returning the result of a `let` binding from a block
|
||||
--> $DIR/let_and_return.rs:13:9
|
||||
--> $DIR/let_and_return.rs:15:9
|
||||
|
|
||||
LL | let x = 5;
|
||||
| ---------- unnecessary `let` binding
|
||||
|
|
@ -28,7 +28,21 @@ LL ~ 5
|
|||
|
|
||||
|
||||
error: returning the result of a `let` binding from a block
|
||||
--> $DIR/let_and_return.rs:164:13
|
||||
--> $DIR/let_and_return.rs:77:5
|
||||
|
|
||||
LL | let line = stdin.lock().lines().next().unwrap().unwrap();
|
||||
| --------------------------------------------------------- unnecessary `let` binding
|
||||
LL | line
|
||||
| ^^^^
|
||||
|
|
||||
help: return the expression directly
|
||||
|
|
||||
LL ~
|
||||
LL ~ stdin.lock().lines().next().unwrap().unwrap()
|
||||
|
|
||||
|
||||
error: returning the result of a `let` binding from a block
|
||||
--> $DIR/let_and_return.rs:167:13
|
||||
|
|
||||
LL | let clone = Arc::clone(&self.foo);
|
||||
| ---------------------------------- unnecessary `let` binding
|
||||
|
|
@ -41,5 +55,5 @@ LL ~
|
|||
LL ~ Arc::clone(&self.foo) as _
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/let_underscore_future.rs:11:35
|
||||
|
|
||||
LL | fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&impl Future<Output = ()>`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: non-binding `let` on a future
|
||||
--> $DIR/let_underscore_future.rs:14:5
|
||||
|
|
||||
|
|
@ -23,5 +31,5 @@ LL | let _ = future;
|
|||
|
|
||||
= help: consider awaiting the future or dropping explicitly with `std::mem::drop`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
extern crate parking_lot;
|
||||
|
||||
fn main() {
|
||||
use parking_lot::{lock_api::RawMutex, Mutex, RwLock};
|
||||
use parking_lot::lock_api::RawMutex;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
|
||||
let p_m: Mutex<()> = Mutex::const_new(RawMutex::INIT, ());
|
||||
let _ = p_m.lock();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: non-binding `let` on a synchronization lock
|
||||
--> $DIR/let_underscore_lock.rs:9:5
|
||||
--> $DIR/let_underscore_lock.rs:10:5
|
||||
|
|
||||
LL | let _ = p_m.lock();
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | let _ = p_m.lock();
|
|||
= note: `-D clippy::let-underscore-lock` implied by `-D warnings`
|
||||
|
||||
error: non-binding `let` on a synchronization lock
|
||||
--> $DIR/let_underscore_lock.rs:12:5
|
||||
--> $DIR/let_underscore_lock.rs:13:5
|
||||
|
|
||||
LL | let _ = p_m1.lock();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -16,7 +16,7 @@ LL | let _ = p_m1.lock();
|
|||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop`
|
||||
|
||||
error: non-binding `let` on a synchronization lock
|
||||
--> $DIR/let_underscore_lock.rs:15:5
|
||||
--> $DIR/let_underscore_lock.rs:16:5
|
||||
|
|
||||
LL | let _ = p_rw.read();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -24,7 +24,7 @@ LL | let _ = p_rw.read();
|
|||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop`
|
||||
|
||||
error: non-binding `let` on a synchronization lock
|
||||
--> $DIR/let_underscore_lock.rs:16:5
|
||||
--> $DIR/let_underscore_lock.rs:17:5
|
||||
|
|
||||
LL | let _ = p_rw.write();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ extern crate proc_macros;
|
|||
use proc_macros::with_span;
|
||||
|
||||
use clippy_utils::is_from_proc_macro;
|
||||
use std::boxed::Box;
|
||||
use std::fmt::Display;
|
||||
use std::future::Future;
|
||||
use std::{boxed::Box, fmt::Display};
|
||||
|
||||
fn a() -> u32 {
|
||||
1
|
||||
|
|
|
|||
|
|
@ -1,60 +1,60 @@
|
|||
error: non-binding `let` without a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:50:5
|
||||
--> $DIR/let_underscore_untyped.rs:51:5
|
||||
|
|
||||
LL | let _ = a();
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
help: consider adding a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:50:10
|
||||
--> $DIR/let_underscore_untyped.rs:51:10
|
||||
|
|
||||
LL | let _ = a();
|
||||
| ^
|
||||
= note: `-D clippy::let-underscore-untyped` implied by `-D warnings`
|
||||
|
||||
error: non-binding `let` without a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:51:5
|
||||
--> $DIR/let_underscore_untyped.rs:52:5
|
||||
|
|
||||
LL | let _ = b(1);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
help: consider adding a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:51:10
|
||||
--> $DIR/let_underscore_untyped.rs:52:10
|
||||
|
|
||||
LL | let _ = b(1);
|
||||
| ^
|
||||
|
||||
error: non-binding `let` without a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:53:5
|
||||
--> $DIR/let_underscore_untyped.rs:54:5
|
||||
|
|
||||
LL | let _ = d(&1);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: consider adding a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:53:10
|
||||
--> $DIR/let_underscore_untyped.rs:54:10
|
||||
|
|
||||
LL | let _ = d(&1);
|
||||
| ^
|
||||
|
||||
error: non-binding `let` without a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:54:5
|
||||
--> $DIR/let_underscore_untyped.rs:55:5
|
||||
|
|
||||
LL | let _ = e();
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
help: consider adding a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:54:10
|
||||
--> $DIR/let_underscore_untyped.rs:55:10
|
||||
|
|
||||
LL | let _ = e();
|
||||
| ^
|
||||
|
||||
error: non-binding `let` without a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:55:5
|
||||
--> $DIR/let_underscore_untyped.rs:56:5
|
||||
|
|
||||
LL | let _ = f();
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
help: consider adding a type annotation
|
||||
--> $DIR/let_underscore_untyped.rs:55:10
|
||||
--> $DIR/let_underscore_untyped.rs:56:10
|
||||
|
|
||||
LL | let _ = f();
|
||||
| ^
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ LL | | if x > 0 {
|
|||
... |
|
||||
LL | | },
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).filter(|&x| x <= 0)`
|
||||
| |_____^ help: try: `Some(0).filter(|&x| x <= 0)`
|
||||
|
|
||||
= note: `-D clippy::manual-filter` implied by `-D warnings`
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ LL | | None
|
|||
... |
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(1).filter(|&x| x <= 0)`
|
||||
| |_____^ help: try: `Some(1).filter(|&x| x <= 0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:29:5
|
||||
|
|
@ -34,7 +34,7 @@ LL | | None
|
|||
... |
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(2).filter(|&x| x <= 0)`
|
||||
| |_____^ help: try: `Some(2).filter(|&x| x <= 0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:40:5
|
||||
|
|
@ -46,7 +46,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(3).filter(|&x| x > 0)`
|
||||
| |_____^ help: try: `Some(3).filter(|&x| x > 0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:52:5
|
||||
|
|
@ -58,7 +58,7 @@ LL | | Some(x) => {
|
|||
... |
|
||||
LL | | },
|
||||
LL | | };
|
||||
| |_____^ help: try this: `y.filter(|&x| x <= 0)`
|
||||
| |_____^ help: try: `y.filter(|&x| x <= 0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:64:5
|
||||
|
|
@ -70,7 +70,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(5).filter(|&x| x > 0)`
|
||||
| |_____^ help: try: `Some(5).filter(|&x| x > 0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:75:5
|
||||
|
|
@ -82,7 +82,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(6).as_ref().filter(|&x| x > &0)`
|
||||
| |_____^ help: try: `Some(6).as_ref().filter(|&x| x > &0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:87:5
|
||||
|
|
@ -94,7 +94,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(String::new()).filter(|x| external_cond)`
|
||||
| |_____^ help: try: `Some(String::new()).filter(|x| external_cond)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:98:5
|
||||
|
|
@ -104,7 +104,7 @@ LL | | if external_cond { Some(x) } else { None }
|
|||
LL | | } else {
|
||||
LL | | None
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(7).filter(|&x| external_cond)`
|
||||
| |_____^ help: try: `Some(7).filter(|&x| external_cond)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:104:5
|
||||
|
|
@ -116,7 +116,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(8).filter(|&x| x != 0)`
|
||||
| |_____^ help: try: `Some(8).filter(|&x| x != 0)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:115:5
|
||||
|
|
@ -128,7 +128,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(9).filter(|&x| x > 10 && x < 100)`
|
||||
| |_____^ help: try: `Some(9).filter(|&x| x > 10 && x < 100)`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:141:5
|
||||
|
|
@ -142,7 +142,7 @@ LL | | None => None,
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ Some(11).filter(|&x| {
|
||||
LL + println!("foo");
|
||||
|
|
@ -161,7 +161,7 @@ LL | | Some(x)
|
|||
... |
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(14).filter(|&x| unsafe { f(x) })`
|
||||
| |_____^ help: try: `Some(14).filter(|&x| unsafe { f(x) })`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:195:13
|
||||
|
|
@ -173,7 +173,7 @@ LL | | if f(x) { Some(x) } else { None }
|
|||
LL | | },
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(15).filter(|&x| unsafe { f(x) })`
|
||||
| |_____^ help: try: `Some(15).filter(|&x| unsafe { f(x) })`
|
||||
|
||||
error: manual implementation of `Option::filter`
|
||||
--> $DIR/manual_filter.rs:205:12
|
||||
|
|
@ -185,7 +185,7 @@ LL | | if x % 2 == 0 { Some(x) } else { None }
|
|||
LL | | } else {
|
||||
LL | | None
|
||||
LL | | };
|
||||
| |_____^ help: try this: `{ Some(16).filter(|&x| x % 2 == 0) }`
|
||||
| |_____^ help: try: `{ Some(16).filter(|&x| x % 2 == 0) }`
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
|||
55
tests/ui/manual_float_methods.rs
Normal file
55
tests/ui/manual_float_methods.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
//@aux-build:proc_macros.rs:proc-macro
|
||||
#![allow(clippy::needless_if, unused)]
|
||||
#![warn(clippy::manual_is_infinite, clippy::manual_is_finite)]
|
||||
#![feature(inline_const)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macros;
|
||||
|
||||
const INFINITE: f32 = f32::INFINITY;
|
||||
const NEG_INFINITE: f32 = f32::NEG_INFINITY;
|
||||
|
||||
fn fn_test() -> f64 {
|
||||
f64::NEG_INFINITY
|
||||
}
|
||||
|
||||
fn fn_test_not_inf() -> f64 {
|
||||
112.0
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = 1.0f32;
|
||||
if x == f32::INFINITY || x == f32::NEG_INFINITY {}
|
||||
if x != f32::INFINITY && x != f32::NEG_INFINITY {}
|
||||
if x == INFINITE || x == NEG_INFINITE {}
|
||||
if x != INFINITE && x != NEG_INFINITE {}
|
||||
let x = 1.0f64;
|
||||
if x == f64::INFINITY || x == f64::NEG_INFINITY {}
|
||||
if x != f64::INFINITY && x != f64::NEG_INFINITY {}
|
||||
// Don't lint
|
||||
if x.is_infinite() {}
|
||||
if x.is_finite() {}
|
||||
if x.abs() < f64::INFINITY {}
|
||||
if f64::INFINITY > x.abs() {}
|
||||
if f64::abs(x) < f64::INFINITY {}
|
||||
if f64::INFINITY > f64::abs(x) {}
|
||||
// Is not evaluated by `clippy_utils::constant`
|
||||
if x != f64::INFINITY && x != fn_test() {}
|
||||
// Not -inf
|
||||
if x != f64::INFINITY && x != fn_test_not_inf() {}
|
||||
const X: f64 = 1.0f64;
|
||||
// Will be linted if `const_float_classify` is enabled
|
||||
if const { X == f64::INFINITY || X == f64::NEG_INFINITY } {}
|
||||
if const { X != f64::INFINITY && X != f64::NEG_INFINITY } {}
|
||||
external! {
|
||||
let x = 1.0;
|
||||
if x == f32::INFINITY || x == f32::NEG_INFINITY {}
|
||||
if x != f32::INFINITY && x != f32::NEG_INFINITY {}
|
||||
}
|
||||
with_span! {
|
||||
span
|
||||
let x = 1.0;
|
||||
if x == f32::INFINITY || x == f32::NEG_INFINITY {}
|
||||
if x != f32::INFINITY && x != f32::NEG_INFINITY {}
|
||||
}
|
||||
}
|
||||
80
tests/ui/manual_float_methods.stderr
Normal file
80
tests/ui/manual_float_methods.stderr
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
error: manually checking if a float is infinite
|
||||
--> $DIR/manual_float_methods.rs:22:8
|
||||
|
|
||||
LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
|
||||
|
|
||||
= note: `-D clippy::manual-is-infinite` implied by `-D warnings`
|
||||
|
||||
error: manually checking if a float is finite
|
||||
--> $DIR/manual_float_methods.rs:23:8
|
||||
|
|
||||
LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::manual-is-finite` implied by `-D warnings`
|
||||
help: use the dedicated method instead
|
||||
|
|
||||
LL | if x.is_finite() {}
|
||||
| ~~~~~~~~~~~~~
|
||||
help: this will alter how it handles NaN; if that is a problem, use instead
|
||||
|
|
||||
LL | if x.is_finite() || x.is_nan() {}
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
help: or, for conciseness
|
||||
|
|
||||
LL | if !x.is_infinite() {}
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: manually checking if a float is infinite
|
||||
--> $DIR/manual_float_methods.rs:24:8
|
||||
|
|
||||
LL | if x == INFINITE || x == NEG_INFINITE {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
|
||||
|
||||
error: manually checking if a float is finite
|
||||
--> $DIR/manual_float_methods.rs:25:8
|
||||
|
|
||||
LL | if x != INFINITE && x != NEG_INFINITE {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the dedicated method instead
|
||||
|
|
||||
LL | if x.is_finite() {}
|
||||
| ~~~~~~~~~~~~~
|
||||
help: this will alter how it handles NaN; if that is a problem, use instead
|
||||
|
|
||||
LL | if x.is_finite() || x.is_nan() {}
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
help: or, for conciseness
|
||||
|
|
||||
LL | if !x.is_infinite() {}
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: manually checking if a float is infinite
|
||||
--> $DIR/manual_float_methods.rs:27:8
|
||||
|
|
||||
LL | if x == f64::INFINITY || x == f64::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
|
||||
|
||||
error: manually checking if a float is finite
|
||||
--> $DIR/manual_float_methods.rs:28:8
|
||||
|
|
||||
LL | if x != f64::INFINITY && x != f64::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the dedicated method instead
|
||||
|
|
||||
LL | if x.is_finite() {}
|
||||
| ~~~~~~~~~~~~~
|
||||
help: this will alter how it handles NaN; if that is a problem, use instead
|
||||
|
|
||||
LL | if x.is_finite() || x.is_nan() {}
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
help: or, for conciseness
|
||||
|
|
||||
LL | if !x.is_infinite() {}
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
@ -279,7 +279,9 @@ fn not_fire() {
|
|||
create_binding_if_some_nf!(v, g());
|
||||
|
||||
// Already a let-else
|
||||
let Some(a) = (if let Some(b) = Some(Some(())) { b } else { return }) else { panic!() };
|
||||
let Some(a) = (if let Some(b) = Some(Some(())) { b } else { return }) else {
|
||||
panic!()
|
||||
};
|
||||
|
||||
// If a type annotation is present, don't lint as
|
||||
// expressing the type might be too hard
|
||||
|
|
@ -304,9 +306,7 @@ fn not_fire() {
|
|||
let _x = if let Some(x) = Some(1) {
|
||||
x
|
||||
} else {
|
||||
let Some(_z) = Some(3) else {
|
||||
return
|
||||
};
|
||||
let Some(_z) = Some(3) else { return };
|
||||
1
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> $DIR/manual_let_else.rs:297:5
|
||||
--> $DIR/manual_let_else.rs:299:5
|
||||
|
|
||||
LL | / let _ = match ff {
|
||||
LL | | Some(value) => value,
|
||||
|
|
|
|||
63
tests/ui/manual_let_else_question_mark.fixed
Normal file
63
tests/ui/manual_let_else_question_mark.fixed
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
//@run-rustfix
|
||||
#![allow(unused_braces, unused_variables, dead_code)]
|
||||
#![allow(
|
||||
clippy::collapsible_else_if,
|
||||
clippy::unused_unit,
|
||||
clippy::let_unit_value,
|
||||
clippy::match_single_binding,
|
||||
clippy::never_loop
|
||||
)]
|
||||
#![warn(clippy::manual_let_else, clippy::question_mark)]
|
||||
|
||||
enum Variant {
|
||||
A(usize, usize),
|
||||
B(usize),
|
||||
C,
|
||||
}
|
||||
|
||||
fn g() -> Option<(u8, u8)> {
|
||||
None
|
||||
}
|
||||
|
||||
fn e() -> Variant {
|
||||
Variant::A(0, 0)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn foo() -> Option<()> {
|
||||
// Fire here, normal case
|
||||
let v = g()?;
|
||||
|
||||
// Don't fire here, the pattern is refutable
|
||||
let Variant::A(v, w) = e() else { return None };
|
||||
|
||||
// Fire here, the pattern is irrefutable
|
||||
let (v, w) = g()?;
|
||||
|
||||
// Don't fire manual_let_else in this instance: question mark can be used instead.
|
||||
let v = g()?;
|
||||
|
||||
// Do fire manual_let_else in this instance: question mark cannot be used here due to the return
|
||||
// body.
|
||||
let Some(v) = g() else {
|
||||
return Some(());
|
||||
};
|
||||
|
||||
// Here we could also fire the question_mark lint, but we don't (as it's a match and not an if let).
|
||||
// So we still emit manual_let_else here. For the *resulting* code, we *do* emit the question_mark
|
||||
// lint, so for rustfix reasons, we allow the question_mark lint here.
|
||||
#[allow(clippy::question_mark)]
|
||||
{
|
||||
let Some(v) = g() else { return None };
|
||||
}
|
||||
|
||||
// This is a copy of the case above where we'd fire the question_mark lint, but here we have allowed
|
||||
// it. Make sure that manual_let_else is fired as the fallback.
|
||||
#[allow(clippy::question_mark)]
|
||||
{
|
||||
let Some(v) = g() else { return None };
|
||||
}
|
||||
|
||||
Some(())
|
||||
}
|
||||
68
tests/ui/manual_let_else_question_mark.rs
Normal file
68
tests/ui/manual_let_else_question_mark.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
//@run-rustfix
|
||||
#![allow(unused_braces, unused_variables, dead_code)]
|
||||
#![allow(
|
||||
clippy::collapsible_else_if,
|
||||
clippy::unused_unit,
|
||||
clippy::let_unit_value,
|
||||
clippy::match_single_binding,
|
||||
clippy::never_loop
|
||||
)]
|
||||
#![warn(clippy::manual_let_else, clippy::question_mark)]
|
||||
|
||||
enum Variant {
|
||||
A(usize, usize),
|
||||
B(usize),
|
||||
C,
|
||||
}
|
||||
|
||||
fn g() -> Option<(u8, u8)> {
|
||||
None
|
||||
}
|
||||
|
||||
fn e() -> Variant {
|
||||
Variant::A(0, 0)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn foo() -> Option<()> {
|
||||
// Fire here, normal case
|
||||
let Some(v) = g() else { return None };
|
||||
|
||||
// Don't fire here, the pattern is refutable
|
||||
let Variant::A(v, w) = e() else { return None };
|
||||
|
||||
// Fire here, the pattern is irrefutable
|
||||
let Some((v, w)) = g() else { return None };
|
||||
|
||||
// Don't fire manual_let_else in this instance: question mark can be used instead.
|
||||
let v = if let Some(v_some) = g() { v_some } else { return None };
|
||||
|
||||
// Do fire manual_let_else in this instance: question mark cannot be used here due to the return
|
||||
// body.
|
||||
let v = if let Some(v_some) = g() {
|
||||
v_some
|
||||
} else {
|
||||
return Some(());
|
||||
};
|
||||
|
||||
// Here we could also fire the question_mark lint, but we don't (as it's a match and not an if let).
|
||||
// So we still emit manual_let_else here. For the *resulting* code, we *do* emit the question_mark
|
||||
// lint, so for rustfix reasons, we allow the question_mark lint here.
|
||||
#[allow(clippy::question_mark)]
|
||||
{
|
||||
let v = match g() {
|
||||
Some(v_some) => v_some,
|
||||
_ => return None,
|
||||
};
|
||||
}
|
||||
|
||||
// This is a copy of the case above where we'd fire the question_mark lint, but here we have allowed
|
||||
// it. Make sure that manual_let_else is fired as the fallback.
|
||||
#[allow(clippy::question_mark)]
|
||||
{
|
||||
let v = if let Some(v_some) = g() { v_some } else { return None };
|
||||
}
|
||||
|
||||
Some(())
|
||||
}
|
||||
55
tests/ui/manual_let_else_question_mark.stderr
Normal file
55
tests/ui/manual_let_else_question_mark.stderr
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
error: this `let...else` may be rewritten with the `?` operator
|
||||
--> $DIR/manual_let_else_question_mark.rs:30:5
|
||||
|
|
||||
LL | let Some(v) = g() else { return None };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let v = g()?;`
|
||||
|
|
||||
= note: `-D clippy::question-mark` implied by `-D warnings`
|
||||
|
||||
error: this `let...else` may be rewritten with the `?` operator
|
||||
--> $DIR/manual_let_else_question_mark.rs:36:5
|
||||
|
|
||||
LL | let Some((v, w)) = g() else { return None };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let (v, w) = g()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/manual_let_else_question_mark.rs:39:13
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { return None };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `g()?`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> $DIR/manual_let_else_question_mark.rs:43:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | | v_some
|
||||
LL | | } else {
|
||||
LL | | return Some(());
|
||||
LL | | };
|
||||
| |______^
|
||||
|
|
||||
= note: `-D clippy::manual-let-else` implied by `-D warnings`
|
||||
help: consider writing
|
||||
|
|
||||
LL ~ let Some(v) = g() else {
|
||||
LL + return Some(());
|
||||
LL + };
|
||||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> $DIR/manual_let_else_question_mark.rs:54:9
|
||||
|
|
||||
LL | / let v = match g() {
|
||||
LL | | Some(v_some) => v_some,
|
||||
LL | | _ => return None,
|
||||
LL | | };
|
||||
| |__________^ help: consider writing: `let Some(v) = g() else { return None };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> $DIR/manual_let_else_question_mark.rs:64:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { return None };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return None };`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ LL | / match Some(0) {
|
|||
LL | | Some(_) => Some(2),
|
||||
LL | | None::<u32> => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|_| 2)`
|
||||
| |_____^ help: try: `Some(0).map(|_| 2)`
|
||||
|
|
||||
= note: `-D clippy::manual-map` implied by `-D warnings`
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ LL | / match Some(0) {
|
|||
LL | | Some(x) => Some(x + 1),
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| x + 1)`
|
||||
| |_____^ help: try: `Some(0).map(|x| x + 1)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:25:5
|
||||
|
|
@ -25,7 +25,7 @@ LL | / match Some("") {
|
|||
LL | | Some(x) => Some(x.is_empty()),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some("").map(|x| x.is_empty())`
|
||||
| |_____^ help: try: `Some("").map(|x| x.is_empty())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:30:5
|
||||
|
|
@ -35,7 +35,7 @@ LL | | Some(!x)
|
|||
LL | | } else {
|
||||
LL | | None
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| !x)`
|
||||
| |_____^ help: try: `Some(0).map(|x| !x)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:37:5
|
||||
|
|
@ -44,7 +44,7 @@ LL | / match Some(0) {
|
|||
LL | | Some(x) => { Some(std::convert::identity(x)) }
|
||||
LL | | None => { None }
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(std::convert::identity)`
|
||||
| |_____^ help: try: `Some(0).map(std::convert::identity)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:42:5
|
||||
|
|
@ -53,7 +53,7 @@ LL | / match Some(&String::new()) {
|
|||
LL | | Some(x) => Some(str::len(x)),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(&String::new()).map(|x| str::len(x))`
|
||||
| |_____^ help: try: `Some(&String::new()).map(|x| str::len(x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:52:5
|
||||
|
|
@ -62,7 +62,7 @@ LL | / match &Some([0, 1]) {
|
|||
LL | | Some(x) => Some(x[0]),
|
||||
LL | | &None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some([0, 1]).as_ref().map(|x| x[0])`
|
||||
| |_____^ help: try: `Some([0, 1]).as_ref().map(|x| x[0])`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:57:5
|
||||
|
|
@ -71,7 +71,7 @@ LL | / match &Some(0) {
|
|||
LL | | &Some(x) => Some(x * 2),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| x * 2)`
|
||||
| |_____^ help: try: `Some(0).map(|x| x * 2)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:62:5
|
||||
|
|
@ -80,7 +80,7 @@ LL | / match Some(String::new()) {
|
|||
LL | | Some(ref x) => Some(x.is_empty()),
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())`
|
||||
| |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.is_empty())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:67:5
|
||||
|
|
@ -89,7 +89,7 @@ LL | / match &&Some(String::new()) {
|
|||
LL | | Some(x) => Some(x.len()),
|
||||
LL | | _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())`
|
||||
| |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.len())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:72:5
|
||||
|
|
@ -98,7 +98,7 @@ LL | / match &&Some(0) {
|
|||
LL | | &&Some(x) => Some(x + x),
|
||||
LL | | &&_ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| x + x)`
|
||||
| |_____^ help: try: `Some(0).map(|x| x + x)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:85:9
|
||||
|
|
@ -107,7 +107,7 @@ LL | / match &mut Some(String::new()) {
|
|||
LL | | Some(x) => Some(x.push_str("")),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `Some(String::new()).as_mut().map(|x| x.push_str(""))`
|
||||
| |_________^ help: try: `Some(String::new()).as_mut().map(|x| x.push_str(""))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:91:5
|
||||
|
|
@ -116,7 +116,7 @@ LL | / match &mut Some(String::new()) {
|
|||
LL | | Some(ref x) => Some(x.len()),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())`
|
||||
| |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.len())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:96:5
|
||||
|
|
@ -125,7 +125,7 @@ LL | / match &mut &Some(String::new()) {
|
|||
LL | | Some(x) => Some(x.is_empty()),
|
||||
LL | | &mut _ => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())`
|
||||
| |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.is_empty())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:101:5
|
||||
|
|
@ -134,7 +134,7 @@ LL | / match Some((0, 1, 2)) {
|
|||
LL | | Some((x, y, z)) => Some(x + y + z),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)`
|
||||
| |_____^ help: try: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:106:5
|
||||
|
|
@ -143,7 +143,7 @@ LL | / match Some([1, 2, 3]) {
|
|||
LL | | Some([first, ..]) => Some(first),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some([1, 2, 3]).map(|[first, ..]| first)`
|
||||
| |_____^ help: try: `Some([1, 2, 3]).map(|[first, ..]| first)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:111:5
|
||||
|
|
@ -152,7 +152,7 @@ LL | / match &Some((String::new(), "test")) {
|
|||
LL | | Some((x, y)) => Some((y, x)),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))`
|
||||
| |_____^ help: try: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:169:5
|
||||
|
|
@ -161,7 +161,7 @@ LL | / match Some(0) {
|
|||
LL | | Some(x) => Some(vec![x]),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| vec![x])`
|
||||
| |_____^ help: try: `Some(0).map(|x| vec![x])`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:174:5
|
||||
|
|
@ -170,7 +170,7 @@ LL | / match option_env!("") {
|
|||
LL | | Some(x) => Some(String::from(x)),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `option_env!("").map(String::from)`
|
||||
| |_____^ help: try: `option_env!("").map(String::from)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:194:12
|
||||
|
|
@ -181,7 +181,7 @@ LL | | Some(x + 1)
|
|||
LL | | } else {
|
||||
LL | | None
|
||||
LL | | };
|
||||
| |_____^ help: try this: `{ Some(0).map(|x| x + 1) }`
|
||||
| |_____^ help: try: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:202:12
|
||||
|
|
@ -192,7 +192,7 @@ LL | | Some(x + 1)
|
|||
LL | | } else {
|
||||
LL | | None
|
||||
LL | | };
|
||||
| |_____^ help: try this: `{ Some(0).map(|x| x + 1) }`
|
||||
| |_____^ help: try: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LL | | };
|
|||
| |_____^
|
||||
|
|
||||
= note: `-D clippy::manual-map` implied by `-D warnings`
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ let _ = Some(0).map(|x| {
|
||||
LL + let y = (String::new(), String::new());
|
||||
|
|
@ -32,7 +32,7 @@ LL | | None => None,
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
help: try this
|
||||
help: try
|
||||
|
|
||||
LL ~ let _ = s.as_ref().map(|x| {
|
||||
LL + if let Some(ref s) = s { (x.clone(), s) } else { panic!() }
|
||||
|
|
@ -47,7 +47,7 @@ LL | let _ = match Some(0) {
|
|||
LL | | Some(x) => Some(f(x)),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `Some(0).map(|x| f(x))`
|
||||
| |_________^ help: try: `Some(0).map(|x| f(x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option_2.rs:67:13
|
||||
|
|
@ -57,7 +57,7 @@ LL | let _ = match Some(0) {
|
|||
LL | | Some(x) => unsafe { Some(f(x)) },
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })`
|
||||
| |_____^ help: try: `Some(0).map(|x| unsafe { f(x) })`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option_2.rs:71:13
|
||||
|
|
@ -67,7 +67,7 @@ LL | let _ = match Some(0) {
|
|||
LL | | Some(x) => Some(unsafe { f(x) }),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })`
|
||||
| |_____^ help: try: `Some(0).map(|x| unsafe { f(x) })`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ fn main() {
|
|||
1..=10 => true,
|
||||
_ => false,
|
||||
};
|
||||
let _ = matches!(f, -5..=3);
|
||||
let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1); // 2 is missing
|
||||
let _ = matches!(f, -1000001..=1000001);
|
||||
let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_002);
|
||||
|
||||
macro_rules! mac {
|
||||
($e:expr) => {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ fn main() {
|
|||
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => true,
|
||||
_ => false,
|
||||
};
|
||||
let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1 | 2);
|
||||
let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1); // 2 is missing
|
||||
let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_001);
|
||||
let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_002);
|
||||
|
||||
macro_rules! mac {
|
||||
($e:expr) => {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,19 @@ LL | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => true,
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:31:26
|
||||
--> $DIR/manual_range_patterns.rs:28:25
|
||||
|
|
||||
LL | let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1 | 2);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-5..=3`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:30:25
|
||||
|
|
||||
LL | let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_001);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-1000001..=1000001`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:35:26
|
||||
|
|
||||
LL | matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
|
@ -47,5 +59,5 @@ LL | mac!(f);
|
|||
|
|
||||
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
//@run-rustfix
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::BinaryHeap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
|
||||
|
||||
fn main() {
|
||||
binary_heap_retain();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
//@run-rustfix
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::BinaryHeap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
|
||||
|
||||
fn main() {
|
||||
binary_heap_retain();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:51:5
|
||||
--> $DIR/manual_retain.rs:46:5
|
||||
|
|
||||
LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)`
|
||||
|
|
@ -7,13 +7,13 @@ LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect()
|
|||
= note: `-D clippy::manual-retain` implied by `-D warnings`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:52:5
|
||||
--> $DIR/manual_retain.rs:47:5
|
||||
|
|
||||
LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:53:5
|
||||
--> $DIR/manual_retain.rs:48:5
|
||||
|
|
||||
LL | / btree_map = btree_map
|
||||
LL | | .into_iter()
|
||||
|
|
@ -22,37 +22,37 @@ LL | | .collect();
|
|||
| |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:75:5
|
||||
--> $DIR/manual_retain.rs:70:5
|
||||
|
|
||||
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:76:5
|
||||
--> $DIR/manual_retain.rs:71:5
|
||||
|
|
||||
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:77:5
|
||||
--> $DIR/manual_retain.rs:72:5
|
||||
|
|
||||
LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:107:5
|
||||
--> $DIR/manual_retain.rs:102:5
|
||||
|
|
||||
LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:108:5
|
||||
--> $DIR/manual_retain.rs:103:5
|
||||
|
|
||||
LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:109:5
|
||||
--> $DIR/manual_retain.rs:104:5
|
||||
|
|
||||
LL | / hash_map = hash_map
|
||||
LL | | .into_iter()
|
||||
|
|
@ -61,61 +61,61 @@ LL | | .collect();
|
|||
| |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:130:5
|
||||
--> $DIR/manual_retain.rs:125:5
|
||||
|
|
||||
LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:131:5
|
||||
--> $DIR/manual_retain.rs:126:5
|
||||
|
|
||||
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:132:5
|
||||
--> $DIR/manual_retain.rs:127:5
|
||||
|
|
||||
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:161:5
|
||||
--> $DIR/manual_retain.rs:156:5
|
||||
|
|
||||
LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:173:5
|
||||
--> $DIR/manual_retain.rs:168:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:174:5
|
||||
--> $DIR/manual_retain.rs:169:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:175:5
|
||||
--> $DIR/manual_retain.rs:170:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:197:5
|
||||
--> $DIR/manual_retain.rs:192:5
|
||||
|
|
||||
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:198:5
|
||||
--> $DIR/manual_retain.rs:193:5
|
||||
|
|
||||
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:199:5
|
||||
--> $DIR/manual_retain.rs:194:5
|
||||
|
|
||||
LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: manual implementation of `split_once`
|
|||
--> $DIR/manual_split_once.rs:13:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1`
|
||||
|
|
||||
= note: `-D clippy::manual-split-once` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,73 +10,73 @@ error: manual implementation of `split_once`
|
|||
--> $DIR/manual_split_once.rs:14:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').skip(1).next().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:15:18
|
||||
|
|
||||
LL | let (_, _) = "key=value".splitn(2, '=').next_tuple().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=')`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=')`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:18:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:21:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:24:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').skip(1).next().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:27:17
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(1)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=')?.1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:28:17
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').skip(1).next()?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=')?.1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:29:17
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').nth(1)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=')?.0`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:30:17
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').skip(1).next()?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=')?.0`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:38:13
|
||||
|
|
||||
LL | let _ = "key=value".rsplitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".rsplit_once('=').unwrap().0`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').unwrap().0`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:39:18
|
||||
|
|
||||
LL | let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:40:13
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').nth(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=').map(|x| x.0)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=').map(|x| x.0)`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:44:5
|
||||
|
|
@ -182,7 +182,7 @@ error: manual implementation of `split_once`
|
|||
--> $DIR/manual_split_once.rs:141:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:143:5
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: manual implementation of `str::repeat` using iterators
|
|||
--> $DIR/manual_str_repeat.rs:9:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat("test").take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"test".repeat(10)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)`
|
||||
|
|
||||
= note: `-D clippy::manual-str-repeat` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,55 +10,55 @@ error: manual implementation of `str::repeat` using iterators
|
|||
--> $DIR/manual_str_repeat.rs:10:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat('x').take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"x".repeat(10)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"x".repeat(10)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:11:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat('/'').take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"'".repeat(10)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"'".repeat(10)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:12:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat('"').take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"/"".repeat(10)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"/"".repeat(10)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:16:13
|
||||
|
|
||||
LL | let _ = repeat(x).take(count + 2).collect::<String>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count + 2)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count + 2)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:25:21
|
||||
|
|
||||
LL | let _: String = repeat(*x).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(*x).repeat(count)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*x).repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:34:21
|
||||
|
|
||||
LL | let _: String = repeat(x).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:46:21
|
||||
|
|
||||
LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `Cow::Borrowed("test").repeat(count)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Cow::Borrowed("test").repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:49:21
|
||||
|
|
||||
LL | let _: String = repeat(x).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:64:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat("test").take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"test".repeat(10)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
#![warn(clippy::manual_try_fold)]
|
||||
#![feature(try_trait_v2)]
|
||||
|
||||
use std::ops::ControlFlow;
|
||||
use std::ops::FromResidual;
|
||||
use std::ops::Try;
|
||||
use std::ops::{ControlFlow, FromResidual, Try};
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macros;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: usage of `Iterator::fold` on a type that implements `Try`
|
||||
--> $DIR/manual_try_fold.rs:61:10
|
||||
--> $DIR/manual_try_fold.rs:59:10
|
||||
|
|
||||
LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`
|
||||
|
|
@ -7,19 +7,19 @@ LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
|
|||
= note: `-D clippy::manual-try-fold` implied by `-D warnings`
|
||||
|
||||
error: usage of `Iterator::fold` on a type that implements `Try`
|
||||
--> $DIR/manual_try_fold.rs:65:10
|
||||
--> $DIR/manual_try_fold.rs:63:10
|
||||
|
|
||||
LL | .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(..., |sum, i| ...)`
|
||||
|
||||
error: usage of `Iterator::fold` on a type that implements `Try`
|
||||
--> $DIR/manual_try_fold.rs:68:10
|
||||
--> $DIR/manual_try_fold.rs:66:10
|
||||
|
|
||||
LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`
|
||||
|
||||
error: usage of `Iterator::fold` on a type that implements `Try`
|
||||
--> $DIR/manual_try_fold.rs:98:10
|
||||
--> $DIR/manual_try_fold.rs:96:10
|
||||
|
|
||||
LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: `.map().collect()` can be replaced with `.try_for_each()`
|
|||
--> $DIR/map_collect_result_unit.rs:6:17
|
||||
|
|
||||
LL | let _ = (0..3).map(|t| Err(t + 1)).collect::<Result<(), _>>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(0..3).try_for_each(|t| Err(t + 1))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))`
|
||||
|
|
||||
= note: `-D clippy::map-collect-result-unit` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ error: `.map().collect()` can be replaced with `.try_for_each()`
|
|||
--> $DIR/map_collect_result_unit.rs:7:32
|
||||
|
|
||||
LL | let _: Result<(), _> = (0..3).map(|t| Err(t + 1)).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(0..3).try_for_each(|t| Err(t + 1))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be do
|
|||
--> $DIR/map_unwrap_or.rs:99:13
|
||||
|
|
||||
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `res.map_or_else(|_e| 0, |x| x + 1)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or_else(|_e| 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/map_unwrap_or.rs:106:13
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let _ = opt.map(|x| x + 1)
|
|||
| _____________^
|
||||
LL | | // Should lint even though this call is on a separate line.
|
||||
LL | | .unwrap_or_else(|| 0);
|
||||
| |_____________________________^ help: try this: `opt.map_or_else(|| 0, |x| x + 1)`
|
||||
| |_____________________________^ help: try: `opt.map_or_else(|| 0, |x| x + 1)`
|
||||
|
|
||||
= note: `-D clippy::map-unwrap-or` implied by `-D warnings`
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ LL | let _ = res.map(|x| x + 1)
|
|||
| _____________^
|
||||
LL | | // should lint even though this call is on a separate line
|
||||
LL | | .unwrap_or_else(|_e| 0);
|
||||
| |_______________________________^ help: try this: `res.map_or_else(|_e| 0, |x| x + 1)`
|
||||
| |_______________________________^ help: try: `res.map_or_else(|_e| 0, |x| x + 1)`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ fn match_as_ref() {
|
|||
}
|
||||
|
||||
mod issue4437 {
|
||||
use std::{error::Error, fmt, num::ParseIntError};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::num::ParseIntError;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct E {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ fn match_as_ref() {
|
|||
}
|
||||
|
||||
mod issue4437 {
|
||||
use std::{error::Error, fmt, num::ParseIntError};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::num::ParseIntError;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct E {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | let borrowed: Option<&()> = match owned {
|
|||
LL | | None => None,
|
||||
LL | | Some(ref v) => Some(v),
|
||||
LL | | };
|
||||
| |_____^ help: try this: `owned.as_ref()`
|
||||
| |_____^ help: try: `owned.as_ref()`
|
||||
|
|
||||
= note: `-D clippy::match-as-ref` implied by `-D warnings`
|
||||
|
||||
|
|
@ -18,16 +18,16 @@ LL | let borrow_mut: Option<&mut ()> = match mut_owned {
|
|||
LL | | None => None,
|
||||
LL | | Some(ref mut v) => Some(v),
|
||||
LL | | };
|
||||
| |_____^ help: try this: `mut_owned.as_mut()`
|
||||
| |_____^ help: try: `mut_owned.as_mut()`
|
||||
|
||||
error: use `as_ref()` instead
|
||||
--> $DIR/match_as_ref.rs:30:13
|
||||
--> $DIR/match_as_ref.rs:32:13
|
||||
|
|
||||
LL | / match self.source {
|
||||
LL | | Some(ref s) => Some(s),
|
||||
LL | | None => None,
|
||||
LL | | }
|
||||
| |_____________^ help: try this: `self.source.as_ref().map(|x| x as _)`
|
||||
| |_____________^ help: try: `self.source.as_ref().map(|x| x as _)`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | let _y = match x {
|
|||
LL | | Some(0) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `matches!(x, Some(0))`
|
||||
| |_____^ help: try: `matches!(x, Some(0))`
|
||||
|
|
||||
= note: `-D clippy::match-like-matches-macro` implied by `-D warnings`
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ LL | let _w = match x {
|
|||
LL | | Some(_) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `x.is_some()`
|
||||
| |_____^ help: try: `x.is_some()`
|
||||
|
|
||||
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ LL | let _z = match x {
|
|||
LL | | Some(_) => false,
|
||||
LL | | None => true,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `x.is_none()`
|
||||
| |_____^ help: try: `x.is_none()`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:33:15
|
||||
|
|
@ -40,13 +40,13 @@ LL | let _zz = match x {
|
|||
LL | | Some(r) if r == 0 => false,
|
||||
LL | | _ => true,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `!matches!(x, Some(r) if r == 0)`
|
||||
| |_____^ help: try: `!matches!(x, Some(r) if r == 0)`
|
||||
|
||||
error: if let .. else expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:39:16
|
||||
|
|
||||
LL | let _zzz = if let Some(5) = x { true } else { false };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `matches!(x, Some(5))`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(x, Some(5))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:63:20
|
||||
|
|
@ -57,7 +57,7 @@ LL | | E::A(_) => true,
|
|||
LL | | E::B(_) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `matches!(x, E::A(_) | E::B(_))`
|
||||
| |_________^ help: try: `matches!(x, E::A(_) | E::B(_))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:73:20
|
||||
|
|
@ -70,7 +70,7 @@ LL | | }
|
|||
LL | | E::B(_) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `matches!(x, E::A(_) | E::B(_))`
|
||||
| |_________^ help: try: `matches!(x, E::A(_) | E::B(_))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:83:20
|
||||
|
|
@ -81,7 +81,7 @@ LL | | E::B(_) => false,
|
|||
LL | | E::C => false,
|
||||
LL | | _ => true,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `!matches!(x, E::B(_) | E::C)`
|
||||
| |_________^ help: try: `!matches!(x, E::B(_) | E::C)`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:143:18
|
||||
|
|
@ -91,7 +91,7 @@ LL | let _z = match &z {
|
|||
LL | | Some(3) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `matches!(z, Some(3))`
|
||||
| |_________^ help: try: `matches!(z, Some(3))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:152:18
|
||||
|
|
@ -101,7 +101,7 @@ LL | let _z = match &z {
|
|||
LL | | Some(3) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `matches!(&z, Some(3))`
|
||||
| |_________^ help: try: `matches!(&z, Some(3))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:169:21
|
||||
|
|
@ -111,7 +111,7 @@ LL | let _ = match &z {
|
|||
LL | | AnEnum::X => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_____________^ help: try this: `matches!(&z, AnEnum::X)`
|
||||
| |_____________^ help: try: `matches!(&z, AnEnum::X)`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:183:20
|
||||
|
|
@ -121,7 +121,7 @@ LL | let _res = match &val {
|
|||
LL | | &Some(ref _a) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `matches!(&val, &Some(ref _a))`
|
||||
| |_________^ help: try: `matches!(&val, &Some(ref _a))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:195:20
|
||||
|
|
@ -131,7 +131,7 @@ LL | let _res = match &val {
|
|||
LL | | &Some(ref _a) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_________^ help: try this: `matches!(&val, &Some(ref _a))`
|
||||
| |_________^ help: try: `matches!(&val, &Some(ref _a))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:253:14
|
||||
|
|
@ -141,7 +141,7 @@ LL | let _y = match Some(5) {
|
|||
LL | | Some(0) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `matches!(Some(5), Some(0))`
|
||||
| |_____^ help: try: `matches!(Some(5), Some(0))`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: indexing into a vector may panic
|
|||
--> $DIR/match_on_vec_items.rs:10:11
|
||||
|
|
||||
LL | match arr[idx] {
|
||||
| ^^^^^^^^ help: try this: `arr.get(idx)`
|
||||
| ^^^^^^^^ help: try: `arr.get(idx)`
|
||||
|
|
||||
= note: `-D clippy::match-on-vec-items` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,43 +10,43 @@ error: indexing into a vector may panic
|
|||
--> $DIR/match_on_vec_items.rs:17:11
|
||||
|
|
||||
LL | match arr[range] {
|
||||
| ^^^^^^^^^^ help: try this: `arr.get(range)`
|
||||
| ^^^^^^^^^^ help: try: `arr.get(range)`
|
||||
|
||||
error: indexing into a vector may panic
|
||||
--> $DIR/match_on_vec_items.rs:30:11
|
||||
|
|
||||
LL | match arr[idx] {
|
||||
| ^^^^^^^^ help: try this: `arr.get(idx)`
|
||||
| ^^^^^^^^ help: try: `arr.get(idx)`
|
||||
|
||||
error: indexing into a vector may panic
|
||||
--> $DIR/match_on_vec_items.rs:37:11
|
||||
|
|
||||
LL | match arr[range] {
|
||||
| ^^^^^^^^^^ help: try this: `arr.get(range)`
|
||||
| ^^^^^^^^^^ help: try: `arr.get(range)`
|
||||
|
||||
error: indexing into a vector may panic
|
||||
--> $DIR/match_on_vec_items.rs:50:11
|
||||
|
|
||||
LL | match arr[idx] {
|
||||
| ^^^^^^^^ help: try this: `arr.get(idx)`
|
||||
| ^^^^^^^^ help: try: `arr.get(idx)`
|
||||
|
||||
error: indexing into a vector may panic
|
||||
--> $DIR/match_on_vec_items.rs:57:11
|
||||
|
|
||||
LL | match arr[range] {
|
||||
| ^^^^^^^^^^ help: try this: `arr.get(range)`
|
||||
| ^^^^^^^^^^ help: try: `arr.get(range)`
|
||||
|
||||
error: indexing into a vector may panic
|
||||
--> $DIR/match_on_vec_items.rs:70:11
|
||||
|
|
||||
LL | match arr[idx] {
|
||||
| ^^^^^^^^ help: try this: `arr.get(idx)`
|
||||
| ^^^^^^^^ help: try: `arr.get(idx)`
|
||||
|
||||
error: indexing into a vector may panic
|
||||
--> $DIR/match_on_vec_items.rs:77:11
|
||||
|
|
||||
LL | match arr[range] {
|
||||
| ^^^^^^^^^^ help: try this: `arr.get(range)`
|
||||
| ^^^^^^^^^^ help: try: `arr.get(range)`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ error: redundant pattern matching, consider using `is_none()`
|
|||
--> $DIR/match_ref_pats.rs:38:12
|
||||
|
|
||||
LL | if let &None = a {
|
||||
| -------^^^^^---- help: try this: `if a.is_none()`
|
||||
| -------^^^^^---- help: try: `if a.is_none()`
|
||||
|
|
||||
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ error: redundant pattern matching, consider using `is_none()`
|
|||
--> $DIR/match_ref_pats.rs:43:12
|
||||
|
|
||||
LL | if let &None = &b {
|
||||
| -------^^^^^----- help: try this: `if b.is_none()`
|
||||
| -------^^^^^----- help: try: `if b.is_none()`
|
||||
|
||||
error: you don't need to add `&` to all patterns
|
||||
--> $DIR/match_ref_pats.rs:103:9
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ LL | | E::A => false,
|
|||
LL | | E::B => false,
|
||||
LL | | _ => true,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `!matches!(x, E::A | E::B)`
|
||||
| |_____^ help: try: `!matches!(x, E::A | E::B)`
|
||||
|
|
||||
= note: `-D clippy::match-like-matches-macro` implied by `-D warnings`
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: wildcard matches only a single variant and will also match any future add
|
|||
--> $DIR/match_wildcard_for_single_variants.rs:24:13
|
||||
|
|
||||
LL | _ => (),
|
||||
| ^ help: try this: `Self::Rgb(..)`
|
||||
| ^ help: try: `Self::Rgb(..)`
|
||||
|
|
||||
= note: `-D clippy::match-wildcard-for-single-variants` implied by `-D warnings`
|
||||
|
||||
|
|
@ -10,55 +10,55 @@ error: wildcard matches only a single variant and will also match any future add
|
|||
--> $DIR/match_wildcard_for_single_variants.rs:34:9
|
||||
|
|
||||
LL | _ => {},
|
||||
| ^ help: try this: `Foo::C`
|
||||
| ^ help: try: `Foo::C`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:44:9
|
||||
|
|
||||
LL | _ => {},
|
||||
| ^ help: try this: `Color::Blue`
|
||||
| ^ help: try: `Color::Blue`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:52:9
|
||||
|
|
||||
LL | _ => {},
|
||||
| ^ help: try this: `Color::Blue`
|
||||
| ^ help: try: `Color::Blue`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:58:9
|
||||
|
|
||||
LL | _ => {},
|
||||
| ^ help: try this: `Color::Blue`
|
||||
| ^ help: try: `Color::Blue`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:75:9
|
||||
|
|
||||
LL | &_ => (),
|
||||
| ^^ help: try this: `Color::Blue`
|
||||
| ^^ help: try: `Color::Blue`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:84:9
|
||||
|
|
||||
LL | _ => (),
|
||||
| ^ help: try this: `C::Blue`
|
||||
| ^ help: try: `C::Blue`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:91:9
|
||||
|
|
||||
LL | _ => (),
|
||||
| ^ help: try this: `Color::Blue`
|
||||
| ^ help: try: `Color::Blue`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:126:13
|
||||
|
|
||||
LL | _ => (),
|
||||
| ^ help: try this: `Enum::__Private`
|
||||
| ^ help: try: `Enum::__Private`
|
||||
|
||||
error: wildcard matches only a single variant and will also match any future added variants
|
||||
--> $DIR/match_wildcard_for_single_variants.rs:153:13
|
||||
|
|
||||
LL | _ => 2,
|
||||
| ^ help: try this: `Foo::B`
|
||||
| ^ help: try: `Foo::B`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@
|
|||
#[macro_use]
|
||||
extern crate option_helpers;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
||||
use std::ops::Mul;
|
||||
use std::rc::{self, Rc};
|
||||
use std::sync::{self, Arc};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: methods called `new` usually return `Self`
|
||||
--> $DIR/methods.rs:106:5
|
||||
--> $DIR/methods.rs:103:5
|
||||
|
|
||||
LL | / fn new() -> i32 {
|
||||
LL | | 0
|
||||
|
|
@ -9,7 +9,7 @@ LL | | }
|
|||
= note: `-D clippy::new-ret-no-self` implied by `-D warnings`
|
||||
|
||||
error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead
|
||||
--> $DIR/methods.rs:127:13
|
||||
--> $DIR/methods.rs:124:13
|
||||
|
|
||||
LL | let _ = v.iter().filter(|&x| {
|
||||
| _____________^
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: called `filter(..).next()` on an `Iterator`. This is more succinctly expr
|
|||
--> $DIR/methods_fixable.rs:11:13
|
||||
|
|
||||
LL | let _ = v.iter().filter(|&x| *x < 0).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `v.iter().find(|&x| *x < 0)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `v.iter().find(|&x| *x < 0)`
|
||||
|
|
||||
= note: `-D clippy::filter-next` implied by `-D warnings`
|
||||
|
||||
|
|
|
|||
10
tests/ui/methods_unfixable.rs
Normal file
10
tests/ui/methods_unfixable.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#![warn(clippy::filter_next)]
|
||||
|
||||
fn main() {
|
||||
issue10029();
|
||||
}
|
||||
|
||||
pub fn issue10029() {
|
||||
let iter = (0..10);
|
||||
let _ = iter.filter(|_| true).next();
|
||||
}
|
||||
15
tests/ui/methods_unfixable.stderr
Normal file
15
tests/ui/methods_unfixable.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead
|
||||
--> $DIR/methods_unfixable.rs:9:13
|
||||
|
|
||||
LL | let _ = iter.filter(|_| true).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `iter.find(|_| true)`
|
||||
|
|
||||
help: you will also need to make `iter` mutable, because `find` takes `&mut self`
|
||||
--> $DIR/methods_unfixable.rs:8:9
|
||||
|
|
||||
LL | let iter = (0..10);
|
||||
| ^^^^
|
||||
= note: `-D clippy::filter-next` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue