Merge remote-tracking branch 'upstream/master' into rustup
This commit is contained in:
commit
7d42d736c5
195 changed files with 4233 additions and 1076 deletions
|
|
@ -1,7 +1,7 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
#![feature(lint_reasons)]
|
||||
#![deny(clippy::allow_attributes_without_reason)]
|
||||
#![allow(unfulfilled_lint_expectations)]
|
||||
#![allow(unfulfilled_lint_expectations, clippy::duplicated_attributes)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::{external, with_span};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: `allow` attribute without specifying a reason
|
||||
--> tests/ui/allow_attributes_without_reason.rs:4:1
|
||||
|
|
||||
LL | #![allow(unfulfilled_lint_expectations)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #![allow(unfulfilled_lint_expectations, clippy::duplicated_attributes)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: try adding a reason at the end with `, reason = ".."`
|
||||
note: the lint level is defined here
|
||||
|
|
|
|||
|
|
@ -128,6 +128,19 @@ fn ignore_generic_clone<T: Clone>(a: &mut T, b: &T) {
|
|||
*a = b.clone();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.62"]
|
||||
fn msrv_1_62(mut a: String, b: String, c: &str) {
|
||||
a.clone_from(&b);
|
||||
// Should not be linted, as clone_into wasn't stabilized until 1.63
|
||||
a = c.to_owned();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.63"]
|
||||
fn msrv_1_63(mut a: String, b: String, c: &str) {
|
||||
a.clone_from(&b);
|
||||
c.clone_into(&mut a);
|
||||
}
|
||||
|
||||
macro_rules! clone_inside {
|
||||
($a:expr, $b: expr) => {
|
||||
$a = $b.clone();
|
||||
|
|
|
|||
|
|
@ -128,6 +128,19 @@ fn ignore_generic_clone<T: Clone>(a: &mut T, b: &T) {
|
|||
*a = b.clone();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.62"]
|
||||
fn msrv_1_62(mut a: String, b: String, c: &str) {
|
||||
a = b.clone();
|
||||
// Should not be linted, as clone_into wasn't stabilized until 1.63
|
||||
a = c.to_owned();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.63"]
|
||||
fn msrv_1_63(mut a: String, b: String, c: &str) {
|
||||
a = b.clone();
|
||||
a = c.to_owned();
|
||||
}
|
||||
|
||||
macro_rules! clone_inside {
|
||||
($a:expr, $b: expr) => {
|
||||
$a = $b.clone();
|
||||
|
|
|
|||
|
|
@ -67,41 +67,59 @@ error: assigning the result of `Clone::clone()` may be inefficient
|
|||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:133:5
|
||||
|
|
||||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:140:5
|
||||
|
|
||||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:145:5
|
||||
--> tests/ui/assigning_clones.rs:141:5
|
||||
|
|
||||
LL | a = c.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^ help: use `clone_into()`: `c.clone_into(&mut a)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:158:5
|
||||
|
|
||||
LL | *mut_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(mut_string)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:149:5
|
||||
--> tests/ui/assigning_clones.rs:162:5
|
||||
|
|
||||
LL | mut_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut mut_string)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:170:5
|
||||
--> tests/ui/assigning_clones.rs:183:5
|
||||
|
|
||||
LL | **mut_box_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut (*mut_box_string))`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:174:5
|
||||
--> tests/ui/assigning_clones.rs:187:5
|
||||
|
|
||||
LL | **mut_box_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut (*mut_box_string))`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:178:5
|
||||
--> tests/ui/assigning_clones.rs:191:5
|
||||
|
|
||||
LL | *mut_thing = ToOwned::to_owned(ref_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(ref_str, mut_thing)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:182:5
|
||||
--> tests/ui/assigning_clones.rs:195:5
|
||||
|
|
||||
LL | mut_thing = ToOwned::to_owned(ref_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(ref_str, &mut mut_thing)`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use quote::{quote, quote_spanned};
|
|||
use syn::spanned::Spanned;
|
||||
use syn::token::Star;
|
||||
use syn::{
|
||||
parse_macro_input, parse_quote, FnArg, ImplItem, ItemFn, ItemImpl, ItemTrait, Lifetime, Pat, PatIdent, PatType,
|
||||
Signature, TraitItem, Type,
|
||||
parse_macro_input, parse_quote, FnArg, ImplItem, ItemFn, ItemImpl, ItemStruct, ItemTrait, Lifetime, Pat, PatIdent,
|
||||
PatType, Signature, TraitItem, Type, Visibility,
|
||||
};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
|
|
@ -101,9 +101,7 @@ pub fn fake_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let mut item = parse_macro_input!(item as ItemFn);
|
||||
let span = item.block.brace_token.span;
|
||||
|
||||
if item.sig.asyncness.is_some() {
|
||||
item.sig.asyncness = None;
|
||||
}
|
||||
item.sig.asyncness = None;
|
||||
|
||||
let crate_name = quote! { fake_crate };
|
||||
let block = item.block;
|
||||
|
|
@ -128,7 +126,7 @@ pub fn fake_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
|
||||
#[proc_macro_attribute]
|
||||
pub fn fake_desugar_await(_args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let mut async_fn = syn::parse_macro_input!(input as syn::ItemFn);
|
||||
let mut async_fn = parse_macro_input!(input as syn::ItemFn);
|
||||
|
||||
for stmt in &mut async_fn.block.stmts {
|
||||
if let syn::Stmt::Expr(syn::Expr::Match(syn::ExprMatch { expr: scrutinee, .. }), _) = stmt {
|
||||
|
|
@ -145,3 +143,36 @@ pub fn fake_desugar_await(_args: TokenStream, input: TokenStream) -> TokenStream
|
|||
|
||||
quote!(#async_fn).into()
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn rewrite_struct(_args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let mut item_struct = parse_macro_input!(input as syn::ItemStruct);
|
||||
// remove struct attributes including doc comments.
|
||||
item_struct.attrs = vec![];
|
||||
if let Visibility::Public(token) = item_struct.vis {
|
||||
// set vis to `pub(crate)` to trigger `missing_docs_in_private_items` lint.
|
||||
let new_vis: Visibility = syn::parse_quote_spanned!(token.span() => pub(crate));
|
||||
item_struct.vis = new_vis;
|
||||
}
|
||||
if let syn::Fields::Named(fields) = &mut item_struct.fields {
|
||||
for field in &mut fields.named {
|
||||
// remove all attributes from fields as well.
|
||||
field.attrs = vec![];
|
||||
}
|
||||
}
|
||||
|
||||
quote!(#item_struct).into()
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn with_empty_docs(_attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let item = parse_macro_input!(input as syn::Item);
|
||||
let attrs: Vec<syn::Attribute> = vec![];
|
||||
let doc_comment = "";
|
||||
quote! {
|
||||
#(#attrs)*
|
||||
#[doc = #doc_comment]
|
||||
#item
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::await_holding_lock)]
|
||||
#![allow(clippy::readonly_write_lock)]
|
||||
|
||||
// When adding or modifying a test, please do the same for parking_lot::Mutex.
|
||||
mod std_mutex {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:9:13
|
||||
--> tests/ui/await_holding_lock.rs:10:13
|
||||
|
|
||||
LL | let guard = x.lock().unwrap();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:11:15
|
||||
--> tests/ui/await_holding_lock.rs:12:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
|
@ -14,40 +14,40 @@ LL | baz().await
|
|||
= help: to override `-D warnings` add `#[allow(clippy::await_holding_lock)]`
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:25:13
|
||||
--> tests/ui/await_holding_lock.rs:26:13
|
||||
|
|
||||
LL | let guard = x.read().unwrap();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:27:15
|
||||
--> tests/ui/await_holding_lock.rs:28:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:31:13
|
||||
--> tests/ui/await_holding_lock.rs:32:13
|
||||
|
|
||||
LL | let mut guard = x.write().unwrap();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:33:15
|
||||
--> tests/ui/await_holding_lock.rs:34:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:53:13
|
||||
--> tests/ui/await_holding_lock.rs:54:13
|
||||
|
|
||||
LL | let guard = x.lock().unwrap();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:56:28
|
||||
--> tests/ui/await_holding_lock.rs:57:28
|
||||
|
|
||||
LL | let second = baz().await;
|
||||
| ^^^^^
|
||||
|
|
@ -56,79 +56,79 @@ LL | let third = baz().await;
|
|||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:67:17
|
||||
--> tests/ui/await_holding_lock.rs:68:17
|
||||
|
|
||||
LL | let guard = x.lock().unwrap();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:69:19
|
||||
--> tests/ui/await_holding_lock.rs:70:19
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:80:17
|
||||
--> tests/ui/await_holding_lock.rs:81:17
|
||||
|
|
||||
LL | let guard = x.lock().unwrap();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:82:19
|
||||
--> tests/ui/await_holding_lock.rs:83:19
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:93:13
|
||||
--> tests/ui/await_holding_lock.rs:94:13
|
||||
|
|
||||
LL | let guard = x.lock();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:95:15
|
||||
--> tests/ui/await_holding_lock.rs:96:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:109:13
|
||||
--> tests/ui/await_holding_lock.rs:110:13
|
||||
|
|
||||
LL | let guard = x.read();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:111:15
|
||||
--> tests/ui/await_holding_lock.rs:112:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:115:13
|
||||
--> tests/ui/await_holding_lock.rs:116:13
|
||||
|
|
||||
LL | let mut guard = x.write();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:117:15
|
||||
--> tests/ui/await_holding_lock.rs:118:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:137:13
|
||||
--> tests/ui/await_holding_lock.rs:138:13
|
||||
|
|
||||
LL | let guard = x.lock();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:140:28
|
||||
--> tests/ui/await_holding_lock.rs:141:28
|
||||
|
|
||||
LL | let second = baz().await;
|
||||
| ^^^^^
|
||||
|
|
@ -137,40 +137,40 @@ LL | let third = baz().await;
|
|||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:151:17
|
||||
--> tests/ui/await_holding_lock.rs:152:17
|
||||
|
|
||||
LL | let guard = x.lock();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:153:19
|
||||
--> tests/ui/await_holding_lock.rs:154:19
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:164:17
|
||||
--> tests/ui/await_holding_lock.rs:165:17
|
||||
|
|
||||
LL | let guard = x.lock();
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:166:19
|
||||
--> tests/ui/await_holding_lock.rs:167:19
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `MutexGuard` is held across an `await` point
|
||||
--> tests/ui/await_holding_lock.rs:185:9
|
||||
--> tests/ui/await_holding_lock.rs:186:9
|
||||
|
|
||||
LL | let mut guard = x.lock().unwrap();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
|
||||
note: these are all the `await` points this lock is held through
|
||||
--> tests/ui/await_holding_lock.rs:189:11
|
||||
--> tests/ui/await_holding_lock.rs:190:11
|
||||
|
|
||||
LL | baz().await;
|
||||
| ^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(unused, clippy::assertions_on_constants)]
|
||||
#![allow(unused, clippy::assertions_on_constants, clippy::const_is_empty)]
|
||||
#![warn(clippy::bool_assert_comparison)]
|
||||
|
||||
use std::ops::Not;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(unused, clippy::assertions_on_constants)]
|
||||
#![allow(unused, clippy::assertions_on_constants, clippy::const_is_empty)]
|
||||
#![warn(clippy::bool_assert_comparison)]
|
||||
|
||||
use std::ops::Not;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#![allow(dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
type U8 = u8;
|
||||
|
||||
fn main() {
|
||||
// Test clippy::cast_lossless with casts to integer types
|
||||
let _ = u8::from(true);
|
||||
|
|
@ -19,6 +21,8 @@ fn main() {
|
|||
|
||||
// Test with an expression wrapped in parens
|
||||
let _ = u16::from(true | false);
|
||||
|
||||
let _ = U8::from(true);
|
||||
}
|
||||
|
||||
// The lint would suggest using `u32::from(input)` here but the `XX::from` function is not const,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#![allow(dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
type U8 = u8;
|
||||
|
||||
fn main() {
|
||||
// Test clippy::cast_lossless with casts to integer types
|
||||
let _ = true as u8;
|
||||
|
|
@ -19,6 +21,8 @@ fn main() {
|
|||
|
||||
// Test with an expression wrapped in parens
|
||||
let _ = (true | false) as u16;
|
||||
|
||||
let _ = true as U8;
|
||||
}
|
||||
|
||||
// The lint would suggest using `u32::from(input)` here but the `XX::from` function is not const,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:6:13
|
||||
--> tests/ui/cast_lossless_bool.rs:8:13
|
||||
|
|
||||
LL | let _ = true as u8;
|
||||
| ^^^^^^^^^^ help: try: `u8::from(true)`
|
||||
|
|
@ -8,82 +8,88 @@ LL | let _ = true as u8;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]`
|
||||
|
||||
error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:7:13
|
||||
--> tests/ui/cast_lossless_bool.rs:9:13
|
||||
|
|
||||
LL | let _ = true as u16;
|
||||
| ^^^^^^^^^^^ help: try: `u16::from(true)`
|
||||
|
||||
error: casting `bool` to `u32` is more cleanly stated with `u32::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:8:13
|
||||
--> tests/ui/cast_lossless_bool.rs:10:13
|
||||
|
|
||||
LL | let _ = true as u32;
|
||||
| ^^^^^^^^^^^ help: try: `u32::from(true)`
|
||||
|
||||
error: casting `bool` to `u64` is more cleanly stated with `u64::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:9:13
|
||||
--> tests/ui/cast_lossless_bool.rs:11:13
|
||||
|
|
||||
LL | let _ = true as u64;
|
||||
| ^^^^^^^^^^^ help: try: `u64::from(true)`
|
||||
|
||||
error: casting `bool` to `u128` is more cleanly stated with `u128::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:10:13
|
||||
--> tests/ui/cast_lossless_bool.rs:12:13
|
||||
|
|
||||
LL | let _ = true as u128;
|
||||
| ^^^^^^^^^^^^ help: try: `u128::from(true)`
|
||||
|
||||
error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:11:13
|
||||
--> tests/ui/cast_lossless_bool.rs:13:13
|
||||
|
|
||||
LL | let _ = true as usize;
|
||||
| ^^^^^^^^^^^^^ help: try: `usize::from(true)`
|
||||
|
||||
error: casting `bool` to `i8` is more cleanly stated with `i8::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:13:13
|
||||
--> tests/ui/cast_lossless_bool.rs:15:13
|
||||
|
|
||||
LL | let _ = true as i8;
|
||||
| ^^^^^^^^^^ help: try: `i8::from(true)`
|
||||
|
||||
error: casting `bool` to `i16` is more cleanly stated with `i16::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:14:13
|
||||
--> tests/ui/cast_lossless_bool.rs:16:13
|
||||
|
|
||||
LL | let _ = true as i16;
|
||||
| ^^^^^^^^^^^ help: try: `i16::from(true)`
|
||||
|
||||
error: casting `bool` to `i32` is more cleanly stated with `i32::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:15:13
|
||||
--> tests/ui/cast_lossless_bool.rs:17:13
|
||||
|
|
||||
LL | let _ = true as i32;
|
||||
| ^^^^^^^^^^^ help: try: `i32::from(true)`
|
||||
|
||||
error: casting `bool` to `i64` is more cleanly stated with `i64::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:16:13
|
||||
--> tests/ui/cast_lossless_bool.rs:18:13
|
||||
|
|
||||
LL | let _ = true as i64;
|
||||
| ^^^^^^^^^^^ help: try: `i64::from(true)`
|
||||
|
||||
error: casting `bool` to `i128` is more cleanly stated with `i128::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:17:13
|
||||
--> tests/ui/cast_lossless_bool.rs:19:13
|
||||
|
|
||||
LL | let _ = true as i128;
|
||||
| ^^^^^^^^^^^^ help: try: `i128::from(true)`
|
||||
|
||||
error: casting `bool` to `isize` is more cleanly stated with `isize::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:18:13
|
||||
--> tests/ui/cast_lossless_bool.rs:20:13
|
||||
|
|
||||
LL | let _ = true as isize;
|
||||
| ^^^^^^^^^^^^^ help: try: `isize::from(true)`
|
||||
|
||||
error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:21:13
|
||||
--> tests/ui/cast_lossless_bool.rs:23:13
|
||||
|
|
||||
LL | let _ = (true | false) as u16;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)`
|
||||
|
||||
error: casting `bool` to `U8` is more cleanly stated with `U8::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:25:13
|
||||
|
|
||||
LL | let _ = true as U8;
|
||||
| ^^^^^^^^^^ help: try: `U8::from(true)`
|
||||
|
||||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)`
|
||||
--> tests/ui/cast_lossless_bool.rs:49:13
|
||||
--> tests/ui/cast_lossless_bool.rs:53:13
|
||||
|
|
||||
LL | let _ = true as u8;
|
||||
| ^^^^^^^^^^ help: try: `u8::from(true)`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
type F32 = f32;
|
||||
type F64 = f64;
|
||||
|
||||
fn main() {
|
||||
// Test clippy::cast_lossless with casts to floating-point types
|
||||
let x0 = 1i8;
|
||||
let _ = f32::from(x0);
|
||||
let _ = f64::from(x0);
|
||||
let _ = F32::from(x0);
|
||||
let _ = F64::from(x0);
|
||||
let x1 = 1u8;
|
||||
let _ = f32::from(x1);
|
||||
let _ = f64::from(x1);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
type F32 = f32;
|
||||
type F64 = f64;
|
||||
|
||||
fn main() {
|
||||
// Test clippy::cast_lossless with casts to floating-point types
|
||||
let x0 = 1i8;
|
||||
let _ = x0 as f32;
|
||||
let _ = x0 as f64;
|
||||
let _ = x0 as F32;
|
||||
let _ = x0 as F64;
|
||||
let x1 = 1u8;
|
||||
let _ = x1 as f32;
|
||||
let _ = x1 as f64;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: casting `i8` to `f32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:7:13
|
||||
--> tests/ui/cast_lossless_float.rs:10:13
|
||||
|
|
||||
LL | let _ = x0 as f32;
|
||||
| ^^^^^^^^^ help: try: `f32::from(x0)`
|
||||
|
|
@ -8,64 +8,76 @@ LL | let _ = x0 as f32;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]`
|
||||
|
||||
error: casting `i8` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:8:13
|
||||
--> tests/ui/cast_lossless_float.rs:11:13
|
||||
|
|
||||
LL | let _ = x0 as f64;
|
||||
| ^^^^^^^^^ help: try: `f64::from(x0)`
|
||||
|
||||
error: casting `i8` to `F32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:12:13
|
||||
|
|
||||
LL | let _ = x0 as F32;
|
||||
| ^^^^^^^^^ help: try: `F32::from(x0)`
|
||||
|
||||
error: casting `i8` to `F64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:13:13
|
||||
|
|
||||
LL | let _ = x0 as F64;
|
||||
| ^^^^^^^^^ help: try: `F64::from(x0)`
|
||||
|
||||
error: casting `u8` to `f32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:10:13
|
||||
--> tests/ui/cast_lossless_float.rs:15:13
|
||||
|
|
||||
LL | let _ = x1 as f32;
|
||||
| ^^^^^^^^^ help: try: `f32::from(x1)`
|
||||
|
||||
error: casting `u8` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:11:13
|
||||
--> tests/ui/cast_lossless_float.rs:16:13
|
||||
|
|
||||
LL | let _ = x1 as f64;
|
||||
| ^^^^^^^^^ help: try: `f64::from(x1)`
|
||||
|
||||
error: casting `i16` to `f32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:13:13
|
||||
--> tests/ui/cast_lossless_float.rs:18:13
|
||||
|
|
||||
LL | let _ = x2 as f32;
|
||||
| ^^^^^^^^^ help: try: `f32::from(x2)`
|
||||
|
||||
error: casting `i16` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:14:13
|
||||
--> tests/ui/cast_lossless_float.rs:19:13
|
||||
|
|
||||
LL | let _ = x2 as f64;
|
||||
| ^^^^^^^^^ help: try: `f64::from(x2)`
|
||||
|
||||
error: casting `u16` to `f32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:16:13
|
||||
--> tests/ui/cast_lossless_float.rs:21:13
|
||||
|
|
||||
LL | let _ = x3 as f32;
|
||||
| ^^^^^^^^^ help: try: `f32::from(x3)`
|
||||
|
||||
error: casting `u16` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:17:13
|
||||
--> tests/ui/cast_lossless_float.rs:22:13
|
||||
|
|
||||
LL | let _ = x3 as f64;
|
||||
| ^^^^^^^^^ help: try: `f64::from(x3)`
|
||||
|
||||
error: casting `i32` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:19:13
|
||||
--> tests/ui/cast_lossless_float.rs:24:13
|
||||
|
|
||||
LL | let _ = x4 as f64;
|
||||
| ^^^^^^^^^ help: try: `f64::from(x4)`
|
||||
|
||||
error: casting `u32` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:21:13
|
||||
--> tests/ui/cast_lossless_float.rs:26:13
|
||||
|
|
||||
LL | let _ = x5 as f64;
|
||||
| ^^^^^^^^^ help: try: `f64::from(x5)`
|
||||
|
||||
error: casting `f32` to `f64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_float.rs:24:13
|
||||
--> tests/ui/cast_lossless_float.rs:29:13
|
||||
|
|
||||
LL | let _ = 1.0f32 as f64;
|
||||
| ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
type I64 = i64;
|
||||
type U128 = u128;
|
||||
|
||||
fn main() {
|
||||
// Test clippy::cast_lossless with casts to integer types
|
||||
let _ = i16::from(1i8);
|
||||
|
|
@ -24,6 +27,13 @@ fn main() {
|
|||
|
||||
// Test with an expression wrapped in parens
|
||||
let _ = u16::from(1u8 + 1u8);
|
||||
|
||||
let _ = I64::from(1i8);
|
||||
|
||||
// Do not lint if destination type is u128
|
||||
// see https://github.com/rust-lang/rust-clippy/issues/12492
|
||||
let _ = 1u8 as u128;
|
||||
let _ = 1u8 as U128;
|
||||
}
|
||||
|
||||
// The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
type I64 = i64;
|
||||
type U128 = u128;
|
||||
|
||||
fn main() {
|
||||
// Test clippy::cast_lossless with casts to integer types
|
||||
let _ = 1i8 as i16;
|
||||
|
|
@ -24,6 +27,13 @@ fn main() {
|
|||
|
||||
// Test with an expression wrapped in parens
|
||||
let _ = (1u8 + 1u8) as u16;
|
||||
|
||||
let _ = 1i8 as I64;
|
||||
|
||||
// Do not lint if destination type is u128
|
||||
// see https://github.com/rust-lang/rust-clippy/issues/12492
|
||||
let _ = 1u8 as u128;
|
||||
let _ = 1u8 as U128;
|
||||
}
|
||||
|
||||
// The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: casting `i8` to `i16` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:6:13
|
||||
--> tests/ui/cast_lossless_integer.rs:9:13
|
||||
|
|
||||
LL | let _ = 1i8 as i16;
|
||||
| ^^^^^^^^^^ help: try: `i16::from(1i8)`
|
||||
|
|
@ -8,124 +8,130 @@ LL | let _ = 1i8 as i16;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]`
|
||||
|
||||
error: casting `i8` to `i32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:7:13
|
||||
--> tests/ui/cast_lossless_integer.rs:10:13
|
||||
|
|
||||
LL | let _ = 1i8 as i32;
|
||||
| ^^^^^^^^^^ help: try: `i32::from(1i8)`
|
||||
|
||||
error: casting `i8` to `i64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:8:13
|
||||
--> tests/ui/cast_lossless_integer.rs:11:13
|
||||
|
|
||||
LL | let _ = 1i8 as i64;
|
||||
| ^^^^^^^^^^ help: try: `i64::from(1i8)`
|
||||
|
||||
error: casting `u8` to `i16` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:9:13
|
||||
--> tests/ui/cast_lossless_integer.rs:12:13
|
||||
|
|
||||
LL | let _ = 1u8 as i16;
|
||||
| ^^^^^^^^^^ help: try: `i16::from(1u8)`
|
||||
|
||||
error: casting `u8` to `i32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:10:13
|
||||
--> tests/ui/cast_lossless_integer.rs:13:13
|
||||
|
|
||||
LL | let _ = 1u8 as i32;
|
||||
| ^^^^^^^^^^ help: try: `i32::from(1u8)`
|
||||
|
||||
error: casting `u8` to `i64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:11:13
|
||||
--> tests/ui/cast_lossless_integer.rs:14:13
|
||||
|
|
||||
LL | let _ = 1u8 as i64;
|
||||
| ^^^^^^^^^^ help: try: `i64::from(1u8)`
|
||||
|
||||
error: casting `u8` to `u16` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:12:13
|
||||
--> tests/ui/cast_lossless_integer.rs:15:13
|
||||
|
|
||||
LL | let _ = 1u8 as u16;
|
||||
| ^^^^^^^^^^ help: try: `u16::from(1u8)`
|
||||
|
||||
error: casting `u8` to `u32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:13:13
|
||||
--> tests/ui/cast_lossless_integer.rs:16:13
|
||||
|
|
||||
LL | let _ = 1u8 as u32;
|
||||
| ^^^^^^^^^^ help: try: `u32::from(1u8)`
|
||||
|
||||
error: casting `u8` to `u64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:14:13
|
||||
--> tests/ui/cast_lossless_integer.rs:17:13
|
||||
|
|
||||
LL | let _ = 1u8 as u64;
|
||||
| ^^^^^^^^^^ help: try: `u64::from(1u8)`
|
||||
|
||||
error: casting `i16` to `i32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:15:13
|
||||
--> tests/ui/cast_lossless_integer.rs:18:13
|
||||
|
|
||||
LL | let _ = 1i16 as i32;
|
||||
| ^^^^^^^^^^^ help: try: `i32::from(1i16)`
|
||||
|
||||
error: casting `i16` to `i64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:16:13
|
||||
--> tests/ui/cast_lossless_integer.rs:19:13
|
||||
|
|
||||
LL | let _ = 1i16 as i64;
|
||||
| ^^^^^^^^^^^ help: try: `i64::from(1i16)`
|
||||
|
||||
error: casting `u16` to `i32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:17:13
|
||||
--> tests/ui/cast_lossless_integer.rs:20:13
|
||||
|
|
||||
LL | let _ = 1u16 as i32;
|
||||
| ^^^^^^^^^^^ help: try: `i32::from(1u16)`
|
||||
|
||||
error: casting `u16` to `i64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:18:13
|
||||
--> tests/ui/cast_lossless_integer.rs:21:13
|
||||
|
|
||||
LL | let _ = 1u16 as i64;
|
||||
| ^^^^^^^^^^^ help: try: `i64::from(1u16)`
|
||||
|
||||
error: casting `u16` to `u32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:19:13
|
||||
--> tests/ui/cast_lossless_integer.rs:22:13
|
||||
|
|
||||
LL | let _ = 1u16 as u32;
|
||||
| ^^^^^^^^^^^ help: try: `u32::from(1u16)`
|
||||
|
||||
error: casting `u16` to `u64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:20:13
|
||||
--> tests/ui/cast_lossless_integer.rs:23:13
|
||||
|
|
||||
LL | let _ = 1u16 as u64;
|
||||
| ^^^^^^^^^^^ help: try: `u64::from(1u16)`
|
||||
|
||||
error: casting `i32` to `i64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:21:13
|
||||
--> tests/ui/cast_lossless_integer.rs:24:13
|
||||
|
|
||||
LL | let _ = 1i32 as i64;
|
||||
| ^^^^^^^^^^^ help: try: `i64::from(1i32)`
|
||||
|
||||
error: casting `u32` to `i64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:22:13
|
||||
--> tests/ui/cast_lossless_integer.rs:25:13
|
||||
|
|
||||
LL | let _ = 1u32 as i64;
|
||||
| ^^^^^^^^^^^ help: try: `i64::from(1u32)`
|
||||
|
||||
error: casting `u32` to `u64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:23:13
|
||||
--> tests/ui/cast_lossless_integer.rs:26:13
|
||||
|
|
||||
LL | let _ = 1u32 as u64;
|
||||
| ^^^^^^^^^^^ help: try: `u64::from(1u32)`
|
||||
|
||||
error: casting `u8` to `u16` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:26:13
|
||||
--> tests/ui/cast_lossless_integer.rs:29:13
|
||||
|
|
||||
LL | let _ = (1u8 + 1u8) as u16;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)`
|
||||
|
||||
error: casting `i8` to `I64` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:31:13
|
||||
|
|
||||
LL | let _ = 1i8 as I64;
|
||||
| ^^^^^^^^^^ help: try: `I64::from(1i8)`
|
||||
|
||||
error: casting `i8` to `i32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:60:13
|
||||
--> tests/ui/cast_lossless_integer.rs:70:13
|
||||
|
|
||||
LL | let _ = sign_cast!(x, u8, i8) as i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::from(sign_cast!(x, u8, i8))`
|
||||
|
||||
error: casting `i8` to `i32` may become silently lossy if you later change the type
|
||||
--> tests/ui/cast_lossless_integer.rs:61:13
|
||||
--> tests/ui/cast_lossless_integer.rs:71:13
|
||||
|
|
||||
LL | let _ = (sign_cast!(x, u8, i8) + 1) as i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::from(sign_cast!(x, u8, i8) + 1)`
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
|
|
|
|||
174
tests/ui/const_is_empty.rs
Normal file
174
tests/ui/const_is_empty.rs
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
#![feature(inline_const)]
|
||||
#![warn(clippy::const_is_empty)]
|
||||
#![allow(clippy::needless_late_init, unused_must_use)]
|
||||
|
||||
fn test_literal() {
|
||||
if "".is_empty() {
|
||||
//~^ERROR: this expression always evaluates to true
|
||||
}
|
||||
if "foobar".is_empty() {
|
||||
//~^ERROR: this expression always evaluates to false
|
||||
}
|
||||
}
|
||||
|
||||
fn test_byte_literal() {
|
||||
if b"".is_empty() {
|
||||
//~^ERROR: this expression always evaluates to true
|
||||
}
|
||||
if b"foobar".is_empty() {
|
||||
//~^ERROR: this expression always evaluates to false
|
||||
}
|
||||
}
|
||||
|
||||
fn test_no_mut() {
|
||||
let mut empty = "";
|
||||
if empty.is_empty() {
|
||||
// No lint because it is mutable
|
||||
}
|
||||
}
|
||||
|
||||
fn test_propagated() {
|
||||
let empty = "";
|
||||
let non_empty = "foobar";
|
||||
let empty2 = empty;
|
||||
let non_empty2 = non_empty;
|
||||
if empty2.is_empty() {
|
||||
//~^ERROR: this expression always evaluates to true
|
||||
}
|
||||
if non_empty2.is_empty() {
|
||||
//~^ERROR: this expression always evaluates to false
|
||||
}
|
||||
}
|
||||
|
||||
const EMPTY_STR: &str = "";
|
||||
const NON_EMPTY_STR: &str = "foo";
|
||||
const EMPTY_BSTR: &[u8] = b"";
|
||||
const NON_EMPTY_BSTR: &[u8] = b"foo";
|
||||
const EMPTY_U8_SLICE: &[u8] = &[];
|
||||
const NON_EMPTY_U8_SLICE: &[u8] = &[1, 2];
|
||||
const EMPTY_SLICE: &[u32] = &[];
|
||||
const NON_EMPTY_SLICE: &[u32] = &[1, 2];
|
||||
const NON_EMPTY_SLICE_REPEAT: &[u32] = &[1; 2];
|
||||
const EMPTY_ARRAY: [u32; 0] = [];
|
||||
const EMPTY_ARRAY_REPEAT: [u32; 0] = [1; 0];
|
||||
const NON_EMPTY_ARRAY: [u32; 2] = [1, 2];
|
||||
const NON_EMPTY_ARRAY_REPEAT: [u32; 2] = [1; 2];
|
||||
const EMPTY_REF_ARRAY: &[u32; 0] = &[];
|
||||
const NON_EMPTY_REF_ARRAY: &[u32; 3] = &[1, 2, 3];
|
||||
|
||||
fn test_from_const() {
|
||||
let _ = EMPTY_STR.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = NON_EMPTY_STR.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = EMPTY_BSTR.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = NON_EMPTY_BSTR.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = EMPTY_ARRAY.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = EMPTY_ARRAY_REPEAT.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = EMPTY_U8_SLICE.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = NON_EMPTY_U8_SLICE.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = NON_EMPTY_ARRAY.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = NON_EMPTY_ARRAY_REPEAT.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = EMPTY_REF_ARRAY.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = NON_EMPTY_REF_ARRAY.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = EMPTY_SLICE.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = NON_EMPTY_SLICE.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = NON_EMPTY_SLICE_REPEAT.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let value = "foobar";
|
||||
let _ = value.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let x = value;
|
||||
let _ = x.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to false
|
||||
let _ = "".is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
let _ = b"".is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
}
|
||||
|
||||
fn str_from_arg(var: &str) {
|
||||
var.is_empty();
|
||||
// Do not lint, we know nothiny about var
|
||||
}
|
||||
|
||||
fn update_str() {
|
||||
let mut value = "duck";
|
||||
value = "penguin";
|
||||
|
||||
let _ = value.is_empty();
|
||||
// Do not lint since value is mutable
|
||||
}
|
||||
|
||||
fn macros() {
|
||||
// Content from Macro
|
||||
let file = include_str!("const_is_empty.rs");
|
||||
let _ = file.is_empty();
|
||||
// No lint because initializer comes from a macro result
|
||||
|
||||
let var = env!("PATH");
|
||||
let _ = var.is_empty();
|
||||
// No lint because initializer comes from a macro result
|
||||
}
|
||||
|
||||
fn conditional_value() {
|
||||
let value;
|
||||
|
||||
if true {
|
||||
value = "hey";
|
||||
} else {
|
||||
value = "hej";
|
||||
}
|
||||
|
||||
let _ = value.is_empty();
|
||||
// Do not lint, current constant folding is too simple to detect this
|
||||
}
|
||||
|
||||
fn cfg_conditioned() {
|
||||
#[cfg(test)]
|
||||
let val = "";
|
||||
#[cfg(not(test))]
|
||||
let val = "foo";
|
||||
|
||||
let _ = val.is_empty();
|
||||
// Do not lint, value depend on a #[cfg(…)] directive
|
||||
}
|
||||
|
||||
fn not_cfg_conditioned() {
|
||||
let val = "";
|
||||
#[cfg(not(target_os = "inexistent"))]
|
||||
let _ = val.is_empty();
|
||||
//~^ ERROR: this expression always evaluates to true
|
||||
}
|
||||
|
||||
const fn const_rand() -> &'static str {
|
||||
"17"
|
||||
}
|
||||
|
||||
fn const_expressions() {
|
||||
let _ = const { if true { "1" } else { "2" } }.is_empty();
|
||||
// Do not lint, we do not recurse into boolean expressions
|
||||
|
||||
let _ = const_rand().is_empty();
|
||||
// Do not lint, we do not recurse into functions
|
||||
}
|
||||
|
||||
fn constant_from_external_crate() {
|
||||
let _ = std::env::consts::EXE_EXTENSION.is_empty();
|
||||
// Do not lint, `exe_ext` comes from the `std` crate
|
||||
}
|
||||
161
tests/ui/const_is_empty.stderr
Normal file
161
tests/ui/const_is_empty.stderr
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:6:8
|
||||
|
|
||||
LL | if "".is_empty() {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::const-is-empty` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::const_is_empty)]`
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:9:8
|
||||
|
|
||||
LL | if "foobar".is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:15:8
|
||||
|
|
||||
LL | if b"".is_empty() {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:18:8
|
||||
|
|
||||
LL | if b"foobar".is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:35:8
|
||||
|
|
||||
LL | if empty2.is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:38:8
|
||||
|
|
||||
LL | if non_empty2.is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:60:13
|
||||
|
|
||||
LL | let _ = EMPTY_STR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:62:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_STR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:64:13
|
||||
|
|
||||
LL | let _ = EMPTY_BSTR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:66:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_BSTR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:68:13
|
||||
|
|
||||
LL | let _ = EMPTY_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:70:13
|
||||
|
|
||||
LL | let _ = EMPTY_ARRAY_REPEAT.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:72:13
|
||||
|
|
||||
LL | let _ = EMPTY_U8_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:74:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_U8_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:76:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:78:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_ARRAY_REPEAT.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:80:13
|
||||
|
|
||||
LL | let _ = EMPTY_REF_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:82:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_REF_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:84:13
|
||||
|
|
||||
LL | let _ = EMPTY_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:86:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:88:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_SLICE_REPEAT.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:94:13
|
||||
|
|
||||
LL | let _ = value.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:97:13
|
||||
|
|
||||
LL | let _ = x.is_empty();
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:99:13
|
||||
|
|
||||
LL | let _ = "".is_empty();
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:101:13
|
||||
|
|
||||
LL | let _ = b"".is_empty();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:155:13
|
||||
|
|
||||
LL | let _ = val.is_empty();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 26 previous errors
|
||||
|
||||
7
tests/ui/crashes/ice-12491.fixed
Normal file
7
tests/ui/crashes/ice-12491.fixed
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![warn(clippy::needless_return)]
|
||||
|
||||
fn main() {
|
||||
if (true) {
|
||||
// anything一些中文
|
||||
}
|
||||
}
|
||||
8
tests/ui/crashes/ice-12491.rs
Normal file
8
tests/ui/crashes/ice-12491.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![warn(clippy::needless_return)]
|
||||
|
||||
fn main() {
|
||||
if (true) {
|
||||
// anything一些中文
|
||||
return;
|
||||
}
|
||||
}
|
||||
19
tests/ui/crashes/ice-12491.stderr
Normal file
19
tests/ui/crashes/ice-12491.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error: unneeded `return` statement
|
||||
--> tests/ui/crashes/ice-12491.rs:5:24
|
||||
|
|
||||
LL | // anything一些中文
|
||||
| ____________________________^
|
||||
LL | | return;
|
||||
| |______________^
|
||||
|
|
||||
= note: `-D clippy::needless-return` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::needless_return)]`
|
||||
help: remove `return`
|
||||
|
|
||||
LL - // anything一些中文
|
||||
LL - return;
|
||||
LL + // anything一些中文
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
111
tests/ui/dbg_macro/dbg_macro.fixed
Normal file
111
tests/ui/dbg_macro/dbg_macro.fixed
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#![warn(clippy::dbg_macro)]
|
||||
#![allow(clippy::unnecessary_operation, clippy::no_effect)]
|
||||
|
||||
fn foo(n: u32) -> u32 {
|
||||
if let Some(n) = n.checked_sub(4) { n } else { n }
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
fn bar(_: ()) {}
|
||||
|
||||
fn factorial(n: u32) -> u32 {
|
||||
if n <= 1 {
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
1
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
} else {
|
||||
n * factorial(n - 1)
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
42;
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
foo(3) + factorial(4);
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
(1, 2, 3, 4, 5);
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
|
||||
fn issue9914() {
|
||||
macro_rules! foo {
|
||||
($x:expr) => {
|
||||
$x;
|
||||
};
|
||||
}
|
||||
macro_rules! foo2 {
|
||||
($x:expr) => {
|
||||
$x;
|
||||
};
|
||||
}
|
||||
macro_rules! expand_to_dbg {
|
||||
() => {
|
||||
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
#[allow(clippy::let_unit_value)]
|
||||
let _ = ();
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
bar(());
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
foo!(());
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
foo2!(foo!(()));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
expand_to_dbg!();
|
||||
}
|
||||
|
||||
mod issue7274 {
|
||||
trait Thing<'b> {
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
macro_rules! define_thing {
|
||||
($thing:ident, $body:expr) => {
|
||||
impl<'a> Thing<'a> for $thing {
|
||||
fn foo<'b>(&self) {
|
||||
$body
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct MyThing;
|
||||
define_thing!(MyThing, {
|
||||
2;
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn issue8481() {
|
||||
1;
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn foo2() {
|
||||
1;
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod mod1 {
|
||||
fn func() {
|
||||
1;
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
}
|
||||
|
||||
mod issue12131 {
|
||||
fn dbg_in_print(s: &str) {
|
||||
println!("dbg: {:?}", s);
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
print!("{}", s);
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
//@no-rustfix
|
||||
|
||||
#![warn(clippy::dbg_macro)]
|
||||
|
||||
#[path = "auxiliary/submodule.rs"]
|
||||
mod submodule;
|
||||
#![allow(clippy::unnecessary_operation, clippy::no_effect)]
|
||||
|
||||
fn foo(n: u32) -> u32 {
|
||||
if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
|
||||
|
|
@ -25,12 +21,8 @@ fn factorial(n: u32) -> u32 {
|
|||
fn main() {
|
||||
dbg!(42);
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
dbg!(dbg!(dbg!(42)));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
foo(3) + dbg!(factorial(4));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
dbg!(1, 2, dbg!(3, 4));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
dbg!(1, 2, 3, 4, 5);
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
|
|
@ -49,6 +41,7 @@ fn issue9914() {
|
|||
macro_rules! expand_to_dbg {
|
||||
() => {
|
||||
dbg!();
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -107,3 +100,12 @@ mod mod1 {
|
|||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
}
|
||||
|
||||
mod issue12131 {
|
||||
fn dbg_in_print(s: &str) {
|
||||
println!("dbg: {:?}", dbg!(s));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
print!("{}", dbg!(s));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,18 @@
|
|||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/auxiliary/submodule.rs:2:5
|
||||
|
|
||||
LL | dbg!();
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::dbg-macro` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]`
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL - dbg!();
|
||||
LL +
|
||||
|
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:9:22
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:5:22
|
||||
|
|
||||
LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::dbg-macro` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]`
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | if let Some(n) = n.checked_sub(4) { n } else { n }
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:15:8
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:11:8
|
||||
|
|
||||
LL | if dbg!(n <= 1) {
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -35,7 +23,7 @@ LL | if n <= 1 {
|
|||
| ~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:17:9
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:13:9
|
||||
|
|
||||
LL | dbg!(1)
|
||||
| ^^^^^^^
|
||||
|
|
@ -46,7 +34,7 @@ LL | 1
|
|||
|
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:20:9
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:16:9
|
||||
|
|
||||
LL | dbg!(n * factorial(n - 1))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -57,7 +45,7 @@ LL | n * factorial(n - 1)
|
|||
|
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:26:5
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:22:5
|
||||
|
|
||||
LL | dbg!(42);
|
||||
| ^^^^^^^^
|
||||
|
|
@ -68,18 +56,7 @@ LL | 42;
|
|||
| ~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:28:5
|
||||
|
|
||||
LL | dbg!(dbg!(dbg!(42)));
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | dbg!(dbg!(42));
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:30:14
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:24:14
|
||||
|
|
||||
LL | foo(3) + dbg!(factorial(4));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -90,18 +67,7 @@ LL | foo(3) + factorial(4);
|
|||
| ~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:32:5
|
||||
|
|
||||
LL | dbg!(1, 2, dbg!(3, 4));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | (1, 2, dbg!(3, 4));
|
||||
| ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:34:5
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:26:5
|
||||
|
|
||||
LL | dbg!(1, 2, 3, 4, 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -112,7 +78,7 @@ LL | (1, 2, 3, 4, 5);
|
|||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:55:5
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:48:5
|
||||
|
|
||||
LL | dbg!();
|
||||
| ^^^^^^^
|
||||
|
|
@ -124,7 +90,7 @@ LL +
|
|||
|
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:58:13
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:51:13
|
||||
|
|
||||
LL | let _ = dbg!();
|
||||
| ^^^^^^
|
||||
|
|
@ -135,7 +101,7 @@ LL | let _ = ();
|
|||
| ~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:60:9
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:53:9
|
||||
|
|
||||
LL | bar(dbg!());
|
||||
| ^^^^^^
|
||||
|
|
@ -146,7 +112,7 @@ LL | bar(());
|
|||
| ~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:62:10
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:55:10
|
||||
|
|
||||
LL | foo!(dbg!());
|
||||
| ^^^^^^
|
||||
|
|
@ -157,7 +123,7 @@ LL | foo!(());
|
|||
| ~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:64:16
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:57:16
|
||||
|
|
||||
LL | foo2!(foo!(dbg!()));
|
||||
| ^^^^^^
|
||||
|
|
@ -168,7 +134,23 @@ LL | foo2!(foo!(()));
|
|||
| ~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:86:9
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:43:13
|
||||
|
|
||||
LL | dbg!();
|
||||
| ^^^^^^^
|
||||
...
|
||||
LL | expand_to_dbg!();
|
||||
| ---------------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `expand_to_dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL - dbg!();
|
||||
LL +
|
||||
|
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:79:9
|
||||
|
|
||||
LL | dbg!(2);
|
||||
| ^^^^^^^
|
||||
|
|
@ -179,7 +161,7 @@ LL | 2;
|
|||
| ~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:93:5
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:86:5
|
||||
|
|
||||
LL | dbg!(1);
|
||||
| ^^^^^^^
|
||||
|
|
@ -190,7 +172,7 @@ LL | 1;
|
|||
| ~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:99:5
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:92:5
|
||||
|
|
||||
LL | dbg!(1);
|
||||
| ^^^^^^^
|
||||
|
|
@ -201,7 +183,7 @@ LL | 1;
|
|||
| ~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:106:9
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:99:9
|
||||
|
|
||||
LL | dbg!(1);
|
||||
| ^^^^^^^
|
||||
|
|
@ -211,5 +193,27 @@ help: remove the invocation before committing it to a version control system
|
|||
LL | 1;
|
||||
| ~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:106:31
|
||||
|
|
||||
LL | println!("dbg: {:?}", dbg!(s));
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | println!("dbg: {:?}", s);
|
||||
| ~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro.rs:108:22
|
||||
|
|
||||
LL | print!("{}", dbg!(s));
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | print!("{}", s);
|
||||
| ~
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
|
||||
|
|
|
|||
12
tests/ui/dbg_macro/dbg_macro_unfixable.rs
Normal file
12
tests/ui/dbg_macro/dbg_macro_unfixable.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//@no-rustfix
|
||||
#![warn(clippy::dbg_macro)]
|
||||
|
||||
#[path = "auxiliary/submodule.rs"]
|
||||
mod submodule;
|
||||
|
||||
fn main() {
|
||||
dbg!(dbg!(dbg!(42)));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
dbg!(1, 2, dbg!(3, 4));
|
||||
//~^ ERROR: the `dbg!` macro is intended as a debugging tool
|
||||
}
|
||||
71
tests/ui/dbg_macro/dbg_macro_unfixable.stderr
Normal file
71
tests/ui/dbg_macro/dbg_macro_unfixable.stderr
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/auxiliary/submodule.rs:2:5
|
||||
|
|
||||
LL | dbg!();
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::dbg-macro` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]`
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL - dbg!();
|
||||
LL +
|
||||
|
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro_unfixable.rs:8:5
|
||||
|
|
||||
LL | dbg!(dbg!(dbg!(42)));
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | dbg!(dbg!(42));
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro_unfixable.rs:8:10
|
||||
|
|
||||
LL | dbg!(dbg!(dbg!(42)));
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | dbg!(dbg!(42));
|
||||
| ~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro_unfixable.rs:8:15
|
||||
|
|
||||
LL | dbg!(dbg!(dbg!(42)));
|
||||
| ^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | dbg!(dbg!(42));
|
||||
| ~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro_unfixable.rs:10:5
|
||||
|
|
||||
LL | dbg!(1, 2, dbg!(3, 4));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | (1, 2, dbg!(3, 4));
|
||||
| ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: the `dbg!` macro is intended as a debugging tool
|
||||
--> tests/ui/dbg_macro/dbg_macro_unfixable.rs:10:16
|
||||
|
|
||||
LL | dbg!(1, 2, dbg!(3, 4));
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: remove the invocation before committing it to a version control system
|
||||
|
|
||||
LL | dbg!(1, 2, (3, 4));
|
||||
| ~~~~~~
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#![allow(clippy::non_canonical_clone_impl, clippy::non_canonical_partial_ord_impl, 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
|
||||
--> tests/ui/derive.rs:8:1
|
||||
--> tests/ui/derive.rs:7:1
|
||||
|
|
||||
LL | / impl Clone for Qux {
|
||||
LL | |
|
||||
|
|
@ -10,7 +10,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> tests/ui/derive.rs:8:1
|
||||
--> tests/ui/derive.rs:7:1
|
||||
|
|
||||
LL | / impl Clone for Qux {
|
||||
LL | |
|
||||
|
|
@ -23,7 +23,7 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::expl_impl_clone_on_copy)]`
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> tests/ui/derive.rs:33:1
|
||||
--> tests/ui/derive.rs:32:1
|
||||
|
|
||||
LL | / impl<'a> Clone for Lt<'a> {
|
||||
LL | |
|
||||
|
|
@ -34,7 +34,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> tests/ui/derive.rs:33:1
|
||||
--> tests/ui/derive.rs:32:1
|
||||
|
|
||||
LL | / impl<'a> Clone for Lt<'a> {
|
||||
LL | |
|
||||
|
|
@ -45,7 +45,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> tests/ui/derive.rs:45:1
|
||||
--> tests/ui/derive.rs:44:1
|
||||
|
|
||||
LL | / impl Clone for BigArray {
|
||||
LL | |
|
||||
|
|
@ -56,7 +56,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> tests/ui/derive.rs:45:1
|
||||
--> tests/ui/derive.rs:44:1
|
||||
|
|
||||
LL | / impl Clone for BigArray {
|
||||
LL | |
|
||||
|
|
@ -67,7 +67,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> tests/ui/derive.rs:57:1
|
||||
--> tests/ui/derive.rs:56:1
|
||||
|
|
||||
LL | / impl Clone for FnPtr {
|
||||
LL | |
|
||||
|
|
@ -78,7 +78,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> tests/ui/derive.rs:57:1
|
||||
--> tests/ui/derive.rs:56:1
|
||||
|
|
||||
LL | / impl Clone for FnPtr {
|
||||
LL | |
|
||||
|
|
@ -89,7 +89,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
--> tests/ui/derive.rs:78:1
|
||||
--> tests/ui/derive.rs:77:1
|
||||
|
|
||||
LL | / impl<T: Clone> Clone for Generic2<T> {
|
||||
LL | |
|
||||
|
|
@ -100,7 +100,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
note: consider deriving `Clone` or removing `Copy`
|
||||
--> tests/ui/derive.rs:78:1
|
||||
--> tests/ui/derive.rs:77:1
|
||||
|
|
||||
LL | / impl<T: Clone> Clone for Generic2<T> {
|
||||
LL | |
|
||||
|
|
|
|||
12
tests/ui/doc/issue_10262.fixed
Normal file
12
tests/ui/doc/issue_10262.fixed
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#![warn(clippy::doc_markdown)]
|
||||
|
||||
// Should only warn for the first line!
|
||||
/// `AviSynth` documentation:
|
||||
//~^ ERROR: item in documentation is missing backticks
|
||||
///
|
||||
/// > AvisynthPluginInit3 may be called more than once with different IScriptEnvironments.
|
||||
///
|
||||
/// <blockquote>bla AvisynthPluginInit3 bla</blockquote>
|
||||
///
|
||||
/// <q>bla AvisynthPluginInit3 bla</q>
|
||||
pub struct Foo;
|
||||
12
tests/ui/doc/issue_10262.rs
Normal file
12
tests/ui/doc/issue_10262.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#![warn(clippy::doc_markdown)]
|
||||
|
||||
// Should only warn for the first line!
|
||||
/// AviSynth documentation:
|
||||
//~^ ERROR: item in documentation is missing backticks
|
||||
///
|
||||
/// > AvisynthPluginInit3 may be called more than once with different IScriptEnvironments.
|
||||
///
|
||||
/// <blockquote>bla AvisynthPluginInit3 bla</blockquote>
|
||||
///
|
||||
/// <q>bla AvisynthPluginInit3 bla</q>
|
||||
pub struct Foo;
|
||||
15
tests/ui/doc/issue_10262.stderr
Normal file
15
tests/ui/doc/issue_10262.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error: item in documentation is missing backticks
|
||||
--> tests/ui/doc/issue_10262.rs:4:5
|
||||
|
|
||||
LL | /// AviSynth documentation:
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::doc-markdown` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
|
||||
help: try
|
||||
|
|
||||
LL | /// `AviSynth` documentation:
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
17
tests/ui/duplicated_attributes.rs
Normal file
17
tests/ui/duplicated_attributes.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#![warn(clippy::duplicated_attributes)]
|
||||
#![cfg(any(unix, windows))]
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code)] //~ ERROR: duplicated attribute
|
||||
#![cfg(any(unix, windows))]
|
||||
//~^ ERROR: duplicated attribute
|
||||
//~| ERROR: duplicated attribute
|
||||
|
||||
#[cfg(any(unix, windows, target_os = "linux"))]
|
||||
#[allow(dead_code)]
|
||||
#[allow(dead_code)] //~ ERROR: duplicated attribute
|
||||
#[cfg(any(unix, windows, target_os = "linux"))]
|
||||
//~^ ERROR: duplicated attribute
|
||||
//~| ERROR: duplicated attribute
|
||||
fn foo() {}
|
||||
|
||||
fn main() {}
|
||||
123
tests/ui/duplicated_attributes.stderr
Normal file
123
tests/ui/duplicated_attributes.stderr
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:4:10
|
||||
|
|
||||
LL | #![allow(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:3:10
|
||||
|
|
||||
LL | #![allow(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:4:10
|
||||
|
|
||||
LL | #![allow(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
= note: `-D clippy::duplicated-attributes` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::duplicated_attributes)]`
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:5:12
|
||||
|
|
||||
LL | #![cfg(any(unix, windows))]
|
||||
| ^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:2:12
|
||||
|
|
||||
LL | #![cfg(any(unix, windows))]
|
||||
| ^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:5:12
|
||||
|
|
||||
LL | #![cfg(any(unix, windows))]
|
||||
| ^^^^
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:5:18
|
||||
|
|
||||
LL | #![cfg(any(unix, windows))]
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:2:18
|
||||
|
|
||||
LL | #![cfg(any(unix, windows))]
|
||||
| ^^^^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:5:18
|
||||
|
|
||||
LL | #![cfg(any(unix, windows))]
|
||||
| ^^^^^^^
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:11:9
|
||||
|
|
||||
LL | #[allow(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:10:9
|
||||
|
|
||||
LL | #[allow(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:11:9
|
||||
|
|
||||
LL | #[allow(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:12:11
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:9:11
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:12:11
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:12:17
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:9:17
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:12:17
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^^^^
|
||||
|
||||
error: duplicated attribute
|
||||
--> tests/ui/duplicated_attributes.rs:12:26
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first defined here
|
||||
--> tests/ui/duplicated_attributes.rs:9:26
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: remove this attribute
|
||||
--> tests/ui/duplicated_attributes.rs:12:26
|
||||
|
|
||||
LL | #[cfg(any(unix, windows, target_os = "linux"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::all)]
|
||||
#![warn(clippy::else_if_without_else)]
|
||||
#![allow(clippy::collapsible_else_if)]
|
||||
|
||||
fn bla1() -> bool {
|
||||
unimplemented!()
|
||||
|
|
@ -12,6 +10,12 @@ fn bla2() -> bool {
|
|||
fn bla3() -> bool {
|
||||
unimplemented!()
|
||||
}
|
||||
fn bla4() -> bool {
|
||||
unimplemented!()
|
||||
}
|
||||
fn bla5() -> bool {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if bla1() {
|
||||
|
|
@ -57,4 +61,62 @@ fn main() {
|
|||
//~^ ERROR: `if` expression with an `else if`, but without a final `else`
|
||||
println!("else if 2");
|
||||
}
|
||||
|
||||
if bla1() {
|
||||
println!("if");
|
||||
} else if bla2() {
|
||||
println!("else if 1");
|
||||
} else if bla3() {
|
||||
println!("else if 2");
|
||||
} else if bla4() {
|
||||
println!("else if 3");
|
||||
} else if bla5() {
|
||||
println!("else if 4");
|
||||
} else {
|
||||
println!("else");
|
||||
}
|
||||
|
||||
if bla1() {
|
||||
println!("if");
|
||||
} else if bla2() {
|
||||
println!("else if 1");
|
||||
} else if bla3() {
|
||||
println!("else if 2");
|
||||
} else if bla4() {
|
||||
println!("else if 3");
|
||||
} else if bla5() {
|
||||
//~^ ERROR: `if` expression with an `else if`, but without a final `else`
|
||||
println!("else if 4");
|
||||
}
|
||||
|
||||
if bla1() {
|
||||
println!("if");
|
||||
} else if bla2() {
|
||||
println!("else if 1");
|
||||
} else {
|
||||
if bla3() {
|
||||
println!("else if 2");
|
||||
} else if bla4() {
|
||||
println!("else if 3");
|
||||
} else if bla5() {
|
||||
println!("else if 4");
|
||||
} else {
|
||||
println!("else");
|
||||
}
|
||||
}
|
||||
|
||||
if bla1() {
|
||||
println!("if");
|
||||
} else if bla2() {
|
||||
println!("else if 1");
|
||||
} else {
|
||||
if bla3() {
|
||||
println!("else if 2");
|
||||
} else if bla4() {
|
||||
println!("else if 3");
|
||||
} else if bla5() {
|
||||
//~^ ERROR: `if` expression with an `else if`, but without a final `else`
|
||||
println!("else if 4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: `if` expression with an `else if`, but without a final `else`
|
||||
--> tests/ui/else_if_without_else.rs:47:12
|
||||
--> tests/ui/else_if_without_else.rs:51:12
|
||||
|
|
||||
LL | } else if bla2() {
|
||||
| ____________^
|
||||
|
|
@ -13,7 +13,7 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::else_if_without_else)]`
|
||||
|
||||
error: `if` expression with an `else if`, but without a final `else`
|
||||
--> tests/ui/else_if_without_else.rs:56:12
|
||||
--> tests/ui/else_if_without_else.rs:60:12
|
||||
|
|
||||
LL | } else if bla3() {
|
||||
| ____________^
|
||||
|
|
@ -24,5 +24,29 @@ LL | | }
|
|||
|
|
||||
= help: add an `else` block here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: `if` expression with an `else if`, but without a final `else`
|
||||
--> tests/ui/else_if_without_else.rs:87:12
|
||||
|
|
||||
LL | } else if bla5() {
|
||||
| ____________^
|
||||
LL | |
|
||||
LL | | println!("else if 4");
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: add an `else` block here
|
||||
|
||||
error: `if` expression with an `else if`, but without a final `else`
|
||||
--> tests/ui/else_if_without_else.rs:117:16
|
||||
|
|
||||
LL | } else if bla5() {
|
||||
| ________________^
|
||||
LL | |
|
||||
LL | | println!("else if 4");
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: add an `else` block here
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
//@aux-build:proc_macro_attr.rs
|
||||
|
||||
#![allow(unused)]
|
||||
#![warn(clippy::empty_docs)]
|
||||
#![allow(clippy::mixed_attributes_style)]
|
||||
#![feature(extern_types)]
|
||||
|
||||
mod outer {
|
||||
//!
|
||||
|
|
@ -67,3 +70,17 @@ mod outer {
|
|||
y: i32,
|
||||
}
|
||||
}
|
||||
|
||||
mod issue_12377 {
|
||||
use proc_macro_attr::with_empty_docs;
|
||||
|
||||
#[with_empty_docs]
|
||||
extern "C" {
|
||||
type Test;
|
||||
}
|
||||
|
||||
#[with_empty_docs]
|
||||
struct Foo {
|
||||
a: u8,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:6:5
|
||||
--> tests/ui/empty_docs.rs:9:5
|
||||
|
|
||||
LL | //!
|
||||
| ^^^
|
||||
|
|
@ -9,7 +9,7 @@ LL | //!
|
|||
= help: to override `-D warnings` add `#[allow(clippy::empty_docs)]`
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:14:5
|
||||
--> tests/ui/empty_docs.rs:17:5
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:16:9
|
||||
--> tests/ui/empty_docs.rs:19:9
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:27:5
|
||||
--> tests/ui/empty_docs.rs:30:5
|
||||
|
|
||||
LL | #[doc = ""]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | #[doc = ""]
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:30:5
|
||||
--> tests/ui/empty_docs.rs:33:5
|
||||
|
|
||||
LL | / #[doc = ""]
|
||||
LL | | #[doc = ""]
|
||||
|
|
@ -42,7 +42,7 @@ LL | | #[doc = ""]
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:37:5
|
||||
--> tests/ui/empty_docs.rs:40:5
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -50,7 +50,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:50:13
|
||||
--> tests/ui/empty_docs.rs:53:13
|
||||
|
|
||||
LL | /*! */
|
||||
| ^^^^^^
|
||||
|
|
@ -58,7 +58,7 @@ LL | /*! */
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:58:13
|
||||
--> tests/ui/empty_docs.rs:61:13
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -66,7 +66,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:66:9
|
||||
--> tests/ui/empty_docs.rs:69:9
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@aux-build:proc_macro_attr.rs
|
||||
#![warn(clippy::empty_line_after_doc_comments)]
|
||||
#![allow(clippy::assertions_on_constants)]
|
||||
#![allow(clippy::assertions_on_constants, clippy::duplicated_attributes)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![rustfmt::skip]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@aux-build:proc_macro_attr.rs
|
||||
#![warn(clippy::empty_line_after_outer_attr)]
|
||||
#![allow(clippy::assertions_on_constants)]
|
||||
#![allow(clippy::assertions_on_constants, clippy::duplicated_attributes)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![rustfmt::skip]
|
||||
|
||||
|
|
|
|||
|
|
@ -176,4 +176,14 @@ pub fn issue_11935() {
|
|||
}
|
||||
}
|
||||
|
||||
fn issue12489(map: &mut HashMap<u64, u64>) -> Option<()> {
|
||||
if let std::collections::hash_map::Entry::Vacant(e) = map.entry(1) {
|
||||
let Some(1) = Some(2) else {
|
||||
return None;
|
||||
};
|
||||
e.insert(42);
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -180,4 +180,14 @@ pub fn issue_11935() {
|
|||
}
|
||||
}
|
||||
|
||||
fn issue12489(map: &mut HashMap<u64, u64>) -> Option<()> {
|
||||
if !map.contains_key(&1) {
|
||||
let Some(1) = Some(2) else {
|
||||
return None;
|
||||
};
|
||||
map.insert(1, 42);
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -214,5 +214,26 @@ LL + v
|
|||
LL + });
|
||||
|
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
--> tests/ui/entry.rs:184:5
|
||||
|
|
||||
LL | / if !map.contains_key(&1) {
|
||||
LL | | let Some(1) = Some(2) else {
|
||||
LL | | return None;
|
||||
LL | | };
|
||||
LL | | map.insert(1, 42);
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL ~ if let std::collections::hash_map::Entry::Vacant(e) = map.entry(1) {
|
||||
LL + let Some(1) = Some(2) else {
|
||||
LL + return None;
|
||||
LL + };
|
||||
LL + e.insert(42);
|
||||
LL + }
|
||||
|
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
41
tests/ui/integer_division_remainder_used.rs
Normal file
41
tests/ui/integer_division_remainder_used.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#![warn(clippy::integer_division_remainder_used)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(clippy::op_ref)]
|
||||
|
||||
struct CustomOps(pub i32);
|
||||
impl std::ops::Div for CustomOps {
|
||||
type Output = Self;
|
||||
|
||||
fn div(self, rhs: Self) -> Self::Output {
|
||||
Self(self.0 / rhs.0)
|
||||
}
|
||||
}
|
||||
impl std::ops::Rem for CustomOps {
|
||||
type Output = Self;
|
||||
|
||||
fn rem(self, rhs: Self) -> Self::Output {
|
||||
Self(self.0 % rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// should trigger
|
||||
let a = 10;
|
||||
let b = 5;
|
||||
let c = a / b;
|
||||
let d = a % b;
|
||||
let e = &a / b;
|
||||
let f = a % &b;
|
||||
let g = &a / &b;
|
||||
let h = &10 % b;
|
||||
let i = a / &4;
|
||||
|
||||
// should not trigger on custom Div and Rem
|
||||
let w = CustomOps(3);
|
||||
let x = CustomOps(4);
|
||||
let y = w / x;
|
||||
|
||||
let w = CustomOps(3);
|
||||
let x = CustomOps(4);
|
||||
let z = w % x;
|
||||
}
|
||||
59
tests/ui/integer_division_remainder_used.stderr
Normal file
59
tests/ui/integer_division_remainder_used.stderr
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
error: use of / has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:10:14
|
||||
|
|
||||
LL | Self(self.0 / rhs.0)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::integer-division-remainder-used` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::integer_division_remainder_used)]`
|
||||
|
||||
error: use of % has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:17:14
|
||||
|
|
||||
LL | Self(self.0 % rhs.0)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: use of / has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:25:13
|
||||
|
|
||||
LL | let c = a / b;
|
||||
| ^^^^^
|
||||
|
||||
error: use of % has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:26:13
|
||||
|
|
||||
LL | let d = a % b;
|
||||
| ^^^^^
|
||||
|
||||
error: use of / has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:27:13
|
||||
|
|
||||
LL | let e = &a / b;
|
||||
| ^^^^^^
|
||||
|
||||
error: use of % has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:28:13
|
||||
|
|
||||
LL | let f = a % &b;
|
||||
| ^^^^^^
|
||||
|
||||
error: use of / has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:29:13
|
||||
|
|
||||
LL | let g = &a / &b;
|
||||
| ^^^^^^^
|
||||
|
||||
error: use of % has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:30:13
|
||||
|
|
||||
LL | let h = &10 % b;
|
||||
| ^^^^^^^
|
||||
|
||||
error: use of / has been disallowed in this context
|
||||
--> tests/ui/integer_division_remainder_used.rs:31:13
|
||||
|
|
||||
LL | let i = a / &4;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
60
tests/ui/iter_nth.fixed
Normal file
60
tests/ui/iter_nth.fixed
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
//@aux-build:option_helpers.rs
|
||||
|
||||
#![warn(clippy::iter_nth)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate option_helpers;
|
||||
|
||||
use option_helpers::IteratorFalsePositives;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
/// Struct to generate false positives for things with `.iter()`.
|
||||
#[derive(Copy, Clone)]
|
||||
struct HasIter;
|
||||
|
||||
impl HasIter {
|
||||
fn iter(self) -> IteratorFalsePositives {
|
||||
IteratorFalsePositives { foo: 0 }
|
||||
}
|
||||
|
||||
fn iter_mut(self) -> IteratorFalsePositives {
|
||||
IteratorFalsePositives { foo: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks implementation of `ITER_NTH` lint.
|
||||
fn iter_nth() {
|
||||
let mut some_vec = vec![0, 1, 2, 3];
|
||||
let mut boxed_slice: Box<[u8]> = Box::new([0, 1, 2, 3]);
|
||||
let mut some_vec_deque: VecDeque<_> = some_vec.iter().cloned().collect();
|
||||
|
||||
{
|
||||
// Make sure we lint `.iter()` for relevant types.
|
||||
let bad_vec = some_vec.get(3);
|
||||
let bad_slice = &some_vec[..].get(3);
|
||||
let bad_boxed_slice = boxed_slice.get(3);
|
||||
let bad_vec_deque = some_vec_deque.get(3);
|
||||
}
|
||||
|
||||
{
|
||||
// Make sure we lint `.iter_mut()` for relevant types.
|
||||
let bad_vec = some_vec.get_mut(3);
|
||||
}
|
||||
{
|
||||
let bad_slice = &some_vec[..].get_mut(3);
|
||||
}
|
||||
{
|
||||
let bad_vec_deque = some_vec_deque.get_mut(3);
|
||||
}
|
||||
|
||||
let vec_ref = &Vec::<String>::new();
|
||||
vec_ref.get(3);
|
||||
|
||||
// Make sure we don't lint for non-relevant types.
|
||||
let false_positive = HasIter;
|
||||
let ok = false_positive.iter().nth(3);
|
||||
let ok_mut = false_positive.iter_mut().nth(3);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -48,6 +48,9 @@ fn iter_nth() {
|
|||
let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
|
||||
}
|
||||
|
||||
let vec_ref = &Vec::<String>::new();
|
||||
vec_ref.iter().nth(3);
|
||||
|
||||
// Make sure we don't lint for non-relevant types.
|
||||
let false_positive = HasIter;
|
||||
let ok = false_positive.iter().nth(3);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@ error: called `.iter().nth()` on a `Vec`
|
|||
LL | let bad_vec = some_vec.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get()` is both faster and more readable
|
||||
= note: `-D clippy::iter-nth` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::iter_nth)]`
|
||||
help: `get` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_vec = some_vec.get(3);
|
||||
| ~~~
|
||||
|
||||
error: called `.iter().nth()` on a slice
|
||||
--> tests/ui/iter_nth.rs:35:26
|
||||
|
|
@ -14,7 +17,10 @@ error: called `.iter().nth()` on a slice
|
|||
LL | let bad_slice = &some_vec[..].iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get()` is both faster and more readable
|
||||
help: `get` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_slice = &some_vec[..].get(3);
|
||||
| ~~~
|
||||
|
||||
error: called `.iter().nth()` on a slice
|
||||
--> tests/ui/iter_nth.rs:36:31
|
||||
|
|
@ -22,7 +28,10 @@ error: called `.iter().nth()` on a slice
|
|||
LL | let bad_boxed_slice = boxed_slice.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get()` is both faster and more readable
|
||||
help: `get` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_boxed_slice = boxed_slice.get(3);
|
||||
| ~~~
|
||||
|
||||
error: called `.iter().nth()` on a `VecDeque`
|
||||
--> tests/ui/iter_nth.rs:37:29
|
||||
|
|
@ -30,7 +39,10 @@ error: called `.iter().nth()` on a `VecDeque`
|
|||
LL | let bad_vec_deque = some_vec_deque.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get()` is both faster and more readable
|
||||
help: `get` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_vec_deque = some_vec_deque.get(3);
|
||||
| ~~~
|
||||
|
||||
error: called `.iter_mut().nth()` on a `Vec`
|
||||
--> tests/ui/iter_nth.rs:42:23
|
||||
|
|
@ -38,7 +50,10 @@ error: called `.iter_mut().nth()` on a `Vec`
|
|||
LL | let bad_vec = some_vec.iter_mut().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get_mut()` is both faster and more readable
|
||||
help: `get_mut` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_vec = some_vec.get_mut(3);
|
||||
| ~~~~~~~
|
||||
|
||||
error: called `.iter_mut().nth()` on a slice
|
||||
--> tests/ui/iter_nth.rs:45:26
|
||||
|
|
@ -46,7 +61,10 @@ error: called `.iter_mut().nth()` on a slice
|
|||
LL | let bad_slice = &some_vec[..].iter_mut().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get_mut()` is both faster and more readable
|
||||
help: `get_mut` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_slice = &some_vec[..].get_mut(3);
|
||||
| ~~~~~~~
|
||||
|
||||
error: called `.iter_mut().nth()` on a `VecDeque`
|
||||
--> tests/ui/iter_nth.rs:48:29
|
||||
|
|
@ -54,7 +72,21 @@ error: called `.iter_mut().nth()` on a `VecDeque`
|
|||
LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: calling `.get_mut()` is both faster and more readable
|
||||
help: `get_mut` is equivalent but more concise
|
||||
|
|
||||
LL | let bad_vec_deque = some_vec_deque.get_mut(3);
|
||||
| ~~~~~~~
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: called `.iter().nth()` on a `Vec`
|
||||
--> tests/ui/iter_nth.rs:52:5
|
||||
|
|
||||
LL | vec_ref.iter().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: `get` is equivalent but more concise
|
||||
|
|
||||
LL | vec_ref.get(3);
|
||||
| ~~~
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
#![warn(clippy::len_zero)]
|
||||
#![allow(dead_code, unused, clippy::needless_if, clippy::len_without_is_empty)]
|
||||
#![allow(
|
||||
dead_code,
|
||||
unused,
|
||||
clippy::needless_if,
|
||||
clippy::len_without_is_empty,
|
||||
clippy::const_is_empty
|
||||
)]
|
||||
|
||||
extern crate core;
|
||||
use core::ops::Deref;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
#![warn(clippy::len_zero)]
|
||||
#![allow(dead_code, unused, clippy::needless_if, clippy::len_without_is_empty)]
|
||||
#![allow(
|
||||
dead_code,
|
||||
unused,
|
||||
clippy::needless_if,
|
||||
clippy::len_without_is_empty,
|
||||
clippy::const_is_empty
|
||||
)]
|
||||
|
||||
extern crate core;
|
||||
use core::ops::Deref;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:82:8
|
||||
--> tests/ui/len_zero.rs:88:8
|
||||
|
|
||||
LL | if x.len() == 0 {
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()`
|
||||
|
|
@ -8,13 +8,13 @@ LL | if x.len() == 0 {
|
|||
= help: to override `-D warnings` add `#[allow(clippy::len_zero)]`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:86:8
|
||||
--> tests/ui/len_zero.rs:92:8
|
||||
|
|
||||
LL | if "".len() == 0 {}
|
||||
| ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:95:20
|
||||
--> tests/ui/len_zero.rs:101:20
|
||||
|
|
||||
LL | println!("{}", *s1 == "");
|
||||
| ^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s1.is_empty()`
|
||||
|
|
@ -23,121 +23,121 @@ LL | println!("{}", *s1 == "");
|
|||
= help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:96:20
|
||||
--> tests/ui/len_zero.rs:102:20
|
||||
|
|
||||
LL | println!("{}", **s2 == "");
|
||||
| ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s2.is_empty()`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:97:20
|
||||
--> tests/ui/len_zero.rs:103:20
|
||||
|
|
||||
LL | println!("{}", ***s3 == "");
|
||||
| ^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s3.is_empty()`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:98:20
|
||||
--> tests/ui/len_zero.rs:104:20
|
||||
|
|
||||
LL | println!("{}", ****s4 == "");
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s4.is_empty()`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:99:20
|
||||
--> tests/ui/len_zero.rs:105:20
|
||||
|
|
||||
LL | println!("{}", *****s5 == "");
|
||||
| ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s5.is_empty()`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:100:20
|
||||
--> tests/ui/len_zero.rs:106:20
|
||||
|
|
||||
LL | println!("{}", ******(s6) == "");
|
||||
| ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(s6).is_empty()`
|
||||
|
||||
error: comparison to empty slice
|
||||
--> tests/ui/len_zero.rs:103:20
|
||||
--> tests/ui/len_zero.rs:109:20
|
||||
|
|
||||
LL | println!("{}", &**d2s == "");
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(**d2s).is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:118:8
|
||||
--> tests/ui/len_zero.rs:124:8
|
||||
|
|
||||
LL | if has_is_empty.len() == 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:121:8
|
||||
--> tests/ui/len_zero.rs:127:8
|
||||
|
|
||||
LL | if has_is_empty.len() != 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:124:8
|
||||
--> tests/ui/len_zero.rs:130:8
|
||||
|
|
||||
LL | if has_is_empty.len() > 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to one
|
||||
--> tests/ui/len_zero.rs:127:8
|
||||
--> tests/ui/len_zero.rs:133:8
|
||||
|
|
||||
LL | if has_is_empty.len() < 1 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to one
|
||||
--> tests/ui/len_zero.rs:130:8
|
||||
--> tests/ui/len_zero.rs:136:8
|
||||
|
|
||||
LL | if has_is_empty.len() >= 1 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:141:8
|
||||
--> tests/ui/len_zero.rs:147:8
|
||||
|
|
||||
LL | if 0 == has_is_empty.len() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:144:8
|
||||
--> tests/ui/len_zero.rs:150:8
|
||||
|
|
||||
LL | if 0 != has_is_empty.len() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:147:8
|
||||
--> tests/ui/len_zero.rs:153:8
|
||||
|
|
||||
LL | if 0 < has_is_empty.len() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to one
|
||||
--> tests/ui/len_zero.rs:150:8
|
||||
--> tests/ui/len_zero.rs:156:8
|
||||
|
|
||||
LL | if 1 <= has_is_empty.len() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to one
|
||||
--> tests/ui/len_zero.rs:153:8
|
||||
--> tests/ui/len_zero.rs:159:8
|
||||
|
|
||||
LL | if 1 > has_is_empty.len() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:167:8
|
||||
--> tests/ui/len_zero.rs:173:8
|
||||
|
|
||||
LL | if with_is_empty.len() == 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:179:6
|
||||
--> tests/ui/len_zero.rs:185:6
|
||||
|
|
||||
LL | (has_is_empty.len() > 0).then(|| println!("This can happen."));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:180:6
|
||||
--> tests/ui/len_zero.rs:186:6
|
||||
|
|
||||
LL | (has_is_empty.len() == 0).then(|| println!("Or this!"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> tests/ui/len_zero.rs:184:8
|
||||
--> tests/ui/len_zero.rs:190:8
|
||||
|
|
||||
LL | if b.len() != 0 {}
|
||||
| ^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!b.is_empty()`
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@ fn early_return() -> u8 {
|
|||
foo
|
||||
}
|
||||
|
||||
fn allow_works() -> i32 {
|
||||
#[allow(clippy::useless_let_if_seq)]
|
||||
let x;
|
||||
if true {
|
||||
x = 1;
|
||||
} else {
|
||||
x = 2;
|
||||
}
|
||||
x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
early_return();
|
||||
issue975();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> tests/ui/let_if_seq.rs:66:5
|
||||
--> tests/ui/let_if_seq.rs:77:5
|
||||
|
|
||||
LL | / let mut foo = 0;
|
||||
LL | |
|
||||
|
|
@ -14,7 +14,7 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::useless_let_if_seq)]`
|
||||
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> tests/ui/let_if_seq.rs:73:5
|
||||
--> tests/ui/let_if_seq.rs:84:5
|
||||
|
|
||||
LL | / let mut bar = 0;
|
||||
LL | |
|
||||
|
|
@ -28,7 +28,7 @@ LL | | }
|
|||
= note: you might not need `mut` at all
|
||||
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> tests/ui/let_if_seq.rs:83:5
|
||||
--> tests/ui/let_if_seq.rs:94:5
|
||||
|
|
||||
LL | / let quz;
|
||||
LL | |
|
||||
|
|
@ -40,7 +40,7 @@ LL | | }
|
|||
| |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };`
|
||||
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> tests/ui/let_if_seq.rs:113:5
|
||||
--> tests/ui/let_if_seq.rs:124:5
|
||||
|
|
||||
LL | / let mut baz = 0;
|
||||
LL | |
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
clippy::never_loop,
|
||||
clippy::needless_if,
|
||||
clippy::diverging_sub_expression,
|
||||
clippy::single_match
|
||||
clippy::single_match,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
#![warn(clippy::manual_let_else)]
|
||||
//@no-rustfix
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:28:5
|
||||
--> tests/ui/manual_let_else.rs:29:5
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };`
|
||||
|
|
@ -8,7 +8,7 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return };
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:31:5
|
||||
--> tests/ui/manual_let_else.rs:32:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -26,7 +26,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:38:5
|
||||
--> tests/ui/manual_let_else.rs:39:5
|
||||
|
|
||||
LL | / let v = if let Some(v) = g() {
|
||||
LL | |
|
||||
|
|
@ -47,25 +47,25 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:50:9
|
||||
--> tests/ui/manual_let_else.rs:51:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { continue };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { continue };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:52:9
|
||||
--> tests/ui/manual_let_else.rs:53:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { break };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { break };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:57:5
|
||||
--> tests/ui/manual_let_else.rs:58:5
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { panic!() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { panic!() };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:61:5
|
||||
--> tests/ui/manual_let_else.rs:62:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -83,7 +83,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:69:5
|
||||
--> tests/ui/manual_let_else.rs:70:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -101,7 +101,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:77:5
|
||||
--> tests/ui/manual_let_else.rs:78:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -121,7 +121,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:86:5
|
||||
--> tests/ui/manual_let_else.rs:87:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -141,7 +141,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:95:5
|
||||
--> tests/ui/manual_let_else.rs:96:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -168,7 +168,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:111:5
|
||||
--> tests/ui/manual_let_else.rs:112:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -190,7 +190,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:122:5
|
||||
--> tests/ui/manual_let_else.rs:123:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -217,7 +217,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:138:5
|
||||
--> tests/ui/manual_let_else.rs:139:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -239,7 +239,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:149:5
|
||||
--> tests/ui/manual_let_else.rs:150:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -257,7 +257,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:157:5
|
||||
--> tests/ui/manual_let_else.rs:158:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -278,7 +278,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:167:5
|
||||
--> tests/ui/manual_let_else.rs:168:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -299,7 +299,7 @@ LL + } };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:177:5
|
||||
--> tests/ui/manual_let_else.rs:178:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -328,7 +328,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:195:5
|
||||
--> tests/ui/manual_let_else.rs:196:5
|
||||
|
|
||||
LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) {
|
||||
LL | |
|
||||
|
|
@ -346,7 +346,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:203:5
|
||||
--> tests/ui/manual_let_else.rs:204:5
|
||||
|
|
||||
LL | / let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) {
|
||||
LL | |
|
||||
|
|
@ -364,7 +364,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:213:13
|
||||
--> tests/ui/manual_let_else.rs:214:13
|
||||
|
|
||||
LL | let $n = if let Some(v) = $e { v } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };`
|
||||
|
|
@ -375,19 +375,19 @@ LL | create_binding_if_some!(w, g());
|
|||
= note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:222:5
|
||||
--> tests/ui/manual_let_else.rs:223:5
|
||||
|
|
||||
LL | let v = if let Variant::A(a, 0) = e() { a } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:226:5
|
||||
--> tests/ui/manual_let_else.rs:227:5
|
||||
|
|
||||
LL | let mut v = if let Variant::B(b) = e() { b } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:231:5
|
||||
--> tests/ui/manual_let_else.rs:232:5
|
||||
|
|
||||
LL | / let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested {
|
||||
LL | |
|
||||
|
|
@ -405,19 +405,19 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:238:5
|
||||
--> tests/ui/manual_let_else.rs:239:5
|
||||
|
|
||||
LL | let v = if let Variant::A(.., a) = e() { a } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(.., v) = e() else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:242:5
|
||||
--> tests/ui/manual_let_else.rs:243:5
|
||||
|
|
||||
LL | let w = if let (Some(v), ()) = (g(), ()) { v } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let (Some(w), ()) = (g(), ()) else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:246:5
|
||||
--> tests/ui/manual_let_else.rs:247:5
|
||||
|
|
||||
LL | / let w = if let Some(S { v: x }) = Some(S { v: 0 }) {
|
||||
LL | |
|
||||
|
|
@ -435,7 +435,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:254:5
|
||||
--> tests/ui/manual_let_else.rs:255:5
|
||||
|
|
||||
LL | / let v = if let Some(S { v: x }) = Some(S { v: 0 }) {
|
||||
LL | |
|
||||
|
|
@ -453,7 +453,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:262:5
|
||||
--> tests/ui/manual_let_else.rs:263:5
|
||||
|
|
||||
LL | / let (x, S { v }, w) = if let Some(U { v, w, x }) = None::<U<S<()>>> {
|
||||
LL | |
|
||||
|
|
@ -471,7 +471,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:379:5
|
||||
--> tests/ui/manual_let_else.rs:380:5
|
||||
|
|
||||
LL | / let _ = match ff {
|
||||
LL | |
|
||||
|
|
@ -481,7 +481,7 @@ LL | | };
|
|||
| |______^ help: consider writing: `let Some(_) = ff else { macro_call!() };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:456:9
|
||||
--> tests/ui/manual_let_else.rs:457:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:27:5
|
||||
--> tests/ui/manual_retain.rs:25:5
|
||||
|
|
||||
LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)`
|
||||
|
|
@ -8,43 +8,43 @@ LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_retain)]`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:28:5
|
||||
--> tests/ui/manual_retain.rs:26:5
|
||||
|
|
||||
LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:29:5
|
||||
--> tests/ui/manual_retain.rs:27:5
|
||||
|
|
||||
LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:33:5
|
||||
--> tests/ui/manual_retain.rs:31:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:34:5
|
||||
--> tests/ui/manual_retain.rs:32:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:64:5
|
||||
--> tests/ui/manual_retain.rs:62: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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:65:5
|
||||
--> tests/ui/manual_retain.rs:63: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()`
|
||||
--> tests/ui/manual_retain.rs:66:5
|
||||
--> tests/ui/manual_retain.rs:64:5
|
||||
|
|
||||
LL | / btree_map = btree_map
|
||||
LL | | .into_iter()
|
||||
|
|
@ -53,49 +53,49 @@ 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()`
|
||||
--> tests/ui/manual_retain.rs:91:5
|
||||
--> tests/ui/manual_retain.rs:89: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()`
|
||||
--> tests/ui/manual_retain.rs:92:5
|
||||
--> tests/ui/manual_retain.rs:90: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()`
|
||||
--> tests/ui/manual_retain.rs:93:5
|
||||
--> tests/ui/manual_retain.rs:91: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()`
|
||||
--> tests/ui/manual_retain.rs:97:5
|
||||
--> tests/ui/manual_retain.rs:95:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:98:5
|
||||
--> tests/ui/manual_retain.rs:96:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:128:5
|
||||
--> tests/ui/manual_retain.rs:126: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()`
|
||||
--> tests/ui/manual_retain.rs:129:5
|
||||
--> tests/ui/manual_retain.rs:127: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()`
|
||||
--> tests/ui/manual_retain.rs:130:5
|
||||
--> tests/ui/manual_retain.rs:128:5
|
||||
|
|
||||
LL | / hash_map = hash_map
|
||||
LL | | .into_iter()
|
||||
|
|
@ -104,133 +104,133 @@ 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()`
|
||||
--> tests/ui/manual_retain.rs:154:5
|
||||
--> tests/ui/manual_retain.rs:152: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()`
|
||||
--> tests/ui/manual_retain.rs:155:5
|
||||
--> tests/ui/manual_retain.rs:153: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()`
|
||||
--> tests/ui/manual_retain.rs:156:5
|
||||
--> tests/ui/manual_retain.rs:154: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()`
|
||||
--> tests/ui/manual_retain.rs:160:5
|
||||
--> tests/ui/manual_retain.rs:158:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:161:5
|
||||
--> tests/ui/manual_retain.rs:159:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:190:5
|
||||
--> tests/ui/manual_retain.rs:188: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()`
|
||||
--> tests/ui/manual_retain.rs:202:5
|
||||
--> tests/ui/manual_retain.rs:200: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()`
|
||||
--> tests/ui/manual_retain.rs:203:5
|
||||
--> tests/ui/manual_retain.rs:201: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()`
|
||||
--> tests/ui/manual_retain.rs:204:5
|
||||
--> tests/ui/manual_retain.rs:202: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()`
|
||||
--> tests/ui/manual_retain.rs:208:5
|
||||
--> tests/ui/manual_retain.rs:206:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:209:5
|
||||
--> tests/ui/manual_retain.rs:207:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:231:5
|
||||
--> tests/ui/manual_retain.rs:229: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()`
|
||||
--> tests/ui/manual_retain.rs:232:5
|
||||
--> tests/ui/manual_retain.rs:230: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()`
|
||||
--> tests/ui/manual_retain.rs:233:5
|
||||
--> tests/ui/manual_retain.rs:231: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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:290:5
|
||||
--> tests/ui/manual_retain.rs:288:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|(x, y)| *x == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:294:5
|
||||
--> tests/ui/manual_retain.rs:292:5
|
||||
|
|
||||
LL | tuples = tuples.into_iter().filter(|(_, n)| *n > 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(_, n)| *n > 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:311:5
|
||||
--> tests/ui/manual_retain.rs:309:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&&x| x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:312:5
|
||||
--> tests/ui/manual_retain.rs:310:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&&x| x == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:313:5
|
||||
--> tests/ui/manual_retain.rs:311:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|&x| x == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:316:5
|
||||
--> tests/ui/manual_retain.rs:314:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:317:5
|
||||
--> tests/ui/manual_retain.rs:315:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| *x == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:318:5
|
||||
--> tests/ui/manual_retain.rs:316:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|x| *x == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
#![allow(dead_code)]
|
||||
#![allow(unused_variables, clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)]
|
||||
#![allow(
|
||||
unused_variables,
|
||||
clippy::unnecessary_wraps,
|
||||
clippy::unnecessary_literal_unwrap,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
|
||||
fn option_unwrap_or() {
|
||||
// int case
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
#![allow(dead_code)]
|
||||
#![allow(unused_variables, clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)]
|
||||
#![allow(
|
||||
unused_variables,
|
||||
clippy::unnecessary_wraps,
|
||||
clippy::unnecessary_literal_unwrap,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
|
||||
fn option_unwrap_or() {
|
||||
// int case
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:6:5
|
||||
--> tests/ui/manual_unwrap_or.rs:11:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -11,7 +11,7 @@ LL | | };
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or)]`
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:12:5
|
||||
--> tests/ui/manual_unwrap_or.rs:17:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | None => 42,
|
||||
|
|
@ -20,7 +20,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:18:5
|
||||
--> tests/ui/manual_unwrap_or.rs:23:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -29,7 +29,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Some(1).unwrap_or(1 + 42)`
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:25:5
|
||||
--> tests/ui/manual_unwrap_or.rs:30:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -50,7 +50,7 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:35:5
|
||||
--> tests/ui/manual_unwrap_or.rs:40:5
|
||||
|
|
||||
LL | / match Some("Bob") {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -59,7 +59,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")`
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:85:5
|
||||
--> tests/ui/manual_unwrap_or.rs:90:5
|
||||
|
|
||||
LL | / match Ok::<i32, &str>(1) {
|
||||
LL | | Ok(i) => i,
|
||||
|
|
@ -68,7 +68,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Ok::<i32, &str>(1).unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:92:5
|
||||
--> tests/ui/manual_unwrap_or.rs:97:5
|
||||
|
|
||||
LL | / match a {
|
||||
LL | | Ok(i) => i,
|
||||
|
|
@ -77,7 +77,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `a.unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:98:5
|
||||
--> tests/ui/manual_unwrap_or.rs:103:5
|
||||
|
|
||||
LL | / match Ok(1) as Result<i32, &str> {
|
||||
LL | | Ok(i) => i,
|
||||
|
|
@ -86,7 +86,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `(Ok(1) as Result<i32, &str>).unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:111:5
|
||||
--> tests/ui/manual_unwrap_or.rs:116:5
|
||||
|
|
||||
LL | / match s.method() {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -95,7 +95,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `s.method().unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:117:5
|
||||
--> tests/ui/manual_unwrap_or.rs:122:5
|
||||
|
|
||||
LL | / match Ok::<i32, &str>(1) {
|
||||
LL | | Err(_) => 42,
|
||||
|
|
@ -104,7 +104,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Ok::<i32, &str>(1).unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:123:5
|
||||
--> tests/ui/manual_unwrap_or.rs:128:5
|
||||
|
|
||||
LL | / match Ok::<i32, &str>(1) {
|
||||
LL | | Ok(i) => i,
|
||||
|
|
@ -113,7 +113,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Ok::<i32, &str>(1).unwrap_or(1 + 42)`
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:130:5
|
||||
--> tests/ui/manual_unwrap_or.rs:135:5
|
||||
|
|
||||
LL | / match Ok::<i32, &str>(1) {
|
||||
LL | | Ok(i) => i,
|
||||
|
|
@ -134,7 +134,7 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: this pattern reimplements `Result::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:140:5
|
||||
--> tests/ui/manual_unwrap_or.rs:145:5
|
||||
|
|
||||
LL | / match Ok::<&str, &str>("Bob") {
|
||||
LL | | Ok(i) => i,
|
||||
|
|
@ -143,7 +143,7 @@ LL | | };
|
|||
| |_____^ help: replace with: `Ok::<&str, &str>("Bob").unwrap_or("Alice")`
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> tests/ui/manual_unwrap_or.rs:200:17
|
||||
--> tests/ui/manual_unwrap_or.rs:205:17
|
||||
|
|
||||
LL | let _ = match some_macro!() {
|
||||
| _________________^
|
||||
|
|
|
|||
19
tests/ui/manual_unwrap_or_default.fixed
Normal file
19
tests/ui/manual_unwrap_or_default.fixed
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![warn(clippy::manual_unwrap_or_default)]
|
||||
#![allow(clippy::unnecessary_literal_unwrap)]
|
||||
|
||||
fn main() {
|
||||
let x: Option<Vec<String>> = None;
|
||||
x.unwrap_or_default();
|
||||
|
||||
let x: Option<Vec<String>> = None;
|
||||
x.unwrap_or_default();
|
||||
|
||||
let x: Option<String> = None;
|
||||
x.unwrap_or_default();
|
||||
|
||||
let x: Option<Vec<String>> = None;
|
||||
x.unwrap_or_default();
|
||||
|
||||
let x: Option<Vec<String>> = None;
|
||||
x.unwrap_or_default();
|
||||
}
|
||||
40
tests/ui/manual_unwrap_or_default.rs
Normal file
40
tests/ui/manual_unwrap_or_default.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#![warn(clippy::manual_unwrap_or_default)]
|
||||
#![allow(clippy::unnecessary_literal_unwrap)]
|
||||
|
||||
fn main() {
|
||||
let x: Option<Vec<String>> = None;
|
||||
match x {
|
||||
//~^ ERROR: match can be simplified with `.unwrap_or_default()`
|
||||
Some(v) => v,
|
||||
None => Vec::default(),
|
||||
};
|
||||
|
||||
let x: Option<Vec<String>> = None;
|
||||
match x {
|
||||
//~^ ERROR: match can be simplified with `.unwrap_or_default()`
|
||||
Some(v) => v,
|
||||
_ => Vec::default(),
|
||||
};
|
||||
|
||||
let x: Option<String> = None;
|
||||
match x {
|
||||
//~^ ERROR: match can be simplified with `.unwrap_or_default()`
|
||||
Some(v) => v,
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
let x: Option<Vec<String>> = None;
|
||||
match x {
|
||||
//~^ ERROR: match can be simplified with `.unwrap_or_default()`
|
||||
None => Vec::default(),
|
||||
Some(v) => v,
|
||||
};
|
||||
|
||||
let x: Option<Vec<String>> = None;
|
||||
if let Some(v) = x {
|
||||
//~^ ERROR: if let can be simplified with `.unwrap_or_default()`
|
||||
v
|
||||
} else {
|
||||
Vec::default()
|
||||
};
|
||||
}
|
||||
56
tests/ui/manual_unwrap_or_default.stderr
Normal file
56
tests/ui/manual_unwrap_or_default.stderr
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
error: match can be simplified with `.unwrap_or_default()`
|
||||
--> tests/ui/manual_unwrap_or_default.rs:6:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | |
|
||||
LL | | Some(v) => v,
|
||||
LL | | None => Vec::default(),
|
||||
LL | | };
|
||||
| |_____^ help: replace it with: `x.unwrap_or_default()`
|
||||
|
|
||||
= note: `-D clippy::manual-unwrap-or-default` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or_default)]`
|
||||
|
||||
error: match can be simplified with `.unwrap_or_default()`
|
||||
--> tests/ui/manual_unwrap_or_default.rs:13:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | |
|
||||
LL | | Some(v) => v,
|
||||
LL | | _ => Vec::default(),
|
||||
LL | | };
|
||||
| |_____^ help: replace it with: `x.unwrap_or_default()`
|
||||
|
||||
error: match can be simplified with `.unwrap_or_default()`
|
||||
--> tests/ui/manual_unwrap_or_default.rs:20:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | |
|
||||
LL | | Some(v) => v,
|
||||
LL | | None => String::new(),
|
||||
LL | | };
|
||||
| |_____^ help: replace it with: `x.unwrap_or_default()`
|
||||
|
||||
error: match can be simplified with `.unwrap_or_default()`
|
||||
--> tests/ui/manual_unwrap_or_default.rs:27:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | |
|
||||
LL | | None => Vec::default(),
|
||||
LL | | Some(v) => v,
|
||||
LL | | };
|
||||
| |_____^ help: replace it with: `x.unwrap_or_default()`
|
||||
|
||||
error: if let can be simplified with `.unwrap_or_default()`
|
||||
--> tests/ui/manual_unwrap_or_default.rs:34:5
|
||||
|
|
||||
LL | / if let Some(v) = x {
|
||||
LL | |
|
||||
LL | | v
|
||||
LL | | } else {
|
||||
LL | | Vec::default()
|
||||
LL | | };
|
||||
| |_____^ help: replace it with: `x.unwrap_or_default()`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
clippy::redundant_clone,
|
||||
clippy::redundant_closure,
|
||||
clippy::useless_asref,
|
||||
clippy::useless_vec
|
||||
clippy::useless_vec,
|
||||
clippy::empty_loop
|
||||
)]
|
||||
|
||||
fn main() {
|
||||
|
|
@ -117,4 +118,17 @@ fn main() {
|
|||
let y = x.as_ref().map(|x| String::clone(x));
|
||||
let x: Result<String, ()> = Ok(String::new());
|
||||
let y = x.as_ref().map(|x| String::clone(x));
|
||||
|
||||
// Issue #12271
|
||||
{
|
||||
// Don't lint these
|
||||
let x: Option<&u8> = None;
|
||||
let y = x.map(|x| String::clone(loop {}));
|
||||
let x: Option<&u8> = None;
|
||||
let y = x.map(|x| u8::clone(loop {}));
|
||||
let x: Vec<&u8> = vec![];
|
||||
let y = x.into_iter().map(|x| String::clone(loop {}));
|
||||
let x: Vec<&u8> = vec![];
|
||||
let y = x.into_iter().map(|x| u8::clone(loop {}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
clippy::redundant_clone,
|
||||
clippy::redundant_closure,
|
||||
clippy::useless_asref,
|
||||
clippy::useless_vec
|
||||
clippy::useless_vec,
|
||||
clippy::empty_loop
|
||||
)]
|
||||
|
||||
fn main() {
|
||||
|
|
@ -117,4 +118,17 @@ fn main() {
|
|||
let y = x.as_ref().map(|x| String::clone(x));
|
||||
let x: Result<String, ()> = Ok(String::new());
|
||||
let y = x.as_ref().map(|x| String::clone(x));
|
||||
|
||||
// Issue #12271
|
||||
{
|
||||
// Don't lint these
|
||||
let x: Option<&u8> = None;
|
||||
let y = x.map(|x| String::clone(loop {}));
|
||||
let x: Option<&u8> = None;
|
||||
let y = x.map(|x| u8::clone(loop {}));
|
||||
let x: Vec<&u8> = vec![];
|
||||
let y = x.into_iter().map(|x| String::clone(loop {}));
|
||||
let x: Vec<&u8> = vec![];
|
||||
let y = x.into_iter().map(|x| u8::clone(loop {}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: you are using an explicit closure for copying elements
|
||||
--> tests/ui/map_clone.rs:13:22
|
||||
--> tests/ui/map_clone.rs:14:22
|
||||
|
|
||||
LL | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()`
|
||||
|
|
@ -8,85 +8,85 @@ LL | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::map_clone)]`
|
||||
|
||||
error: you are using an explicit closure for cloning elements
|
||||
--> tests/ui/map_clone.rs:14:26
|
||||
--> tests/ui/map_clone.rs:15:26
|
||||
|
|
||||
LL | let _: Vec<String> = vec![String::new()].iter().map(|x| x.clone()).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()`
|
||||
|
||||
error: you are using an explicit closure for copying elements
|
||||
--> tests/ui/map_clone.rs:15:23
|
||||
--> tests/ui/map_clone.rs:16:23
|
||||
|
|
||||
LL | let _: Vec<u32> = vec![42, 43].iter().map(|&x| x).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()`
|
||||
|
||||
error: you are using an explicit closure for copying elements
|
||||
--> tests/ui/map_clone.rs:17:26
|
||||
--> tests/ui/map_clone.rs:18:26
|
||||
|
|
||||
LL | let _: Option<u64> = Some(&16).map(|b| *b);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()`
|
||||
|
||||
error: you are using an explicit closure for copying elements
|
||||
--> tests/ui/map_clone.rs:18:25
|
||||
--> tests/ui/map_clone.rs:19:25
|
||||
|
|
||||
LL | let _: Option<u8> = Some(&1).map(|x| x.clone());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&1).copied()`
|
||||
|
||||
error: you are needlessly cloning iterator elements
|
||||
--> tests/ui/map_clone.rs:29:29
|
||||
--> tests/ui/map_clone.rs:30:29
|
||||
|
|
||||
LL | let _ = std::env::args().map(|v| v.clone());
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: remove the `map` call
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:68:13
|
||||
--> tests/ui/map_clone.rs:69:13
|
||||
|
|
||||
LL | let y = x.map(|x| String::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:70:13
|
||||
--> tests/ui/map_clone.rs:71:13
|
||||
|
|
||||
LL | let y = x.map(Clone::clone);
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:73:13
|
||||
--> tests/ui/map_clone.rs:74:13
|
||||
|
|
||||
LL | let y = x.map(String::clone);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:79:13
|
||||
--> tests/ui/map_clone.rs:80:13
|
||||
|
|
||||
LL | let y = x.map(|x| u32::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:82:13
|
||||
--> tests/ui/map_clone.rs:83:13
|
||||
|
|
||||
LL | let y = x.map(|x| Clone::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:94:13
|
||||
--> tests/ui/map_clone.rs:95:13
|
||||
|
|
||||
LL | let y = x.map(|x| String::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:97:13
|
||||
--> tests/ui/map_clone.rs:98:13
|
||||
|
|
||||
LL | let y = x.map(|x| Clone::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:103:13
|
||||
--> tests/ui/map_clone.rs:104:13
|
||||
|
|
||||
LL | let y = x.map(|x| u32::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()`
|
||||
|
||||
error: you are explicitly cloning with `.map()`
|
||||
--> tests/ui/map_clone.rs:106:13
|
||||
--> tests/ui/map_clone.rs:107:13
|
||||
|
|
||||
LL | let y = x.map(|x| Clone::clone(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![warn(clippy::match_result_ok)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::boxed_local, clippy::uninlined_format_args)]
|
||||
#![allow(clippy::boxed_local, clippy::uninlined_format_args, clippy::manual_unwrap_or_default)]
|
||||
|
||||
// Checking `if` cases
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![warn(clippy::match_result_ok)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::boxed_local, clippy::uninlined_format_args)]
|
||||
#![allow(clippy::boxed_local, clippy::uninlined_format_args, clippy::manual_unwrap_or_default)]
|
||||
|
||||
// Checking `if` cases
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@needs-asm-support
|
||||
//@aux-build: proc_macros.rs
|
||||
//@aux-build: proc_macro_attr.rs
|
||||
|
||||
#![warn(clippy::missing_docs_in_private_items)]
|
||||
// When denying at the crate level, be sure to not get random warnings from the
|
||||
|
|
@ -8,6 +9,8 @@
|
|||
//! Some garbage docs for the crate here
|
||||
#![doc = "More garbage"]
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macro_attr;
|
||||
extern crate proc_macros;
|
||||
|
||||
use proc_macros::with_span;
|
||||
|
|
@ -112,3 +115,12 @@ with_span!(span pub enum FooPm3 { A, B(u32), C { field: u32 }});
|
|||
with_span!(span pub fn foo_pm() {});
|
||||
with_span!(span pub static FOO_PM: u32 = 0;);
|
||||
with_span!(span pub const FOO2_PM: u32 = 0;);
|
||||
|
||||
// issue #12197
|
||||
// Undocumented field originated inside of spanned proc-macro attribute
|
||||
/// Some dox for struct.
|
||||
#[rewrite_struct]
|
||||
pub struct Test {
|
||||
/// Dox
|
||||
a: u8,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: missing documentation for a type alias
|
||||
--> tests/ui/missing_doc.rs:16:1
|
||||
--> tests/ui/missing_doc.rs:19:1
|
||||
|
|
||||
LL | type Typedef = String;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,19 +8,19 @@ LL | type Typedef = String;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]`
|
||||
|
||||
error: missing documentation for a module
|
||||
--> tests/ui/missing_doc.rs:19:1
|
||||
--> tests/ui/missing_doc.rs:22:1
|
||||
|
|
||||
LL | mod module_no_dox {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> tests/ui/missing_doc.rs:25:1
|
||||
--> tests/ui/missing_doc.rs:28:1
|
||||
|
|
||||
LL | fn foo3() {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for an enum
|
||||
--> tests/ui/missing_doc.rs:39:1
|
||||
--> tests/ui/missing_doc.rs:42:1
|
||||
|
|
||||
LL | / enum Baz {
|
||||
LL | | BazA { a: isize, b: isize },
|
||||
|
|
@ -29,43 +29,43 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: missing documentation for a variant
|
||||
--> tests/ui/missing_doc.rs:40:5
|
||||
--> tests/ui/missing_doc.rs:43:5
|
||||
|
|
||||
LL | BazA { a: isize, b: isize },
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a struct field
|
||||
--> tests/ui/missing_doc.rs:40:12
|
||||
--> tests/ui/missing_doc.rs:43:12
|
||||
|
|
||||
LL | BazA { a: isize, b: isize },
|
||||
| ^^^^^^^^
|
||||
|
||||
error: missing documentation for a struct field
|
||||
--> tests/ui/missing_doc.rs:40:22
|
||||
--> tests/ui/missing_doc.rs:43:22
|
||||
|
|
||||
LL | BazA { a: isize, b: isize },
|
||||
| ^^^^^^^^
|
||||
|
||||
error: missing documentation for a variant
|
||||
--> tests/ui/missing_doc.rs:41:5
|
||||
--> tests/ui/missing_doc.rs:44:5
|
||||
|
|
||||
LL | BarB,
|
||||
| ^^^^
|
||||
|
||||
error: missing documentation for a constant
|
||||
--> tests/ui/missing_doc.rs:65:1
|
||||
--> tests/ui/missing_doc.rs:68:1
|
||||
|
|
||||
LL | const FOO: u32 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a static
|
||||
--> tests/ui/missing_doc.rs:74:1
|
||||
--> tests/ui/missing_doc.rs:77:1
|
||||
|
|
||||
LL | static BAR: u32 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a module
|
||||
--> tests/ui/missing_doc.rs:83:1
|
||||
--> tests/ui/missing_doc.rs:86:1
|
||||
|
|
||||
LL | / mod internal_impl {
|
||||
LL | | /// dox
|
||||
|
|
@ -77,13 +77,13 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> tests/ui/missing_doc.rs:88:5
|
||||
--> tests/ui/missing_doc.rs:91:5
|
||||
|
|
||||
LL | fn undocumented3() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> tests/ui/missing_doc.rs:94:9
|
||||
--> tests/ui/missing_doc.rs:97:9
|
||||
|
|
||||
LL | fn also_undocumented2() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::mixed_attributes_style)]
|
||||
#![allow(clippy::duplicated_attributes)]
|
||||
|
||||
#[allow(unused)] //~ ERROR: item has both inner and outer attributes
|
||||
fn foo1() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: item has both inner and outer attributes
|
||||
--> tests/ui/mixed_attributes_style.rs:3:1
|
||||
--> tests/ui/mixed_attributes_style.rs:4:1
|
||||
|
|
||||
LL | / #[allow(unused)]
|
||||
LL | | fn foo1() {
|
||||
|
|
@ -10,7 +10,7 @@ LL | | #![allow(unused)]
|
|||
= help: to override `-D warnings` add `#[allow(clippy::mixed_attributes_style)]`
|
||||
|
||||
error: item has both inner and outer attributes
|
||||
--> tests/ui/mixed_attributes_style.rs:17:1
|
||||
--> tests/ui/mixed_attributes_style.rs:18:1
|
||||
|
|
||||
LL | / /// linux
|
||||
LL | |
|
||||
|
|
@ -19,7 +19,7 @@ LL | | //! windows
|
|||
| |_______________^
|
||||
|
||||
error: item has both inner and outer attributes
|
||||
--> tests/ui/mixed_attributes_style.rs:32:1
|
||||
--> tests/ui/mixed_attributes_style.rs:33:1
|
||||
|
|
||||
LL | / #[allow(unused)]
|
||||
LL | | mod bar {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::mut_mut)]
|
||||
#![allow(unused)]
|
||||
|
|
@ -82,3 +81,8 @@ mod issue9035 {
|
|||
|
||||
fn bar(_: &mut impl Display) {}
|
||||
}
|
||||
|
||||
fn allow_works() {
|
||||
#[allow(clippy::mut_mut)]
|
||||
let _ = &mut &mut 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:16:11
|
||||
--> tests/ui/mut_mut.rs:15:11
|
||||
|
|
||||
LL | fn fun(x: &mut &mut u32) -> bool {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -8,13 +8,13 @@ LL | fn fun(x: &mut &mut u32) -> bool {
|
|||
= help: to override `-D warnings` add `#[allow(clippy::mut_mut)]`
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:33:17
|
||||
--> tests/ui/mut_mut.rs:32:17
|
||||
|
|
||||
LL | let mut x = &mut &mut 1u32;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:48:25
|
||||
--> tests/ui/mut_mut.rs:47:25
|
||||
|
|
||||
LL | let mut z = inline!(&mut $(&mut 3u32));
|
||||
| ^
|
||||
|
|
@ -22,37 +22,37 @@ LL | let mut z = inline!(&mut $(&mut 3u32));
|
|||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: this expression mutably borrows a mutable reference. Consider reborrowing
|
||||
--> tests/ui/mut_mut.rs:35:21
|
||||
--> tests/ui/mut_mut.rs:34:21
|
||||
|
|
||||
LL | let mut y = &mut x;
|
||||
| ^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:39:32
|
||||
--> tests/ui/mut_mut.rs:38:32
|
||||
|
|
||||
LL | let y: &mut &mut u32 = &mut &mut 2;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:39:16
|
||||
--> tests/ui/mut_mut.rs:38:16
|
||||
|
|
||||
LL | let y: &mut &mut u32 = &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:44:37
|
||||
--> tests/ui/mut_mut.rs:43:37
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:44:16
|
||||
--> tests/ui/mut_mut.rs:43:16
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:44:21
|
||||
--> tests/ui/mut_mut.rs:43:21
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::needless_bitwise_bool)]
|
||||
#![allow(clippy::const_is_empty)]
|
||||
|
||||
fn returns_bool() -> bool {
|
||||
true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::needless_bitwise_bool)]
|
||||
#![allow(clippy::const_is_empty)]
|
||||
|
||||
fn returns_bool() -> bool {
|
||||
true
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: use of bitwise operator instead of lazy operator between booleans
|
||||
--> tests/ui/needless_bitwise_bool.rs:22:8
|
||||
--> tests/ui/needless_bitwise_bool.rs:23:8
|
||||
|
|
||||
LL | if y & !x {
|
||||
| ^^^^^^ help: try: `y && !x`
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// With an explicit return type it should lint too
|
||||
/// ```edition2015
|
||||
/// fn main() -> () {
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// This should, too.
|
||||
/// ```rust
|
||||
/// fn main() {
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// This one too.
|
||||
/// ```no_run
|
||||
/// // the fn is not always the first line
|
||||
|
|
|
|||
|
|
@ -316,4 +316,11 @@ fn test_match_as_stmt() {
|
|||
};
|
||||
}
|
||||
|
||||
fn allow_works() -> i32 {
|
||||
#[allow(clippy::needless_return, clippy::match_single_binding)]
|
||||
match () {
|
||||
() => return 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -326,4 +326,11 @@ fn test_match_as_stmt() {
|
|||
};
|
||||
}
|
||||
|
||||
fn allow_works() -> i32 {
|
||||
#[allow(clippy::needless_return, clippy::match_single_binding)]
|
||||
match () {
|
||||
() => return 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::no_effect_replace)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:6:13
|
||||
--> tests/ui/no_effect_replace.rs:4:13
|
||||
|
|
||||
LL | let _ = "12345".replace('1', "1");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1");
|
|||
= help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]`
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:9:13
|
||||
--> tests/ui/no_effect_replace.rs:7:13
|
||||
|
|
||||
LL | let _ = "12345".replace("12", "12");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:11:13
|
||||
--> tests/ui/no_effect_replace.rs:9:13
|
||||
|
|
||||
LL | let _ = String::new().replace("12", "12");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:14:13
|
||||
--> tests/ui/no_effect_replace.rs:12:13
|
||||
|
|
||||
LL | let _ = "12345".replacen('1', "1", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:16:13
|
||||
--> tests/ui/no_effect_replace.rs:14:13
|
||||
|
|
||||
LL | let _ = "12345".replacen("12", "12", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:18:13
|
||||
--> tests/ui/no_effect_replace.rs:16:13
|
||||
|
|
||||
LL | let _ = String::new().replacen("12", "12", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:25:13
|
||||
--> tests/ui/no_effect_replace.rs:23:13
|
||||
|
|
||||
LL | let _ = "hello".replace(&x.f(), &x.f());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:29:13
|
||||
--> tests/ui/no_effect_replace.rs:27:13
|
||||
|
|
||||
LL | let _ = "hello".replace(&y(), &y());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
clippy::ref_option_ref,
|
||||
clippy::equatable_if_let,
|
||||
clippy::let_unit_value,
|
||||
clippy::redundant_locals
|
||||
clippy::redundant_locals,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
|
||||
fn bad1(string: Option<&str>) -> (bool, &str) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
clippy::ref_option_ref,
|
||||
clippy::equatable_if_let,
|
||||
clippy::let_unit_value,
|
||||
clippy::redundant_locals
|
||||
clippy::redundant_locals,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
|
||||
fn bad1(string: Option<&str>) -> (bool, &str) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:10:5
|
||||
--> tests/ui/option_if_let_else.rs:11:5
|
||||
|
|
||||
LL | / if let Some(x) = string {
|
||||
LL | | (true, x)
|
||||
|
|
@ -12,19 +12,19 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:28:13
|
||||
--> tests/ui/option_if_let_else.rs:29:13
|
||||
|
|
||||
LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:29:13
|
||||
--> tests/ui/option_if_let_else.rs:30:13
|
||||
|
|
||||
LL | let _ = if let Some(s) = &num { s } else { &0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:30:13
|
||||
--> tests/ui/option_if_let_else.rs:31:13
|
||||
|
|
||||
LL | let _ = if let Some(s) = &mut num {
|
||||
| _____________^
|
||||
|
|
@ -44,13 +44,13 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:36:13
|
||||
--> tests/ui/option_if_let_else.rs:37:13
|
||||
|
|
||||
LL | let _ = if let Some(ref s) = num { s } else { &0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:37:13
|
||||
--> tests/ui/option_if_let_else.rs:38:13
|
||||
|
|
||||
LL | let _ = if let Some(mut s) = num {
|
||||
| _____________^
|
||||
|
|
@ -70,7 +70,7 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:43:13
|
||||
--> tests/ui/option_if_let_else.rs:44:13
|
||||
|
|
||||
LL | let _ = if let Some(ref mut s) = num {
|
||||
| _____________^
|
||||
|
|
@ -90,7 +90,7 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:52:5
|
||||
--> tests/ui/option_if_let_else.rs:53:5
|
||||
|
|
||||
LL | / if let Some(x) = arg {
|
||||
LL | | let y = x * x;
|
||||
|
|
@ -109,7 +109,7 @@ LL + })
|
|||
|
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:65:13
|
||||
--> tests/ui/option_if_let_else.rs:66:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = arg {
|
||||
| _____________^
|
||||
|
|
@ -121,7 +121,7 @@ LL | | };
|
|||
| |_____^ help: try: `arg.map_or_else(side_effect, |x| x)`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:74:13
|
||||
--> tests/ui/option_if_let_else.rs:75:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = arg {
|
||||
| _____________^
|
||||
|
|
@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x);
|
|||
|
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:107:13
|
||||
--> tests/ui/option_if_let_else.rs:108:13
|
||||
|
|
||||
LL | / if let Some(idx) = s.find('.') {
|
||||
LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
|
||||
|
|
@ -154,7 +154,7 @@ LL | | }
|
|||
| |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:118:5
|
||||
--> tests/ui/option_if_let_else.rs:119:5
|
||||
|
|
||||
LL | / if let Ok(binding) = variable {
|
||||
LL | | println!("Ok {binding}");
|
||||
|
|
@ -177,13 +177,13 @@ LL + })
|
|||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:142:13
|
||||
--> tests/ui/option_if_let_else.rs:143:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:152:13
|
||||
--> tests/ui/option_if_let_else.rs:153:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = Some(0) {
|
||||
| _____________^
|
||||
|
|
@ -205,13 +205,13 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:180:13
|
||||
--> tests/ui/option_if_let_else.rs:181:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:184:13
|
||||
--> tests/ui/option_if_let_else.rs:185:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = Some(0) {
|
||||
| _____________^
|
||||
|
|
@ -231,7 +231,7 @@ LL ~ });
|
|||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:223:13
|
||||
--> tests/ui/option_if_let_else.rs:224:13
|
||||
|
|
||||
LL | let _ = match s {
|
||||
| _____________^
|
||||
|
|
@ -241,7 +241,7 @@ LL | | };
|
|||
| |_____^ help: try: `s.map_or(1, |string| string.len())`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:227:13
|
||||
--> tests/ui/option_if_let_else.rs:228:13
|
||||
|
|
||||
LL | let _ = match Some(10) {
|
||||
| _____________^
|
||||
|
|
@ -251,7 +251,7 @@ LL | | };
|
|||
| |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:233:13
|
||||
--> tests/ui/option_if_let_else.rs:234:13
|
||||
|
|
||||
LL | let _ = match res {
|
||||
| _____________^
|
||||
|
|
@ -261,7 +261,7 @@ LL | | };
|
|||
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:237:13
|
||||
--> tests/ui/option_if_let_else.rs:238:13
|
||||
|
|
||||
LL | let _ = match res {
|
||||
| _____________^
|
||||
|
|
@ -271,13 +271,13 @@ LL | | };
|
|||
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:241:13
|
||||
--> tests/ui/option_if_let_else.rs:242:13
|
||||
|
|
||||
LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:258:17
|
||||
--> tests/ui/option_if_let_else.rs:259:17
|
||||
|
|
||||
LL | let _ = match initial {
|
||||
| _________________^
|
||||
|
|
@ -287,7 +287,7 @@ LL | | };
|
|||
| |_________^ help: try: `initial.as_ref().map_or(42, |value| do_something(value))`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:265:17
|
||||
--> tests/ui/option_if_let_else.rs:266:17
|
||||
|
|
||||
LL | let _ = match initial {
|
||||
| _________________^
|
||||
|
|
@ -297,7 +297,7 @@ LL | | };
|
|||
| |_________^ help: try: `initial.as_mut().map_or(42, |value| do_something2(value))`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:288:24
|
||||
--> tests/ui/option_if_let_else.rs:289:24
|
||||
|
|
||||
LL | let mut _hashmap = if let Some(hm) = &opt {
|
||||
| ________________________^
|
||||
|
|
@ -308,7 +308,7 @@ LL | | };
|
|||
| |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> tests/ui/option_if_let_else.rs:294:19
|
||||
--> tests/ui/option_if_let_else.rs:295:19
|
||||
|
|
||||
LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![deny(clippy::option_option)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
#![allow(clippy::unnecessary_wraps, clippy::manual_unwrap_or_default)]
|
||||
|
||||
const C: Option<Option<i32>> = None;
|
||||
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:6:10
|
||||
--> tests/ui/option_option.rs:4:10
|
||||
|
|
||||
LL | const C: Option<Option<i32>> = None;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> tests/ui/option_option.rs:3:9
|
||||
--> tests/ui/option_option.rs:1:9
|
||||
|
|
||||
LL | #![deny(clippy::option_option)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:8:11
|
||||
--> tests/ui/option_option.rs:6:11
|
||||
|
|
||||
LL | static S: Option<Option<i32>> = None;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:11:13
|
||||
--> tests/ui/option_option.rs:9:13
|
||||
|
|
||||
LL | fn input(_: Option<Option<u8>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:14:16
|
||||
--> tests/ui/option_option.rs:12:16
|
||||
|
|
||||
LL | fn output() -> Option<Option<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:19:27
|
||||
--> tests/ui/option_option.rs:17:27
|
||||
|
|
||||
LL | fn output_nested() -> Vec<Option<Option<u8>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:25:30
|
||||
--> tests/ui/option_option.rs:23:30
|
||||
|
|
||||
LL | fn output_nested_nested() -> Option<Option<Option<u8>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:31:8
|
||||
--> tests/ui/option_option.rs:29:8
|
||||
|
|
||||
LL | x: Option<Option<u8>>,
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:36:23
|
||||
--> tests/ui/option_option.rs:34:23
|
||||
|
|
||||
LL | fn struct_fn() -> Option<Option<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:43:22
|
||||
--> tests/ui/option_option.rs:41:22
|
||||
|
|
||||
LL | fn trait_fn() -> Option<Option<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:48:11
|
||||
--> tests/ui/option_option.rs:46:11
|
||||
|
|
||||
LL | Tuple(Option<Option<u8>>),
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:50:17
|
||||
--> tests/ui/option_option.rs:48:17
|
||||
|
|
||||
LL | Struct { x: Option<Option<u8>> },
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:92:14
|
||||
--> tests/ui/option_option.rs:90:14
|
||||
|
|
||||
LL | foo: Option<Option<Cow<'a, str>>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -112,4 +112,10 @@ async fn test_tokio<R: TokioAsyncRead + Unpin>(r: &mut R) {
|
|||
//~^ ERROR: reading zero byte data to `Vec`
|
||||
}
|
||||
|
||||
fn allow_works<F: std::io::Read>(mut f: F) {
|
||||
let mut data = Vec::with_capacity(100);
|
||||
#[allow(clippy::read_zero_byte_vec)]
|
||||
f.read(&mut data).unwrap();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::redundant_as_str)]
|
||||
#![allow(clippy::const_is_empty)]
|
||||
|
||||
fn main() {
|
||||
let string = "Hello, world!".to_owned();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::redundant_as_str)]
|
||||
#![allow(clippy::const_is_empty)]
|
||||
|
||||
fn main() {
|
||||
let string = "Hello, world!".to_owned();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too
|
||||
--> tests/ui/redundant_as_str.rs:7:29
|
||||
--> tests/ui/redundant_as_str.rs:8:29
|
||||
|
|
||||
LL | let _redundant = string.as_str().as_bytes();
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `as_bytes`
|
||||
|
|
@ -8,7 +8,7 @@ LL | let _redundant = string.as_str().as_bytes();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::redundant_as_str)]`
|
||||
|
||||
error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too
|
||||
--> tests/ui/redundant_as_str.rs:8:29
|
||||
--> tests/ui/redundant_as_str.rs:9:29
|
||||
|
|
||||
LL | let _redundant = string.as_str().is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `is_empty`
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Use that command to update this file and do not edit by hand.
|
||||
// Manual edits will be overwritten.
|
||||
|
||||
#![allow(clippy::duplicated_attributes)]
|
||||
#![allow(clippy::almost_complete_range)]
|
||||
#![allow(clippy::disallowed_names)]
|
||||
#![allow(clippy::blocks_in_conditions)]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Use that command to update this file and do not edit by hand.
|
||||
// Manual edits will be overwritten.
|
||||
|
||||
#![allow(clippy::duplicated_attributes)]
|
||||
#![allow(clippy::almost_complete_range)]
|
||||
#![allow(clippy::disallowed_names)]
|
||||
#![allow(clippy::blocks_in_conditions)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range`
|
||||
--> tests/ui/rename.rs:55:9
|
||||
--> tests/ui/rename.rs:56:9
|
||||
|
|
||||
LL | #![warn(clippy::almost_complete_letter_range)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range`
|
||||
|
|
@ -8,343 +8,343 @@ LL | #![warn(clippy::almost_complete_letter_range)]
|
|||
= help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]`
|
||||
|
||||
error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names`
|
||||
--> tests/ui/rename.rs:56:9
|
||||
--> tests/ui/rename.rs:57:9
|
||||
|
|
||||
LL | #![warn(clippy::blacklisted_name)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names`
|
||||
|
||||
error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_conditions`
|
||||
--> tests/ui/rename.rs:57:9
|
||||
--> tests/ui/rename.rs:58:9
|
||||
|
|
||||
LL | #![warn(clippy::block_in_if_condition_expr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions`
|
||||
|
||||
error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_conditions`
|
||||
--> tests/ui/rename.rs:58:9
|
||||
--> tests/ui/rename.rs:59:9
|
||||
|
|
||||
LL | #![warn(clippy::block_in_if_condition_stmt)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions`
|
||||
|
||||
error: lint `clippy::blocks_in_if_conditions` has been renamed to `clippy::blocks_in_conditions`
|
||||
--> tests/ui/rename.rs:59:9
|
||||
--> tests/ui/rename.rs:60:9
|
||||
|
|
||||
LL | #![warn(clippy::blocks_in_if_conditions)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions`
|
||||
|
||||
error: lint `clippy::box_vec` has been renamed to `clippy::box_collection`
|
||||
--> tests/ui/rename.rs:60:9
|
||||
--> tests/ui/rename.rs:61:9
|
||||
|
|
||||
LL | #![warn(clippy::box_vec)]
|
||||
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection`
|
||||
|
||||
error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes`
|
||||
--> tests/ui/rename.rs:61:9
|
||||
--> tests/ui/rename.rs:62:9
|
||||
|
|
||||
LL | #![warn(clippy::const_static_lifetime)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes`
|
||||
|
||||
error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
|
||||
--> tests/ui/rename.rs:62:9
|
||||
--> tests/ui/rename.rs:63:9
|
||||
|
|
||||
LL | #![warn(clippy::cyclomatic_complexity)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`
|
||||
|
||||
error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq`
|
||||
--> tests/ui/rename.rs:63:9
|
||||
--> tests/ui/rename.rs:64:9
|
||||
|
|
||||
LL | #![warn(clippy::derive_hash_xor_eq)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq`
|
||||
|
||||
error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods`
|
||||
--> tests/ui/rename.rs:64:9
|
||||
--> tests/ui/rename.rs:65:9
|
||||
|
|
||||
LL | #![warn(clippy::disallowed_method)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods`
|
||||
|
||||
error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types`
|
||||
--> tests/ui/rename.rs:65:9
|
||||
--> tests/ui/rename.rs:66:9
|
||||
|
|
||||
LL | #![warn(clippy::disallowed_type)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types`
|
||||
|
||||
error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression`
|
||||
--> tests/ui/rename.rs:66:9
|
||||
--> tests/ui/rename.rs:67:9
|
||||
|
|
||||
LL | #![warn(clippy::eval_order_dependence)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression`
|
||||
|
||||
error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion`
|
||||
--> tests/ui/rename.rs:67:9
|
||||
--> tests/ui/rename.rs:68:9
|
||||
|
|
||||
LL | #![warn(clippy::identity_conversion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion`
|
||||
|
||||
error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok`
|
||||
--> tests/ui/rename.rs:68:9
|
||||
--> tests/ui/rename.rs:69:9
|
||||
|
|
||||
LL | #![warn(clippy::if_let_some_result)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok`
|
||||
|
||||
error: lint `clippy::incorrect_clone_impl_on_copy_type` has been renamed to `clippy::non_canonical_clone_impl`
|
||||
--> tests/ui/rename.rs:69:9
|
||||
--> tests/ui/rename.rs:70:9
|
||||
|
|
||||
LL | #![warn(clippy::incorrect_clone_impl_on_copy_type)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_clone_impl`
|
||||
|
||||
error: lint `clippy::incorrect_partial_ord_impl_on_ord_type` has been renamed to `clippy::non_canonical_partial_ord_impl`
|
||||
--> tests/ui/rename.rs:70:9
|
||||
--> tests/ui/rename.rs:71:9
|
||||
|
|
||||
LL | #![warn(clippy::incorrect_partial_ord_impl_on_ord_type)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_partial_ord_impl`
|
||||
|
||||
error: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects`
|
||||
--> tests/ui/rename.rs:71:9
|
||||
--> tests/ui/rename.rs:72:9
|
||||
|
|
||||
LL | #![warn(clippy::integer_arithmetic)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects`
|
||||
|
||||
error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr`
|
||||
--> tests/ui/rename.rs:72:9
|
||||
--> tests/ui/rename.rs:73:9
|
||||
|
|
||||
LL | #![warn(clippy::logic_bug)]
|
||||
| ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr`
|
||||
|
||||
error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default`
|
||||
--> tests/ui/rename.rs:73:9
|
||||
--> tests/ui/rename.rs:74:9
|
||||
|
|
||||
LL | #![warn(clippy::new_without_default_derive)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default`
|
||||
|
||||
error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map`
|
||||
--> tests/ui/rename.rs:74:9
|
||||
--> tests/ui/rename.rs:75:9
|
||||
|
|
||||
LL | #![warn(clippy::option_and_then_some)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map`
|
||||
|
||||
error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used`
|
||||
--> tests/ui/rename.rs:75:9
|
||||
--> tests/ui/rename.rs:76:9
|
||||
|
|
||||
LL | #![warn(clippy::option_expect_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
|
||||
|
||||
error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or`
|
||||
--> tests/ui/rename.rs:76:9
|
||||
--> tests/ui/rename.rs:77:9
|
||||
|
|
||||
LL | #![warn(clippy::option_map_unwrap_or)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
|
||||
|
||||
error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
|
||||
--> tests/ui/rename.rs:77:9
|
||||
--> tests/ui/rename.rs:78:9
|
||||
|
|
||||
LL | #![warn(clippy::option_map_unwrap_or_else)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
|
||||
|
||||
error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used`
|
||||
--> tests/ui/rename.rs:78:9
|
||||
--> tests/ui/rename.rs:79:9
|
||||
|
|
||||
LL | #![warn(clippy::option_unwrap_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
|
||||
|
||||
error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow`
|
||||
--> tests/ui/rename.rs:79:9
|
||||
--> tests/ui/rename.rs:80:9
|
||||
|
|
||||
LL | #![warn(clippy::ref_in_deref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow`
|
||||
|
||||
error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used`
|
||||
--> tests/ui/rename.rs:80:9
|
||||
--> tests/ui/rename.rs:81:9
|
||||
|
|
||||
LL | #![warn(clippy::result_expect_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
|
||||
|
||||
error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
|
||||
--> tests/ui/rename.rs:81:9
|
||||
--> tests/ui/rename.rs:82:9
|
||||
|
|
||||
LL | #![warn(clippy::result_map_unwrap_or_else)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
|
||||
|
||||
error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used`
|
||||
--> tests/ui/rename.rs:82:9
|
||||
--> tests/ui/rename.rs:83:9
|
||||
|
|
||||
LL | #![warn(clippy::result_unwrap_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
|
||||
|
||||
error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str`
|
||||
--> tests/ui/rename.rs:83:9
|
||||
--> tests/ui/rename.rs:84:9
|
||||
|
|
||||
LL | #![warn(clippy::single_char_push_str)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str`
|
||||
|
||||
error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions`
|
||||
--> tests/ui/rename.rs:84:9
|
||||
--> tests/ui/rename.rs:85:9
|
||||
|
|
||||
LL | #![warn(clippy::stutter)]
|
||||
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
|
||||
|
||||
error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl`
|
||||
--> tests/ui/rename.rs:85:9
|
||||
--> tests/ui/rename.rs:86:9
|
||||
|
|
||||
LL | #![warn(clippy::to_string_in_display)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl`
|
||||
|
||||
error: lint `clippy::unwrap_or_else_default` has been renamed to `clippy::unwrap_or_default`
|
||||
--> tests/ui/rename.rs:86:9
|
||||
--> tests/ui/rename.rs:87:9
|
||||
|
|
||||
LL | #![warn(clippy::unwrap_or_else_default)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_or_default`
|
||||
|
||||
error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters`
|
||||
--> tests/ui/rename.rs:87:9
|
||||
--> tests/ui/rename.rs:88:9
|
||||
|
|
||||
LL | #![warn(clippy::zero_width_space)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters`
|
||||
|
||||
error: lint `clippy::cast_ref_to_mut` has been renamed to `invalid_reference_casting`
|
||||
--> tests/ui/rename.rs:88:9
|
||||
--> tests/ui/rename.rs:89:9
|
||||
|
|
||||
LL | #![warn(clippy::cast_ref_to_mut)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_reference_casting`
|
||||
|
||||
error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op`
|
||||
--> tests/ui/rename.rs:89:9
|
||||
--> tests/ui/rename.rs:90:9
|
||||
|
|
||||
LL | #![warn(clippy::clone_double_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op`
|
||||
|
||||
error: lint `clippy::cmp_nan` has been renamed to `invalid_nan_comparisons`
|
||||
--> tests/ui/rename.rs:90:9
|
||||
--> tests/ui/rename.rs:91:9
|
||||
|
|
||||
LL | #![warn(clippy::cmp_nan)]
|
||||
| ^^^^^^^^^^^^^^^ help: use the new name: `invalid_nan_comparisons`
|
||||
|
||||
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
|
||||
--> tests/ui/rename.rs:91:9
|
||||
--> tests/ui/rename.rs:92:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_bounds)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
|
||||
|
||||
error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types`
|
||||
--> tests/ui/rename.rs:92:9
|
||||
--> tests/ui/rename.rs:93:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_copy)]
|
||||
| ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types`
|
||||
|
||||
error: lint `clippy::drop_ref` has been renamed to `dropping_references`
|
||||
--> tests/ui/rename.rs:93:9
|
||||
--> tests/ui/rename.rs:94:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_ref)]
|
||||
| ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references`
|
||||
|
||||
error: lint `clippy::fn_null_check` has been renamed to `useless_ptr_null_checks`
|
||||
--> tests/ui/rename.rs:94:9
|
||||
--> tests/ui/rename.rs:95:9
|
||||
|
|
||||
LL | #![warn(clippy::fn_null_check)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `useless_ptr_null_checks`
|
||||
|
||||
error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles`
|
||||
--> tests/ui/rename.rs:95:9
|
||||
--> tests/ui/rename.rs:96:9
|
||||
|
|
||||
LL | #![warn(clippy::for_loop_over_option)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles`
|
||||
--> tests/ui/rename.rs:96:9
|
||||
--> tests/ui/rename.rs:97:9
|
||||
|
|
||||
LL | #![warn(clippy::for_loop_over_result)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles`
|
||||
--> tests/ui/rename.rs:97:9
|
||||
--> tests/ui/rename.rs:98:9
|
||||
|
|
||||
LL | #![warn(clippy::for_loops_over_fallibles)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types`
|
||||
--> tests/ui/rename.rs:98:9
|
||||
--> tests/ui/rename.rs:99:9
|
||||
|
|
||||
LL | #![warn(clippy::forget_copy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types`
|
||||
|
||||
error: lint `clippy::forget_ref` has been renamed to `forgetting_references`
|
||||
--> tests/ui/rename.rs:99:9
|
||||
--> tests/ui/rename.rs:100:9
|
||||
|
|
||||
LL | #![warn(clippy::forget_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references`
|
||||
|
||||
error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
|
||||
--> tests/ui/rename.rs:100:9
|
||||
--> tests/ui/rename.rs:101:9
|
||||
|
|
||||
LL | #![warn(clippy::into_iter_on_array)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter`
|
||||
|
||||
error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering`
|
||||
--> tests/ui/rename.rs:101:9
|
||||
--> tests/ui/rename.rs:102:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_atomic_ordering)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering`
|
||||
|
||||
error: lint `clippy::invalid_ref` has been renamed to `invalid_value`
|
||||
--> tests/ui/rename.rs:102:9
|
||||
--> tests/ui/rename.rs:103:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value`
|
||||
|
||||
error: lint `clippy::invalid_utf8_in_unchecked` has been renamed to `invalid_from_utf8_unchecked`
|
||||
--> tests/ui/rename.rs:103:9
|
||||
--> tests/ui/rename.rs:104:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_utf8_in_unchecked)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_from_utf8_unchecked`
|
||||
|
||||
error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop`
|
||||
--> tests/ui/rename.rs:104:9
|
||||
--> tests/ui/rename.rs:105:9
|
||||
|
|
||||
LL | #![warn(clippy::let_underscore_drop)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop`
|
||||
|
||||
error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
|
||||
--> tests/ui/rename.rs:105:9
|
||||
--> tests/ui/rename.rs:106:9
|
||||
|
|
||||
LL | #![warn(clippy::mem_discriminant_non_enum)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
|
||||
|
||||
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
|
||||
--> tests/ui/rename.rs:106:9
|
||||
--> tests/ui/rename.rs:107:9
|
||||
|
|
||||
LL | #![warn(clippy::panic_params)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
|
||||
|
||||
error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally`
|
||||
--> tests/ui/rename.rs:107:9
|
||||
--> tests/ui/rename.rs:108:9
|
||||
|
|
||||
LL | #![warn(clippy::positional_named_format_parameters)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally`
|
||||
|
||||
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
|
||||
--> tests/ui/rename.rs:108:9
|
||||
--> tests/ui/rename.rs:109:9
|
||||
|
|
||||
LL | #![warn(clippy::temporary_cstring_as_ptr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
|
||||
|
||||
error: lint `clippy::undropped_manually_drops` has been renamed to `undropped_manually_drops`
|
||||
--> tests/ui/rename.rs:109:9
|
||||
--> tests/ui/rename.rs:110:9
|
||||
|
|
||||
LL | #![warn(clippy::undropped_manually_drops)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `undropped_manually_drops`
|
||||
|
||||
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
|
||||
--> tests/ui/rename.rs:110:9
|
||||
--> tests/ui/rename.rs:111:9
|
||||
|
|
||||
LL | #![warn(clippy::unknown_clippy_lints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints`
|
||||
|
||||
error: lint `clippy::unused_label` has been renamed to `unused_labels`
|
||||
--> tests/ui/rename.rs:111:9
|
||||
--> tests/ui/rename.rs:112:9
|
||||
|
|
||||
LL | #![warn(clippy::unused_label)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
|
||||
|
||||
error: lint `clippy::vtable_address_comparisons` has been renamed to `ambiguous_wide_pointer_comparisons`
|
||||
--> tests/ui/rename.rs:112:9
|
||||
--> tests/ui/rename.rs:113:9
|
||||
|
|
||||
LL | #![warn(clippy::vtable_address_comparisons)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `ambiguous_wide_pointer_comparisons`
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::single_match)]
|
||||
#![allow(
|
||||
unused,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_if,
|
||||
clippy::redundant_guards,
|
||||
clippy::redundant_pattern_matching
|
||||
clippy::redundant_pattern_matching,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
fn dummy() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::single_match)]
|
||||
#![allow(
|
||||
unused,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_if,
|
||||
clippy::redundant_guards,
|
||||
clippy::redundant_pattern_matching
|
||||
clippy::redundant_pattern_matching,
|
||||
clippy::manual_unwrap_or_default
|
||||
)]
|
||||
fn dummy() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:16:5
|
||||
--> tests/ui/single_match.rs:15:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Some(y) => {
|
||||
|
|
@ -19,7 +19,7 @@ LL ~ };
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:24:5
|
||||
--> tests/ui/single_match.rs:23:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | // Note the missing block braces.
|
||||
|
|
@ -31,7 +31,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:33:5
|
||||
--> tests/ui/single_match.rs:32:5
|
||||
|
|
||||
LL | / match z {
|
||||
LL | | (2..=3, 7..=9) => dummy(),
|
||||
|
|
@ -40,7 +40,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let (2..=3, 7..=9) = z { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:62:5
|
||||
--> tests/ui/single_match.rs:61:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Some(y) => dummy(),
|
||||
|
|
@ -49,7 +49,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let Some(y) = x { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:67:5
|
||||
--> tests/ui/single_match.rs:66:5
|
||||
|
|
||||
LL | / match y {
|
||||
LL | | Ok(y) => dummy(),
|
||||
|
|
@ -58,7 +58,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let Ok(y) = y { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:74:5
|
||||
--> tests/ui/single_match.rs:73:5
|
||||
|
|
||||
LL | / match c {
|
||||
LL | | Cow::Borrowed(..) => dummy(),
|
||||
|
|
@ -67,7 +67,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let Cow::Borrowed(..) = c { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:95:5
|
||||
--> tests/ui/single_match.rs:94:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | "test" => println!(),
|
||||
|
|
@ -76,7 +76,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == "test" { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:108:5
|
||||
--> tests/ui/single_match.rs:107:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Foo::A => println!(),
|
||||
|
|
@ -85,7 +85,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == Foo::A { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:114:5
|
||||
--> tests/ui/single_match.rs:113:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | FOO_C => println!(),
|
||||
|
|
@ -94,7 +94,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == FOO_C { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:119:5
|
||||
--> tests/ui/single_match.rs:118:5
|
||||
|
|
||||
LL | / match &&x {
|
||||
LL | | Foo::A => println!(),
|
||||
|
|
@ -103,7 +103,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == Foo::A { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:125:5
|
||||
--> tests/ui/single_match.rs:124:5
|
||||
|
|
||||
LL | / match &x {
|
||||
LL | | Foo::A => println!(),
|
||||
|
|
@ -112,7 +112,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == &Foo::A { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:142:5
|
||||
--> tests/ui/single_match.rs:141:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Bar::A => println!(),
|
||||
|
|
@ -121,7 +121,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let Bar::A = x { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:150:5
|
||||
--> tests/ui/single_match.rs:149:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | None => println!(),
|
||||
|
|
@ -130,7 +130,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let None = x { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:172:5
|
||||
--> tests/ui/single_match.rs:171:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | (Some(_), _) => {},
|
||||
|
|
@ -139,7 +139,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let (Some(_), _) = x {}`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:178:5
|
||||
--> tests/ui/single_match.rs:177:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | (Some(E::V), _) => todo!(),
|
||||
|
|
@ -148,7 +148,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let (Some(E::V), _) = x { todo!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:184:5
|
||||
--> tests/ui/single_match.rs:183:5
|
||||
|
|
||||
LL | / match (Some(42), Some(E::V), Some(42)) {
|
||||
LL | | (.., Some(E::V), _) => {},
|
||||
|
|
@ -157,7 +157,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:256:5
|
||||
--> tests/ui/single_match.rs:255:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | Some(v) => unsafe {
|
||||
|
|
@ -177,7 +177,7 @@ LL + } }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:264:5
|
||||
--> tests/ui/single_match.rs:263:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | #[rustfmt::skip]
|
||||
|
|
|
|||
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