Skip to content

Commit 6544a63

Browse files
dp304ebroto
andcommitted
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 3a668a8 commit 6544a63

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,12 @@ pub fn contains_return(expr: &hir::Expr<'_>) -> bool {
603603
visitor.found
604604
}
605605

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

611-
impl<'a, 'tcx> Visitor<'tcx> for FindMacroCalls<'a> {
611+
impl<'a, 'b, 'tcx> Visitor<'tcx> for FindMacroCalls<'a, 'b> {
612612
type Map = Map<'tcx>;
613613

614614
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
@@ -625,7 +625,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindMacroCalls<'a> {
625625
}
626626

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

0 commit comments

Comments
 (0)