mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 09:27:25 +00:00
Auto merge of #6271 - camsteffen:vec-box-import, r=flip1995
Fix vec_box scope error changelog: Fix vec_box suggestion with wrong type scope Fixes #6236
This commit is contained in:
commit
b1faa7f002
4 changed files with 36 additions and 2 deletions
|
@ -553,7 +553,7 @@ impl Types {
|
|||
hir_ty.span,
|
||||
"`Vec<T>` is already on the heap, the boxing is unnecessary.",
|
||||
"try",
|
||||
format!("Vec<{}>", ty_ty),
|
||||
format!("Vec<{}>", snippet(cx, boxed_ty.span, "..")),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
return; // don't recurse into the type
|
||||
|
|
|
@ -35,4 +35,18 @@ mod should_not_trigger {
|
|||
}
|
||||
}
|
||||
|
||||
mod inner_mod {
|
||||
mod inner {
|
||||
pub struct S;
|
||||
}
|
||||
|
||||
mod inner2 {
|
||||
use super::inner::S;
|
||||
|
||||
pub fn f() -> Vec<S> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -35,4 +35,18 @@ mod should_not_trigger {
|
|||
}
|
||||
}
|
||||
|
||||
mod inner_mod {
|
||||
mod inner {
|
||||
pub struct S;
|
||||
}
|
||||
|
||||
mod inner2 {
|
||||
use super::inner::S;
|
||||
|
||||
pub fn f() -> Vec<Box<S>> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -18,5 +18,11 @@ error: `Vec<T>` is already on the heap, the boxing is unnecessary.
|
|||
LL | struct B(Vec<Vec<Box<(u32)>>>);
|
||||
| ^^^^^^^^^^^^^^^ help: try: `Vec<u32>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
|
||||
--> $DIR/vec_box_sized.rs:46:23
|
||||
|
|
||||
LL | pub fn f() -> Vec<Box<S>> {
|
||||
| ^^^^^^^^^^^ help: try: `Vec<S>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue