Skip to content

Commit 6934f67

Browse files
committed
misc: return earlier on name = None
1 parent 99fc4f5 commit 6934f67

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clippy_utils/src/higher.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,21 @@ impl<'a> VecArgs<'a> {
287287
&& let ExprKind::Path(ref qpath) = fun.kind
288288
&& is_expn_of(fun.span, sym::vec).is_some()
289289
&& let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id()
290+
&& let Some(name) = cx.tcx.get_diagnostic_name(fun_def_id)
290291
{
291-
return match (cx.tcx.get_diagnostic_name(fun_def_id), args) {
292-
(Some(sym::vec_from_elem), [elem, size]) => {
292+
return match (name, args) {
293+
(sym::vec_from_elem, [elem, size]) => {
293294
// `vec![elem; size]` case
294295
Some(VecArgs::Repeat(elem, size))
295296
},
296-
(Some(sym::slice_into_vec), [slice])
297+
(sym::slice_into_vec, [slice])
297298
if let ExprKind::Call(_, [arg]) = slice.kind
298299
&& let ExprKind::Array(args) = arg.kind =>
299300
{
300301
// `vec![a, b, c]` case
301302
Some(VecArgs::Vec(args))
302303
},
303-
(Some(sym::vec_new), []) => Some(VecArgs::Vec(&[])),
304+
(sym::vec_new, []) => Some(VecArgs::Vec(&[])),
304305
_ => None,
305306
};
306307
}

0 commit comments

Comments
 (0)