mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Fix FN in iter_cloned_collect
with a large array
This commit is contained in:
parent
a362a4d1d0
commit
d7627dcfc8
@ -18,9 +18,7 @@ pub(super) fn derefs_to_slice<'tcx>(
|
||||
ty::Slice(_) => true,
|
||||
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
|
||||
ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::vec_type),
|
||||
ty::Array(_, size) => size
|
||||
.try_eval_usize(cx.tcx, cx.param_env)
|
||||
.map_or(false, |size| size < 32),
|
||||
ty::Array(_, size) => size.try_eval_usize(cx.tcx, cx.param_env).is_some(),
|
||||
ty::Ref(_, inner, _) => may_slice(cx, inner),
|
||||
_ => false,
|
||||
}
|
||||
|
@ -19,4 +19,8 @@ fn main() {
|
||||
let _: Vec<u8> = std::ffi::CStr::from_ptr(std::ptr::null())
|
||||
.to_bytes().to_vec();
|
||||
}
|
||||
|
||||
// Issue #6808
|
||||
let arr: [u8; 64] = [0; 64];
|
||||
let _: Vec<_> = arr.to_vec();
|
||||
}
|
||||
|
@ -22,4 +22,8 @@ fn main() {
|
||||
.cloned()
|
||||
.collect();
|
||||
}
|
||||
|
||||
// Issue #6808
|
||||
let arr: [u8; 64] = [0; 64];
|
||||
let _: Vec<_> = arr.iter().cloned().collect();
|
||||
}
|
||||
|
@ -22,5 +22,11 @@ LL | | .cloned()
|
||||
LL | | .collect();
|
||||
| |______________________^ help: try: `.to_vec()`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
|
||||
--> $DIR/iter_cloned_collect.rs:28:24
|
||||
|
|
||||
LL | let _: Vec<_> = arr.iter().cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user