Skip to content

Commit

Permalink
Restrict #[rustc_box] to Box::new calls
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Mar 2, 2023
1 parent 2e2e45a commit 702a83b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions clippy_utils/src/higher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,12 @@ impl<'a> VecArgs<'a> {
Some(VecArgs::Repeat(&args[0], &args[1]))
} else if match_def_path(cx, fun_def_id, &paths::SLICE_INTO_VEC) && args.len() == 1 {
// `vec![a, b, c]` case
if_chain! {
if let hir::ExprKind::Box(boxed) = args[0].kind;
if let hir::ExprKind::Array(args) = boxed.kind;
then {
return Some(VecArgs::Vec(args));
}
if let hir::ExprKind::Call(_, [arg]) = &args[0].kind
&& let hir::ExprKind::Array(args) = arg.kind {
Some(VecArgs::Vec(args))
} else {
None
}

None
} else if match_def_path(cx, fun_def_id, &paths::VEC_NEW) && args.is_empty() {
Some(VecArgs::Vec(&[]))
} else {
Expand Down

0 comments on commit 702a83b

Please sign in to comment.