adjust clippy to fix some of the issues
This commit is contained in:
parent
5e65109f21
commit
e5ed8643b6
13 changed files with 47 additions and 47 deletions
|
|
@ -2181,7 +2181,6 @@ symbols! {
|
|||
slice_from_raw_parts_mut,
|
||||
slice_from_ref,
|
||||
slice_get_unchecked,
|
||||
slice_into_vec,
|
||||
slice_iter,
|
||||
slice_len_fn,
|
||||
slice_patterns,
|
||||
|
|
|
|||
|
|
@ -259,6 +259,7 @@ unsafe fn box_new_uninit(size: usize, align: usize) -> *mut u8 {
|
|||
#[unstable(feature = "liballoc_internals", issue = "none")]
|
||||
#[inline(always)]
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[rustc_diagnostic_item = "box_assume_init_into_vec_unsafe"]
|
||||
pub fn box_assume_init_into_vec_unsafe<T, const N: usize>(
|
||||
b: Box<MaybeUninit<[T; N]>>,
|
||||
) -> crate::vec::Vec<T> {
|
||||
|
|
|
|||
|
|
@ -477,7 +477,6 @@ impl<T> [T] {
|
|||
#[rustc_allow_incoherent_impl]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[rustc_diagnostic_item = "slice_into_vec"]
|
||||
pub fn into_vec<A: Allocator>(self: Box<Self, A>) -> Vec<T, A> {
|
||||
unsafe {
|
||||
let len = self.len();
|
||||
|
|
|
|||
|
|
@ -297,12 +297,12 @@ impl<'a> VecArgs<'a> {
|
|||
// `vec![elem; size]` case
|
||||
Some(VecArgs::Repeat(elem, size))
|
||||
},
|
||||
(sym::slice_into_vec, [slice])
|
||||
if let ExprKind::Call(_, [arg]) = slice.kind
|
||||
&& let ExprKind::Array(args) = arg.kind =>
|
||||
(sym::box_assume_init_into_vec_unsafe, [write_box_via_move])
|
||||
if let ExprKind::Call(_, [_box, elems]) = write_box_via_move.kind
|
||||
&& let ExprKind::Array(elems) = elems.kind =>
|
||||
{
|
||||
// `vec![a, b, c]` case
|
||||
Some(VecArgs::Vec(args))
|
||||
Some(VecArgs::Vec(elems))
|
||||
},
|
||||
(sym::vec_new, []) => Some(VecArgs::Vec(&[])),
|
||||
_ => None,
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ generate! {
|
|||
author,
|
||||
borrow,
|
||||
borrow_mut,
|
||||
box_assume_init_into_vec_unsafe,
|
||||
build_hasher,
|
||||
by_ref,
|
||||
bytes,
|
||||
|
|
|
|||
|
|
@ -113,10 +113,7 @@ fn main() {
|
|||
}
|
||||
|
||||
// #6811
|
||||
match Some(0) {
|
||||
Some(x) => Some(vec![x]),
|
||||
None => None,
|
||||
};
|
||||
Some(0).map(|x| vec![x]);
|
||||
|
||||
// Don't lint, coercion
|
||||
let x: Option<Vec<&[u8]>> = match Some(()) {
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ fn main() {
|
|||
|
||||
// #6811
|
||||
match Some(0) {
|
||||
//~^ manual_map
|
||||
Some(x) => Some(vec![x]),
|
||||
None => None,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -173,7 +173,17 @@ LL | | };
|
|||
| |_____^ help: try: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:196:5
|
||||
--> tests/ui/manual_map_option.rs:185:5
|
||||
|
|
||||
LL | / match Some(0) {
|
||||
LL | |
|
||||
LL | | Some(x) => Some(vec![x]),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try: `Some(0).map(|x| vec![x])`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:197:5
|
||||
|
|
||||
LL | / match option_env!("") {
|
||||
LL | |
|
||||
|
|
@ -183,7 +193,7 @@ LL | | };
|
|||
| |_____^ help: try: `option_env!("").map(String::from)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:217:12
|
||||
--> tests/ui/manual_map_option.rs:218:12
|
||||
|
|
||||
LL | } else if let Some(x) = Some(0) {
|
||||
| ____________^
|
||||
|
|
@ -195,7 +205,7 @@ LL | | };
|
|||
| |_____^ help: try: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:226:12
|
||||
--> tests/ui/manual_map_option.rs:227:12
|
||||
|
|
||||
LL | } else if let Some(x) = Some(0) {
|
||||
| ____________^
|
||||
|
|
@ -206,5 +216,5 @@ LL | | None
|
|||
LL | | };
|
||||
| |_____^ help: try: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
error: aborting due to 21 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ fn or_fun_call() {
|
|||
with_constructor.unwrap_or_else(make);
|
||||
//~^ or_fun_call
|
||||
|
||||
let with_new = Some(vec![1]);
|
||||
let with_new: Option<Vec<i32>> = Some(vec![1]);
|
||||
with_new.unwrap_or_default();
|
||||
//~^ unwrap_or_default
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ fn or_fun_call() {
|
|||
real_default.unwrap_or_default();
|
||||
//~^ unwrap_or_default
|
||||
|
||||
let with_vec = Some(vec![1]);
|
||||
let with_vec: Option<Vec<i32>> = Some(vec![1]);
|
||||
with_vec.unwrap_or_default();
|
||||
//~^ unwrap_or_default
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ mod lazy {
|
|||
}
|
||||
}
|
||||
|
||||
let with_new = Some(vec![1]);
|
||||
let with_new: Option<Vec<i32>> = Some(vec![1]);
|
||||
with_new.unwrap_or_default();
|
||||
//~^ unwrap_or_default
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ fn or_fun_call() {
|
|||
with_constructor.unwrap_or(make());
|
||||
//~^ or_fun_call
|
||||
|
||||
let with_new = Some(vec![1]);
|
||||
let with_new: Option<Vec<i32>> = Some(vec![1]);
|
||||
with_new.unwrap_or(Vec::new());
|
||||
//~^ unwrap_or_default
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ fn or_fun_call() {
|
|||
real_default.unwrap_or(<FakeDefault as Default>::default());
|
||||
//~^ unwrap_or_default
|
||||
|
||||
let with_vec = Some(vec![1]);
|
||||
let with_vec: Option<Vec<i32>> = Some(vec![1]);
|
||||
with_vec.unwrap_or(Vec::new());
|
||||
//~^ unwrap_or_default
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ mod lazy {
|
|||
}
|
||||
}
|
||||
|
||||
let with_new = Some(vec![1]);
|
||||
let with_new: Option<Vec<i32>> = Some(vec![1]);
|
||||
with_new.unwrap_or_else(Vec::new);
|
||||
//~^ unwrap_or_default
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ fn unwrap_or_else_default() {
|
|||
with_enum.unwrap_or_else(Enum::A);
|
||||
|
||||
let with_new = Some(vec![1]);
|
||||
with_new.unwrap_or_default();
|
||||
//~^ unwrap_or_default
|
||||
with_new.unwrap_or_else(Vec::new);
|
||||
|
||||
let with_err: Result<_, ()> = Ok(vec![1]);
|
||||
with_err.unwrap_or_else(make);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ fn unwrap_or_else_default() {
|
|||
|
||||
let with_new = Some(vec![1]);
|
||||
with_new.unwrap_or_else(Vec::new);
|
||||
//~^ unwrap_or_default
|
||||
|
||||
let with_err: Result<_, ()> = Ok(vec![1]);
|
||||
with_err.unwrap_or_else(make);
|
||||
|
|
|
|||
|
|
@ -1,101 +1,95 @@
|
|||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:46:14
|
||||
--> tests/ui/unwrap_or_else_default.rs:60:23
|
||||
|
|
||||
LL | with_new.unwrap_or_else(Vec::new);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
LL | with_real_default.unwrap_or_else(<HasDefaultAndDuplicate as Default>::default);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
|
||||
= note: `-D clippy::unwrap-or-default` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unwrap_or_default)]`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:61:23
|
||||
|
|
||||
LL | with_real_default.unwrap_or_else(<HasDefaultAndDuplicate as Default>::default);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:65:24
|
||||
--> tests/ui/unwrap_or_else_default.rs:64:24
|
||||
|
|
||||
LL | with_default_trait.unwrap_or_else(Default::default);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:69:23
|
||||
--> tests/ui/unwrap_or_else_default.rs:68:23
|
||||
|
|
||||
LL | with_default_type.unwrap_or_else(u64::default);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:73:23
|
||||
--> tests/ui/unwrap_or_else_default.rs:72:23
|
||||
|
|
||||
LL | with_default_type.unwrap_or_else(Vec::new);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:77:18
|
||||
--> tests/ui/unwrap_or_else_default.rs:76:18
|
||||
|
|
||||
LL | empty_string.unwrap_or_else(|| "".to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:82:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:81:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:86:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:85:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:90:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:89:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:94:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:93:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:98:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:97:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:102:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:101:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:106:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:105:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:110:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:109:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or_else` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:127:12
|
||||
--> tests/ui/unwrap_or_else_default.rs:126:12
|
||||
|
|
||||
LL | option.unwrap_or_else(Vec::new).push(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
||||
|
||||
error: use of `or_insert_with` to construct default value
|
||||
--> tests/ui/unwrap_or_else_default.rs:145:32
|
||||
--> tests/ui/unwrap_or_else_default.rs:144:32
|
||||
|
|
||||
LL | let _ = inner_map.entry(0).or_insert_with(Default::default);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()`
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue