add no-rustfix since suggestions are invalid

This commit is contained in:
Jacherr 2023-11-08 21:15:11 +00:00
parent 67bb503f26
commit b6d56c47f9
3 changed files with 11 additions and 94 deletions

View file

@ -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() {}

View file

@ -1,3 +1,5 @@
//@no-rustfix
#![allow(dead_code)] #![allow(dead_code)]
#![feature(allocator_api)] #![feature(allocator_api)]

View file

@ -1,5 +1,5 @@
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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(); LL | const C: Vec<Box<i32>> = Vec::new();
| ^^^^^^^^^^^^^ help: try: `Vec<i32>` | ^^^^^^^^^^^^^ 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)]` = help: to override `-D warnings` add `#[allow(clippy::vec_box)]`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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(); LL | static S: Vec<Box<i32>> = Vec::new();
| ^^^^^^^^^^^^^ help: try: `Vec<i32>` | ^^^^^^^^^^^^^ help: try: `Vec<i32>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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>>, LL | sized_type: Vec<Box<SizedStruct>>,
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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>>); LL | struct A(Vec<Box<SizedStruct>>);
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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)>>>); LL | struct B(Vec<Vec<Box<(u32)>>>);
| ^^^^^^^^^^^^^^^ help: try: `Vec<u32>` | ^^^^^^^^^^^^^^^ help: try: `Vec<u32>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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> { LL | fn allocator_global_defined_vec() -> Vec<Box<i32>, std::alloc::Global> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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>> { LL | fn allocator_global_defined_box() -> Vec<Box<i32, std::alloc::Global>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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> { LL | fn allocator_match() -> Vec<Box<i32, DummyAllocator>, DummyAllocator> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<i32>`
error: `Vec<T>` is already on the heap, the boxing is unnecessary 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>> { LL | pub fn f() -> Vec<Box<S>> {
| ^^^^^^^^^^^ help: try: `Vec<S>` | ^^^^^^^^^^^ help: try: `Vec<S>`