Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Use array slice instead of `Vec` in `find_macro_calls` as suggested by @ebroto

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
  • Loading branch information
dp304 and ebroto authored Dec 3, 2020
1 parent 69f83dd commit 69f69bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/panic_in_result_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {

fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) {
let panics = find_macro_calls(
vec![
&[
"unimplemented",
"unreachable",
"panic",
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ pub fn contains_return(expr: &hir::Expr<'_>) -> bool {
visitor.found
}

struct FindMacroCalls<'a> {
names: Vec<&'a str>,
struct FindMacroCalls<'a, 'b> {
names: &'a [&'b str],
result: Vec<Span>,
}

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

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

0 comments on commit 69f69bc

Please sign in to comment.