Minor changes

This commit is contained in:
Red Rapious 2023-08-22 23:41:06 +02:00
parent 7977d209b2
commit e9a222beb5

View File

@ -74,9 +74,7 @@ fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>) {
&& let PatKind::Binding(BindingAnnotation::MUT, id, _, None) = local.pat.kind && let PatKind::Binding(BindingAnnotation::MUT, id, _, None) = local.pat.kind
&& !in_external_macro(cx.sess(), local.span) && !in_external_macro(cx.sess(), local.span)
&& let Some(init) = get_vec_init_kind(cx, init_expr) && let Some(init) = get_vec_init_kind(cx, init_expr)
&& !matches!(init, VecInitKind::WithExprCapacity(_) && !matches!(init, VecInitKind::WithExprCapacity(_) | VecInitKind::WithConstCapacity(_))
| VecInitKind::WithConstCapacity(_)
)
{ {
self.searcher = Some(VecReserveSearcher { self.searcher = Some(VecReserveSearcher {
local_id: id, local_id: id,
@ -93,13 +91,10 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if self.searcher.is_none() if self.searcher.is_none()
&& let ExprKind::Assign(left, right, _) = expr.kind && let ExprKind::Assign(left, right, _) = expr.kind
&& let ExprKind::Path(QPath::Resolved(None, path)) = left.kind && let ExprKind::Path(QPath::Resolved(None, path)) = left.kind
&& let [_] = &path.segments
&& let Res::Local(id) = path.res && let Res::Local(id) = path.res
&& !in_external_macro(cx.sess(), expr.span) && !in_external_macro(cx.sess(), expr.span)
&& let Some(init) = get_vec_init_kind(cx, right) && let Some(init) = get_vec_init_kind(cx, right)
&& !matches!(init, VecInitKind::WithExprCapacity(_) && !matches!(init, VecInitKind::WithExprCapacity(_) | VecInitKind::WithConstCapacity(_))
| VecInitKind::WithConstCapacity(_)
)
{ {
self.searcher = Some(VecReserveSearcher { self.searcher = Some(VecReserveSearcher {
local_id: id, local_id: id,
@ -122,7 +117,7 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
{ {
self.searcher = Some(VecReserveSearcher { self.searcher = Some(VecReserveSearcher {
err_span: searcher.err_span.to(stmt.span), err_span: searcher.err_span.to(stmt.span),
space_hint: snippet(cx, space_hint.span, "..").to_string(), space_hint: snippet(cx, space_hint.span, "..").into_owned(),
.. searcher .. searcher
}); });
} else { } else {