Skip to content

Commit 5cf9c34

Browse files
authored
Rollup merge of rust-lang#108516 - clubby789:rustc-box-restrict, r=compiler-errors
Restrict `#[rustc_box]` to `Box::new` calls Currently, `#[rustc_box]` can be applied to any call expression with a single argument. This PR only allows it to be applied to calls to `Box::new`
2 parents 0966f59 + 702a83b commit 5cf9c34

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

clippy_utils/src/higher.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,12 @@ impl<'a> VecArgs<'a> {
287287
Some(VecArgs::Repeat(&args[0], &args[1]))
288288
} else if match_def_path(cx, fun_def_id, &paths::SLICE_INTO_VEC) && args.len() == 1 {
289289
// `vec![a, b, c]` case
290-
if_chain! {
291-
if let hir::ExprKind::Box(boxed) = args[0].kind;
292-
if let hir::ExprKind::Array(args) = boxed.kind;
293-
then {
294-
return Some(VecArgs::Vec(args));
295-
}
290+
if let hir::ExprKind::Call(_, [arg]) = &args[0].kind
291+
&& let hir::ExprKind::Array(args) = arg.kind {
292+
Some(VecArgs::Vec(args))
293+
} else {
294+
None
296295
}
297-
298-
None
299296
} else if match_def_path(cx, fun_def_id, &paths::VEC_NEW) && args.is_empty() {
300297
Some(VecArgs::Vec(&[]))
301298
} else {

0 commit comments

Comments
 (0)