Skip to content

Commit 1751d24

Browse files
committed
Run rustfmt on clippy_lints
1 parent 5c5e8cc commit 1751d24

File tree

134 files changed

+2977
-2703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+2977
-2703
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
use crate::utils::span_lint;
1210
use crate::rustc::hir::*;
1311
use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
1412
use crate::rustc::{declare_tool_lint, lint_array};
15-
use std::f64::consts as f64;
1613
use crate::syntax::ast::{FloatTy, Lit, LitKind};
1714
use crate::syntax::symbol;
15+
use crate::utils::span_lint;
16+
use std::f64::consts as f64;
1817

1918
/// **What it does:** Checks for floating point literals that approximate
2019
/// constants which are defined in

clippy_lints/src/arithmetic.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
use crate::utils::span_lint;
1210
use crate::rustc::hir;
1311
use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
1412
use crate::rustc::{declare_tool_lint, lint_array};
1513
use crate::syntax::source_map::Span;
14+
use crate::utils::span_lint;
1615

1716
/// **What it does:** Checks for plain integer arithmetic.
1817
///
@@ -52,7 +51,8 @@ declare_clippy_lint! {
5251
#[derive(Copy, Clone, Default)]
5352
pub struct Arithmetic {
5453
expr_span: Option<Span>,
55-
/// This field is used to check whether expressions are constants, such as in enum discriminants and consts
54+
/// This field is used to check whether expressions are constants, such as in enum discriminants
55+
/// and consts
5656
const_span: Option<Span>,
5757
}
5858

@@ -124,8 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
124124
let body_owner = cx.tcx.hir.body_owner(body.id());
125125

126126
match cx.tcx.hir.body_owner_kind(body_owner) {
127-
hir::BodyOwnerKind::Static(_)
128-
| hir::BodyOwnerKind::Const => {
127+
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const => {
129128
let body_span = cx.tcx.hir.span(body_owner);
130129

131130
if let Some(span) = self.const_span {
@@ -134,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
134133
}
135134
}
136135
self.const_span = Some(body_span);
137-
}
136+
},
138137
hir::BodyOwnerKind::Fn => (),
139138
}
140139
}

clippy_lints/src/assign_ops.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
use crate::utils::{get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, SpanlessEq};
12-
use crate::utils::{higher, sugg};
1310
use crate::rustc::hir;
1411
use crate::rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
1512
use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
1613
use crate::rustc::{declare_tool_lint, lint_array};
17-
use if_chain::if_chain;
18-
use crate::syntax::ast;
1914
use crate::rustc_errors::Applicability;
15+
use crate::syntax::ast;
16+
use crate::utils::{get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, SpanlessEq};
17+
use crate::utils::{higher, sugg};
18+
use if_chain::if_chain;
2019

2120
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
2221
/// patterns.
@@ -217,7 +216,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
217216
// a = b commutative_op a
218217
// Limited to primitive type as these ops are know to be commutative
219218
if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, r)
220-
&& cx.tables.expr_ty(assignee).is_primitive_ty() {
219+
&& cx.tables.expr_ty(assignee).is_primitive_ty()
220+
{
221221
match op.node {
222222
hir::BinOpKind::Add
223223
| hir::BinOpKind::Mul

clippy_lints/src/attrs.rs

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,24 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
//! checks for attributes
1211
1312
use crate::reexport::*;
14-
use crate::utils::{
15-
in_macro, last_line_of_span, match_def_path, opt_def_id, paths, snippet_opt, span_lint, span_lint_and_sugg,
16-
span_lint_and_then, without_block_comments,
17-
};
18-
use if_chain::if_chain;
1913
use crate::rustc::hir::*;
2014
use crate::rustc::lint::{
2115
CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintContext, LintPass,
2216
};
2317
use crate::rustc::ty::{self, TyCtxt};
2418
use crate::rustc::{declare_tool_lint, lint_array};
25-
use semver::Version;
26-
use crate::syntax::ast::{
27-
AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind,
28-
};
29-
use crate::syntax::source_map::Span;
3019
use crate::rustc_errors::Applicability;
20+
use crate::syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
21+
use crate::syntax::source_map::Span;
22+
use crate::utils::{
23+
in_macro, last_line_of_span, match_def_path, opt_def_id, paths, snippet_opt, span_lint, span_lint_and_sugg,
24+
span_lint_and_then, without_block_comments,
25+
};
26+
use if_chain::if_chain;
27+
use semver::Version;
3128

3229
/// **What it does:** Checks for items annotated with `#[inline(always)]`,
3330
/// unless the annotated function is empty or simply panics.
@@ -219,8 +216,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
219216
match &*attr.name().as_str() {
220217
"allow" | "warn" | "deny" | "forbid" => {
221218
check_clippy_lint_names(cx, items);
222-
}
223-
_ => {}
219+
},
220+
_ => {},
224221
}
225222
if items.is_empty() || attr.name() != "deprecated" {
226223
return;
@@ -254,19 +251,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
254251
// and `unused_imports` for `extern crate` items with `macro_use`
255252
for lint in lint_list {
256253
match item.node {
257-
ItemKind::Use(..) => if is_word(lint, "unused_imports")
258-
|| is_word(lint, "deprecated") {
259-
return
254+
ItemKind::Use(..) => {
255+
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
256+
return;
257+
}
260258
},
261259
ItemKind::ExternCrate(..) => {
262-
if is_word(lint, "unused_imports")
263-
&& skip_unused_imports {
264-
return
260+
if is_word(lint, "unused_imports") && skip_unused_imports {
261+
return;
265262
}
266263
if is_word(lint, "unused_extern_crates") {
267-
return
264+
return;
268265
}
269-
}
266+
},
270267
_ => {},
271268
}
272269
}
@@ -396,14 +393,16 @@ fn is_relevant_expr(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>, expr
396393
ExprKind::Block(ref block, _) => is_relevant_block(tcx, tables, block),
397394
ExprKind::Ret(Some(ref e)) => is_relevant_expr(tcx, tables, e),
398395
ExprKind::Ret(None) | ExprKind::Break(_, None) => false,
399-
ExprKind::Call(ref path_expr, _) => if let ExprKind::Path(ref qpath) = path_expr.node {
400-
if let Some(fun_id) = opt_def_id(tables.qpath_def(qpath, path_expr.hir_id)) {
401-
!match_def_path(tcx, fun_id, &paths::BEGIN_PANIC)
396+
ExprKind::Call(ref path_expr, _) => {
397+
if let ExprKind::Path(ref qpath) = path_expr.node {
398+
if let Some(fun_id) = opt_def_id(tables.qpath_def(qpath, path_expr.hir_id)) {
399+
!match_def_path(tcx, fun_id, &paths::BEGIN_PANIC)
400+
} else {
401+
true
402+
}
402403
} else {
403404
true
404405
}
405-
} else {
406-
true
407406
},
408407
_ => true,
409408
}
@@ -435,7 +434,8 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
435434
cx,
436435
EMPTY_LINE_AFTER_OUTER_ATTR,
437436
begin_of_attr_to_item,
438-
"Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?"
437+
"Found an empty line after an outer attribute. \
438+
Perhaps you forgot to add a '!' to make it an inner attribute?",
439439
);
440440
}
441441
}
@@ -501,9 +501,7 @@ pub struct CfgAttrPass;
501501

502502
impl LintPass for CfgAttrPass {
503503
fn get_lints(&self) -> LintArray {
504-
lint_array!(
505-
DEPRECATED_CFG_ATTR,
506-
)
504+
lint_array!(DEPRECATED_CFG_ATTR,)
507505
}
508506
}
509507

0 commit comments

Comments
 (0)