Skip to content

Commit 69f69bc

Browse files
dp304ebroto
andauthored
Apply suggestions from code review
Use array slice instead of `Vec` in `find_macro_calls` as suggested by @ebroto Co-authored-by: Eduardo Broto <[email protected]>
1 parent 69f83dd commit 69f69bc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clippy_lints/src/panic_in_result_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {
5353

5454
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) {
5555
let panics = find_macro_calls(
56-
vec![
56+
&[
5757
"unimplemented",
5858
"unreachable",
5959
"panic",

clippy_lints/src/utils/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ pub fn contains_return(expr: &hir::Expr<'_>) -> bool {
602602
visitor.found
603603
}
604604

605-
struct FindMacroCalls<'a> {
606-
names: Vec<&'a str>,
605+
struct FindMacroCalls<'a, 'b> {
606+
names: &'a [&'b str],
607607
result: Vec<Span>,
608608
}
609609

@@ -624,7 +624,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindMacroCalls<'a> {
624624
}
625625

626626
/// Finds calls of the specified macros in a function body.
627-
pub fn find_macro_calls(names: Vec<&str>, body: &'tcx Body<'tcx>) -> Vec<Span> {
627+
pub fn find_macro_calls(names: &[&str], body: &Body<'_>) -> Vec<Span> {
628628
let mut fmc = FindMacroCalls {
629629
names,
630630
result: Vec::new(),

0 commit comments

Comments
 (0)