Skip to content

Commit 41115d9

Browse files
authored
Formatting and naming
1 parent d7f1a1e commit 41115d9

File tree

5 files changed

+38
-35
lines changed

5 files changed

+38
-35
lines changed

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
5050
EMPTY_ENUM,
5151
item.span,
5252
"enum with no variants",
53-
Some(item.span),
53+
None,
5454
"consider using the uninhabited type `!` (never type) or a wrapper \
5555
around it to introduce a type which can't be instantiated",
5656
);

clippy_lints/src/loops.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,34 +2473,37 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'a, '
24732473
match_type(cx, ty, &paths::HASHMAP) {
24742474
if method.ident.name == sym!(len) {
24752475
let span = shorten_needless_collect_span(expr);
2476-
span_lint_and_sugg(cx,
2476+
span_lint_and_sugg(
2477+
cx,
24772478
NEEDLESS_COLLECT,
24782479
span,
24792480
NEEDLESS_COLLECT_MSG,
2480-
"replace with",
2481-
".count()".to_string(),
2482-
Applicability::MachineApplicable,
2483-
);
2481+
"replace with",
2482+
".count()".to_string(),
2483+
Applicability::MachineApplicable,
2484+
);
24842485
}
24852486
if method.ident.name == sym!(is_empty) {
24862487
let span = shorten_needless_collect_span(expr);
2487-
span_lint_and_sugg(cx,
2488+
span_lint_and_sugg(
2489+
cx,
24882490
NEEDLESS_COLLECT,
24892491
span,
24902492
NEEDLESS_COLLECT_MSG,
24912493
"replace with",
24922494
".next().is_none()".to_string(),
24932495
Applicability::MachineApplicable,
2494-
);
2496+
);
24952497
}
24962498
if method.ident.name == sym!(contains) {
24972499
let contains_arg = snippet(cx, args[1].span, "??");
24982500
let span = shorten_needless_collect_span(expr);
2499-
span_lint_and_then(cx,
2501+
span_lint_and_then(
2502+
cx,
25002503
NEEDLESS_COLLECT,
25012504
span,
25022505
NEEDLESS_COLLECT_MSG,
2503-
|db| {
2506+
|db| {
25042507
let (arg, pred) = if contains_arg.starts_with('&') {
25052508
("x", &contains_arg[1..])
25062509
} else {

clippy_lints/src/returns.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ impl EarlyLintPass for Return {
291291
String::new(),
292292
Applicability::MachineApplicable,
293293
);
294-
295294
}
296295
}
297296
}

clippy_lints/src/utils/diagnostics.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ pub fn span_lint_and_help<'a, T: LintContext>(
7070
help_span: Option<Span>,
7171
help: &str,
7272
) {
73-
cx.struct_span_lint(lint, span, |ldb| {
74-
let mut db = ldb.build(msg);
73+
cx.struct_span_lint(lint, span, |diag| {
74+
let mut diag = diag.build(msg);
7575
if let Some(help_span) = help_span {
76-
db.span_help(help_span, help);
76+
diag.span_help(help_span, help);
7777
} else {
78-
db.help(help);
78+
diag.help(help);
7979
}
80-
docs_link(&mut db, lint);
81-
db.emit();
80+
docs_link(&mut diag, lint);
81+
diag.emit();
8282
});
8383
}
8484

@@ -111,12 +111,12 @@ pub fn span_lint_and_note<'a, T: LintContext>(
111111
note_span: Option<Span>,
112112
note: &str,
113113
) {
114-
cx.struct_span_lint(lint, span, |ldb| {
115-
let mut db = ldb.build(msg);
114+
cx.struct_span_lint(lint, span, |diag| {
115+
let mut diag = diag.build(msg);
116116
if let Some(note_span) = note_span {
117-
db.span_note(note_span, note);
117+
diag.span_note(note_span, note);
118118
} else {
119-
db.note(note);
119+
diag.note(note);
120120
}
121121
docs_link(&mut diag, lint);
122122
diag.emit();

clippy_lints/src/utils/internal_lints.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,25 +163,25 @@ declare_clippy_lint! {
163163
/// *Example:**
164164
/// Bad:
165165
/// ```rust,ignore
166-
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
167-
/// db.span_suggestion(
166+
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
167+
/// diag.span_suggestion(
168168
/// expr.span,
169169
/// help_msg,
170170
/// sugg.to_string(),
171171
/// Applicability::MachineApplicable,
172172
/// );
173173
/// });
174-
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
175-
/// db.span_help(expr.span, help_msg);
174+
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
175+
/// diag.span_help(expr.span, help_msg);
176176
/// });
177-
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
178-
/// db.help(help_msg);
177+
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
178+
/// diag.help(help_msg);
179179
/// });
180-
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
181-
/// db.span_note(expr.span, note_msg);
180+
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
181+
/// diag.span_note(expr.span, note_msg);
182182
/// });
183-
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
184-
/// db.note(note_msg);
183+
/// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
184+
/// diag.note(note_msg);
185185
/// });
186186
/// ```
187187
///
@@ -258,9 +258,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
258258
if_chain! {
259259
if let ExprKind::AddrOf(_, _, ref inner_exp) = expr.kind;
260260
if let ExprKind::Struct(_, ref fields, _) = inner_exp.kind;
261-
let field = fields.iter()
262-
.find(|f| f.ident.as_str() == "desc")
263-
.expect("lints must have a description field");
261+
let field = fields
262+
.iter()
263+
.find(|f| f.ident.as_str() == "desc")
264+
.expect("lints must have a description field");
264265
if let ExprKind::Lit(Spanned {
265266
node: LitKind::Str(ref sym, _),
266267
..
@@ -396,7 +397,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
396397
if let Some(sugg) = self.map.get(&*fn_name.as_str());
397398
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));
398399
if match_type(cx, ty, &paths::EARLY_CONTEXT)
399-
|| match_type(cx, ty, &paths::LATE_CONTEXT);
400+
|| match_type(cx, ty, &paths::LATE_CONTEXT);
400401
then {
401402
span_lint_and_help(
402403
cx,

0 commit comments

Comments
 (0)