Apply suggestions from code review
Use array slice instead of `Vec` in `find_macro_calls` as suggested by @ebroto Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
This commit is contained in:
parent
e58c7dd168
commit
bdad7900f4
@ -53,7 +53,7 @@ fn check_fn(
|
|||||||
|
|
||||||
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) {
|
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) {
|
||||||
let panics = find_macro_calls(
|
let panics = find_macro_calls(
|
||||||
vec![
|
&[
|
||||||
"unimplemented",
|
"unimplemented",
|
||||||
"unreachable",
|
"unreachable",
|
||||||
"panic",
|
"panic",
|
||||||
|
@ -603,12 +603,12 @@ fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
|
|||||||
visitor.found
|
visitor.found
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FindMacroCalls<'a> {
|
struct FindMacroCalls<'a, 'b> {
|
||||||
names: Vec<&'a str>,
|
names: &'a [&'b str],
|
||||||
result: Vec<Span>,
|
result: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Visitor<'tcx> for FindMacroCalls<'a> {
|
impl<'a, 'b, 'tcx> Visitor<'tcx> for FindMacroCalls<'a, 'b> {
|
||||||
type Map = Map<'tcx>;
|
type Map = Map<'tcx>;
|
||||||
|
|
||||||
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
|
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
|
||||||
@ -625,7 +625,7 @@ fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Finds calls of the specified macros in a function body.
|
/// 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 {
|
let mut fmc = FindMacroCalls {
|
||||||
names,
|
names,
|
||||||
result: Vec::new(),
|
result: Vec::new(),
|
||||||
|
Loading…
Reference in New Issue
Block a user