Skip to content

Commit ed58976

Browse files
authored
Merge pull request #2202 from topecongiro/format
Run `cargo fmt`
2 parents fdeaf80 + a6c71e9 commit ed58976

Some content is hidden

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

63 files changed

+804
-613
lines changed

clippy_lints/src/array_indexing.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,19 @@ fn to_const_range(
120120
array_size: ConstInt,
121121
) -> Option<(ConstInt, ConstInt)> {
122122
let start = match *start {
123-
Some(Some(&ty::Const { val: ConstVal::Integral(x), .. })) => x,
123+
Some(Some(&ty::Const {
124+
val: ConstVal::Integral(x),
125+
..
126+
})) => x,
124127
Some(_) => return None,
125128
None => ConstInt::U8(0),
126129
};
127130

128131
let end = match *end {
129-
Some(Some(&ty::Const { val: ConstVal::Integral(x), .. })) => if limits == RangeLimits::Closed {
132+
Some(Some(&ty::Const {
133+
val: ConstVal::Integral(x),
134+
..
135+
})) => if limits == RangeLimits::Closed {
130136
match x {
131137
ConstInt::U8(_) => (x + ConstInt::U8(1)),
132138
ConstInt::U16(_) => (x + ConstInt::U16(1)),

clippy_lints/src/assign_ops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
143143
if_chain! {
144144
if parent_impl != ast::CRATE_NODE_ID;
145145
if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl);
146-
if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node;
146+
if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) =
147+
item.node;
147148
if trait_ref.path.def.def_id() == trait_id;
148149
then { return; }
149150
}

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc::ty::{self, TyCtxt};
77
use semver::Version;
88
use syntax::ast::{Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
99
use syntax::codemap::Span;
10-
use utils::{in_macro, match_def_path, paths, snippet_opt, span_lint, span_lint_and_then, opt_def_id};
10+
use utils::{in_macro, match_def_path, opt_def_id, paths, snippet_opt, span_lint, span_lint_and_then};
1111

1212
/// **What it does:** Checks for items annotated with `#[inline(always)]`,
1313
/// unless the annotated function is empty or simply panics.

clippy_lints/src/block_in_if_condition.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
7373

7474
const BRACED_EXPR_MESSAGE: &str = "omit braces around single expression condition";
7575
const COMPLEX_BLOCK_MESSAGE: &str = "in an 'if' condition, avoid complex blocks or closures with blocks; \
76-
instead, move the block or closure higher and bind it with a 'let'";
76+
instead, move the block or closure higher and bind it with a 'let'";
7777

7878
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
7979
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
@@ -92,9 +92,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
9292
BLOCK_IN_IF_CONDITION_EXPR,
9393
check.span,
9494
BRACED_EXPR_MESSAGE,
95-
&format!("try\nif {} {} ... ",
96-
snippet_block(cx, ex.span, ".."),
97-
snippet_block(cx, then.span, "..")),
95+
&format!(
96+
"try\nif {} {} ... ",
97+
snippet_block(cx, ex.span, ".."),
98+
snippet_block(cx, then.span, "..")
99+
),
98100
);
99101
}
100102
} else {
@@ -111,9 +113,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
111113
BLOCK_IN_IF_CONDITION_STMT,
112114
check.span,
113115
COMPLEX_BLOCK_MESSAGE,
114-
&format!("try\nlet res = {};\nif res {} ... ",
115-
snippet_block(cx, block.span, ".."),
116-
snippet_block(cx, then.span, "..")),
116+
&format!(
117+
"try\nlet res = {};\nif res {} ... ",
118+
snippet_block(cx, block.span, ".."),
119+
snippet_block(cx, then.span, "..")
120+
),
117121
);
118122
}
119123
}

clippy_lints/src/booleans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
368368
}
369369
// if the number of occurrences of a terminal decreases or any of the stats
370370
// decreases while none increases
371-
improvement |= (stats.terminals[i] > simplified_stats.terminals[i]) ||
372-
(stats.negations > simplified_stats.negations && stats.ops == simplified_stats.ops) ||
373-
(stats.ops > simplified_stats.ops && stats.negations == simplified_stats.negations);
371+
improvement |= (stats.terminals[i] > simplified_stats.terminals[i])
372+
|| (stats.negations > simplified_stats.negations && stats.ops == simplified_stats.ops)
373+
|| (stats.ops > simplified_stats.ops && stats.negations == simplified_stats.negations);
374374
}
375375
if improvement {
376376
improvements.push(suggestion);

clippy_lints/src/bytecount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use rustc::hir::*;
22
use rustc::lint::*;
33
use rustc::ty;
44
use syntax::ast::{Name, UintTy};
5-
use utils::{contains_name, get_pat_name, match_type, paths, single_segment_path,
6-
snippet, span_lint_and_sugg, walk_ptrs_ty};
5+
use utils::{contains_name, get_pat_name, match_type, paths, single_segment_path, snippet, span_lint_and_sugg,
6+
walk_ptrs_ty};
77

88
/// **What it does:** Checks for naive byte counts
99
///

clippy_lints/src/const_static_lifetime.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use syntax::ast::{Item, ItemKind, TyKind, Ty};
2-
use rustc::lint::{LintPass, EarlyLintPass, LintArray, EarlyContext};
3-
use utils::{span_lint_and_then, in_macro};
1+
use syntax::ast::{Item, ItemKind, Ty, TyKind};
2+
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
3+
use utils::{in_macro, span_lint_and_then};
44

55
/// **What it does:** Checks for constants with an explicit `'static` lifetime.
66
///
@@ -20,7 +20,7 @@ use utils::{span_lint_and_then, in_macro};
2020
/// ```
2121
2222
declare_lint! {
23-
pub CONST_STATIC_LIFETIME,
23+
pub CONST_STATIC_LIFETIME,
2424
Warn,
2525
"Using explicit `'static` lifetime for constants when elision rules would allow omitting them."
2626
}
@@ -41,10 +41,8 @@ impl StaticConst {
4141
TyKind::Array(ref ty, _) => {
4242
self.visit_type(&*ty, cx);
4343
},
44-
TyKind::Tup(ref tup) => {
45-
for tup_ty in tup {
46-
self.visit_type(&*tup_ty, cx);
47-
}
44+
TyKind::Tup(ref tup) => for tup_ty in tup {
45+
self.visit_type(&*tup_ty, cx);
4846
},
4947
// This is what we are looking for !
5048
TyKind::Rptr(ref optional_lifetime, ref borrow_type) => {
@@ -54,11 +52,15 @@ impl StaticConst {
5452
// Verify that the path is a str
5553
if lifetime.ident.name == "'static" {
5654
let mut sug: String = String::new();
57-
span_lint_and_then(cx,
58-
CONST_STATIC_LIFETIME,
59-
lifetime.span,
60-
"Constants have by default a `'static` lifetime",
61-
|db| {db.span_suggestion(lifetime.span,"consider removing `'static`",sug);});
55+
span_lint_and_then(
56+
cx,
57+
CONST_STATIC_LIFETIME,
58+
lifetime.span,
59+
"Constants have by default a `'static` lifetime",
60+
|db| {
61+
db.span_suggestion(lifetime.span, "consider removing `'static`", sug);
62+
},
63+
);
6264
}
6365
}
6466
}

clippy_lints/src/derive.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ fn check_hash_peq<'a, 'tcx>(
9898
// Look for the PartialEq implementations for `ty`
9999
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {
100100
let peq_is_automatically_derived = is_automatically_derived(&cx.tcx.get_attrs(impl_id));
101-
101+
102102
if peq_is_automatically_derived == hash_is_automatically_derived {
103103
return;
104104
}
105-
105+
106106
let trait_ref = cx.tcx.impl_trait_ref(impl_id).expect("must be a trait implementation");
107-
107+
108108
// Only care about `impl PartialEq<Foo> for Foo`
109109
// For `impl PartialEq<B> for A, input_types is [A, B]
110110
if trait_ref.substs.type_at(1) == ty {
@@ -113,7 +113,7 @@ fn check_hash_peq<'a, 'tcx>(
113113
} else {
114114
"you are deriving `Hash` but have implemented `PartialEq` explicitly"
115115
};
116-
116+
117117
span_lint_and_then(
118118
cx, DERIVE_HASH_XOR_EQ, span,
119119
mess,
@@ -157,7 +157,9 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
157157
EXPL_IMPL_CLONE_ON_COPY,
158158
item.span,
159159
"you are implementing `Clone` explicitly on a `Copy` type",
160-
|db| { db.span_note(item.span, "consider deriving `Clone` or removing `Copy`"); },
160+
|db| {
161+
db.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
162+
},
161163
);
162164
}
163165
}

clippy_lints/src/doc.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn check_doc<'a, Events: Iterator<Item = (usize, pulldown_cmark::Event<'a>)>>(
204204
End(CodeBlock(_)) | End(Code) => in_code = false,
205205
Start(Link(link, _)) => in_link = Some(link),
206206
End(Link(_, _)) => in_link = None,
207-
Start(_tag) | End(_tag) => (), // We don't care about other tags
207+
Start(_tag) | End(_tag) => (), // We don't care about other tags
208208
Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it
209209
SoftBreak => (),
210210
HardBreak => (),
@@ -273,8 +273,8 @@ fn check_word(cx: &EarlyContext, word: &str, span: Span) {
273273
s
274274
};
275275

276-
s.chars().all(char::is_alphanumeric) && s.chars().filter(|&c| c.is_uppercase()).take(2).count() > 1 &&
277-
s.chars().filter(|&c| c.is_lowercase()).take(1).count() > 0
276+
s.chars().all(char::is_alphanumeric) && s.chars().filter(|&c| c.is_uppercase()).take(2).count() > 1
277+
&& s.chars().filter(|&c| c.is_lowercase()).take(1).count() > 0
278278
}
279279

280280
fn has_underscore(s: &str) -> bool {
@@ -284,10 +284,12 @@ fn check_word(cx: &EarlyContext, word: &str, span: Span) {
284284
if let Ok(url) = Url::parse(word) {
285285
// try to get around the fact that `foo::bar` parses as a valid URL
286286
if !url.cannot_be_a_base() {
287-
span_lint(cx,
288-
DOC_MARKDOWN,
289-
span,
290-
"you should put bare URLs between `<`/`>` or make a proper Markdown link");
287+
span_lint(
288+
cx,
289+
DOC_MARKDOWN,
290+
span,
291+
"you should put bare URLs between `<`/`>` or make a proper Markdown link",
292+
);
291293

292294
return;
293295
}

clippy_lints/src/drop_forget_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::lint::*;
22
use rustc::ty;
33
use rustc::hir::*;
4-
use utils::{is_copy, match_def_path, paths, span_note_and_lint, opt_def_id};
4+
use utils::{is_copy, match_def_path, opt_def_id, paths, span_note_and_lint};
55

66
/// **What it does:** Checks for calls to `std::mem::drop` with a reference
77
/// instead of an owned value.
@@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
125125
let msg;
126126
let arg = &args[0];
127127
let arg_ty = cx.tables.expr_ty(arg);
128-
128+
129129
if let ty::TyRef(..) = arg_ty.sty {
130130
if match_def_path(cx.tcx, def_id, &paths::DROP) {
131131
lint = DROP_REF;

0 commit comments

Comments
 (0)