diff options
| author | Jacherr <jwc2002@outlook.com> | 2023-11-08 21:15:11 +0000 |
|---|---|---|
| committer | Jacherr <jwc2002@outlook.com> | 2023-11-08 21:15:11 +0000 |
| commit | b6d56c47f9d62a456fc2affaad71f9120c1a8059 (patch) | |
| tree | 94c2d9f90246b48e946d488ca0ccf1eed7f37904 | |
| parent | 67bb503f26ad5d695229153995bd2ab296e590cb (diff) | |
| download | rust-b6d56c47f9d62a456fc2affaad71f9120c1a8059.tar.gz rust-b6d56c47f9d62a456fc2affaad71f9120c1a8059.zip | |
add no-rustfix since suggestions are invalid
| -rw-r--r-- | tests/ui/vec_box_sized.fixed | 85 | ||||
| -rw-r--r-- | tests/ui/vec_box_sized.rs | 2 | ||||
| -rw-r--r-- | tests/ui/vec_box_sized.stderr | 18 |
3 files changed, 11 insertions, 94 deletions
diff --git a/tests/ui/vec_box_sized.fixed b/tests/ui/vec_box_sized.fixed deleted file mode 100644 index 0be891a92bc..00000000000 --- a/tests/ui/vec_box_sized.fixed +++ /dev/null @@ -1,85 +0,0 @@ -#![allow(dead_code)] -#![feature(allocator_api)] - -use std::alloc::{Layout, AllocError, Allocator}; -use std::ptr::NonNull; - -struct SizedStruct(i32); -struct UnsizedStruct([i32]); -struct BigStruct([i32; 10000]); - -struct DummyAllocator; -unsafe impl Allocator for DummyAllocator { - fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { - todo!() - } - unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { - todo!() - } -} - -/// The following should trigger the lint -mod should_trigger { - use super::{SizedStruct, DummyAllocator}; - const C: Vec<i32> = Vec::new(); - static S: Vec<i32> = Vec::new(); - - struct StructWithVecBox { - sized_type: Vec<SizedStruct>, - } - - struct A(Vec<SizedStruct>); - struct B(Vec<Vec<u32>>); - - fn allocator_global_defined_vec() -> Vec<i32> { - Vec::new() - } - fn allocator_global_defined_box() -> Vec<i32> { - Vec::new() - } - fn allocator_match() -> Vec<i32> { - Vec::new_in(DummyAllocator) - } -} - -/// The following should not trigger the lint -mod should_not_trigger { - use super::{BigStruct, UnsizedStruct, DummyAllocator}; - - struct C(Vec<Box<UnsizedStruct>>); - struct D(Vec<Box<BigStruct>>); - - struct StructWithVecBoxButItsUnsized { - unsized_type: Vec<Box<UnsizedStruct>>, - } - - struct TraitVec<T: ?Sized> { - // Regression test for #3720. This was causing an ICE. - inner: Vec<Box<T>>, - } - - fn allocator_mismatch() -> Vec<Box<i32, DummyAllocator>> { - Vec::new() - } -} - -mod inner_mod { - mod inner { - pub struct S; - } - - mod inner2 { - use super::inner::S; - - pub fn f() -> Vec<S> { - vec![] - } - } -} - -// https://github.com/rust-lang/rust-clippy/issues/11417 -fn in_closure() { - let _ = |_: Vec<Box<dyn ToString>>| {}; -} - -fn main() {} diff --git a/tests/ui/vec_box_sized.rs b/tests/ui/vec_box_sized.rs index 9314195b103..af471f1eb8d 100644 --- a/tests/ui/vec_box_sized.rs +++ b/tests/ui/vec_box_sized.rs @@ -1,3 +1,5 @@ +//@no-rustfix + #![allow(dead_code)] #![feature(allocator_api)] diff --git a/tests/ui/vec_box_sized.stderr b/tests/ui/vec_box_sized.stderr index 2fa5679650b..db5674210d9 100644 --- a/tests/ui/vec_box_sized.stderr +++ b/tests/ui/vec_box_sized.stderr @@ -1,5 +1,5 @@ error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:24:14 + --> $DIR/vec_box_sized.rs:26:14 | LL | const C: Vec<Box<i32>> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec<i32>` @@ -8,49 +8,49 @@ LL | const C: Vec<Box<i32>> = Vec::new(); = help: to override `-D warnings` add `#[allow(clippy::vec_box)]` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:25:15 + --> $DIR/vec_box_sized.rs:27:15 | LL | static S: Vec<Box<i32>> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec<i32>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:28:21 + --> $DIR/vec_box_sized.rs:30:21 | LL | sized_type: Vec<Box<SizedStruct>>, | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:31:14 + --> $DIR/vec_box_sized.rs:33:14 | LL | struct A(Vec<Box<SizedStruct>>); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:32:18 + --> $DIR/vec_box_sized.rs:34:18 | LL | struct B(Vec<Vec<Box<(u32)>>>); | ^^^^^^^^^^^^^^^ help: try: `Vec<u32>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:34:42 + --> $DIR/vec_box_sized.rs:36:42 | LL | fn allocator_global_defined_vec() -> Vec<Box<i32>, std::alloc::Global> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:37:42 + --> $DIR/vec_box_sized.rs:39:42 | LL | fn allocator_global_defined_box() -> Vec<Box<i32, std::alloc::Global>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:40:29 + --> $DIR/vec_box_sized.rs:42:29 | LL | fn allocator_match() -> Vec<Box<i32, DummyAllocator>, DummyAllocator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>` error: `Vec<T>` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:74:23 + --> $DIR/vec_box_sized.rs:76:23 | LL | pub fn f() -> Vec<Box<S>> { | ^^^^^^^^^^^ help: try: `Vec<S>` |
