Skip to content

Commit 5e722ba

Browse files
committed
Auto merge of #5098 - JohnTitor:rename-span-lints, r=flip1995
Rename `span_{help, note}_and_lint` to `span_lint_and_*` `span_*_and_lint` and `span_lint_and_*` make us confused. The order should be the same. [context](#5084 (comment)) changelog: none
2 parents 4f65bec + f5e86d6 commit 5e722ba

36 files changed

+113
-113
lines changed

clippy_lints/src/as_conversions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
33
use rustc_session::{declare_lint_pass, declare_tool_lint};
44
use syntax::ast::*;
55

6-
use crate::utils::span_help_and_lint;
6+
use crate::utils::span_lint_and_help;
77

88
declare_clippy_lint! {
99
/// **What it does:** Checks for usage of `as` conversions.
@@ -45,7 +45,7 @@ impl EarlyLintPass for AsConversions {
4545
}
4646

4747
if let ExprKind::Cast(_, _) = expr.kind {
48-
span_help_and_lint(
48+
span_lint_and_help(
4949
cx,
5050
AS_CONVERSIONS,
5151
expr.span,

clippy_lints/src/assertions_on_constants.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::consts::{constant, Constant};
22
use crate::utils::paths;
3-
use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, snippet_opt, span_help_and_lint};
3+
use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, snippet_opt, span_lint_and_help};
44
use if_chain::if_chain;
55
use rustc_hir::*;
66
use rustc_lint::{LateContext, LateLintPass};
@@ -34,7 +34,7 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
3535
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
3636
let lint_true = |is_debug: bool| {
37-
span_help_and_lint(
37+
span_lint_and_help(
3838
cx,
3939
ASSERTIONS_ON_CONSTANTS,
4040
e.span,
@@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
4747
);
4848
};
4949
let lint_false_without_message = || {
50-
span_help_and_lint(
50+
span_lint_and_help(
5151
cx,
5252
ASSERTIONS_ON_CONSTANTS,
5353
e.span,
@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
5656
);
5757
};
5858
let lint_false_with_message = |panic_message: String| {
59-
span_help_and_lint(
59+
span_lint_and_help(
6060
cx,
6161
ASSERTIONS_ON_CONSTANTS,
6262
e.span,

clippy_lints/src/atomic_ordering.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{match_def_path, span_help_and_lint};
1+
use crate::utils::{match_def_path, span_lint_and_help};
22
use if_chain::if_chain;
33
use rustc::ty;
44
use rustc_hir::def_id::DefId;
@@ -80,7 +80,7 @@ fn check_atomic_load_store(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
8080
then {
8181
if method == "load" &&
8282
match_ordering_def_path(cx, ordering_def_id, &["Release", "AcqRel"]) {
83-
span_help_and_lint(
83+
span_lint_and_help(
8484
cx,
8585
INVALID_ATOMIC_ORDERING,
8686
ordering_arg.span,
@@ -89,7 +89,7 @@ fn check_atomic_load_store(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
8989
);
9090
} else if method == "store" &&
9191
match_ordering_def_path(cx, ordering_def_id, &["Acquire", "AcqRel"]) {
92-
span_help_and_lint(
92+
span_lint_and_help(
9393
cx,
9494
INVALID_ATOMIC_ORDERING,
9595
ordering_arg.span,
@@ -113,7 +113,7 @@ fn check_memory_fence(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
113113
if let Some(ordering_def_id) = cx.tables.qpath_res(ordering_qpath, args[0].hir_id).opt_def_id();
114114
if match_ordering_def_path(cx, ordering_def_id, &["Relaxed"]);
115115
then {
116-
span_help_and_lint(
116+
span_lint_and_help(
117117
cx,
118118
INVALID_ATOMIC_ORDERING,
119119
args[0].span,

clippy_lints/src/block_in_if_condition.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
8989
if expr.span.from_expansion() || differing_macro_contexts(expr.span, ex.span) {
9090
return;
9191
}
92-
span_help_and_lint(
92+
span_lint_and_help(
9393
cx,
9494
BLOCK_IN_IF_CONDITION_EXPR,
9595
check.span,
@@ -107,7 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
107107
return;
108108
}
109109
// move block higher
110-
span_help_and_lint(
110+
span_lint_and_help(
111111
cx,
112112
BLOCK_IN_IF_CONDITION_STMT,
113113
check.span,

clippy_lints/src/cognitive_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_span::source_map::Span;
99
use rustc_span::BytePos;
1010
use syntax::ast::Attribute;
1111

12-
use crate::utils::{match_type, paths, snippet_opt, span_help_and_lint, LimitStack};
12+
use crate::utils::{match_type, paths, snippet_opt, span_lint_and_help, LimitStack};
1313

1414
declare_clippy_lint! {
1515
/// **What it does:** Checks for methods with high cognitive complexity.
@@ -96,7 +96,7 @@ impl CognitiveComplexity {
9696
},
9797
};
9898

99-
span_help_and_lint(
99+
span_lint_and_help(
100100
cx,
101101
COGNITIVE_COMPLEXITY,
102102
fn_span,

clippy_lints/src/comparison_chain.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::utils::{
2-
get_trait_def_id, if_sequence, implements_trait, parent_node_is_if_expr, paths, span_help_and_lint, SpanlessEq,
2+
get_trait_def_id, if_sequence, implements_trait, parent_node_is_if_expr, paths, span_lint_and_help, SpanlessEq,
33
};
44
use rustc_hir::*;
55
use rustc_lint::{LateContext, LateLintPass};
@@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ComparisonChain {
9999
return;
100100
}
101101
}
102-
span_help_and_lint(
102+
span_lint_and_help(
103103
cx,
104104
COMPARISON_CHAIN,
105105
expr.span,

clippy_lints/src/copies.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{get_parent_expr, higher, if_sequence, same_tys, snippet, span_lint_and_then, span_note_and_lint};
1+
use crate::utils::{get_parent_expr, higher, if_sequence, same_tys, snippet, span_lint_and_note, span_lint_and_then};
22
use crate::utils::{SpanlessEq, SpanlessHash};
33
use rustc::ty::Ty;
44
use rustc_data_structures::fx::FxHashMap;
@@ -178,7 +178,7 @@ fn lint_same_then_else(cx: &LateContext<'_, '_>, blocks: &[&Block<'_>]) {
178178
&|&lhs, &rhs| -> bool { SpanlessEq::new(cx).eq_block(lhs, rhs) };
179179

180180
if let Some((i, j)) = search_same_sequenced(blocks, eq) {
181-
span_note_and_lint(
181+
span_lint_and_note(
182182
cx,
183183
IF_SAME_THEN_ELSE,
184184
j.span,
@@ -201,7 +201,7 @@ fn lint_same_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
201201
&|&lhs, &rhs| -> bool { SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, rhs) };
202202

203203
for (i, j) in search_same(conds, hash, eq) {
204-
span_note_and_lint(
204+
span_lint_and_note(
205205
cx,
206206
IFS_SAME_COND,
207207
j.span,
@@ -229,7 +229,7 @@ fn lint_same_fns_in_if_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
229229
};
230230

231231
for (i, j) in search_same(conds, hash, eq) {
232-
span_note_and_lint(
232+
span_lint_and_note(
233233
cx,
234234
SAME_FUNCTIONS_IN_IF_CONDITION,
235235
j.span,

clippy_lints/src/copy_iterator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{is_copy, match_path, paths, span_note_and_lint};
1+
use crate::utils::{is_copy, match_path, paths, span_lint_and_note};
22
use rustc_hir::{Item, ItemKind};
33
use rustc_lint::{LateContext, LateLintPass};
44
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -41,7 +41,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
4141
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
4242

4343
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
44-
span_note_and_lint(
44+
span_lint_and_note(
4545
cx,
4646
COPY_ITERATOR,
4747
item.span,

clippy_lints/src/dbg_macro.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{snippet_opt, span_help_and_lint, span_lint_and_sugg};
1+
use crate::utils::{snippet_opt, span_lint_and_help, span_lint_and_sugg};
22
use rustc_errors::Applicability;
33
use rustc_lint::{EarlyContext, EarlyLintPass};
44
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -43,7 +43,7 @@ impl EarlyLintPass for DbgMacro {
4343
Applicability::MaybeIncorrect,
4444
);
4545
} else {
46-
span_help_and_lint(
46+
span_lint_and_help(
4747
cx,
4848
DBG_MACRO,
4949
mac.span(),

clippy_lints/src/drop_forget_ref.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{is_copy, match_def_path, paths, qpath_res, span_note_and_lint};
1+
use crate::utils::{is_copy, match_def_path, paths, qpath_res, span_lint_and_note};
22
use if_chain::if_chain;
33
use rustc::ty;
44
use rustc_hir::*;
@@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef {
131131
} else {
132132
return;
133133
}
134-
span_note_and_lint(cx,
134+
span_lint_and_note(cx,
135135
lint,
136136
expr.span,
137137
&msg,
@@ -147,7 +147,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef {
147147
} else {
148148
return;
149149
}
150-
span_note_and_lint(cx,
150+
span_lint_and_note(cx,
151151
lint,
152152
expr.span,
153153
&msg,

clippy_lints/src/else_if_without_else.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66
use syntax::ast::*;
77

8-
use crate::utils::span_help_and_lint;
8+
use crate::utils::span_lint_and_help;
99

1010
declare_clippy_lint! {
1111
/// **What it does:** Checks for usage of if expressions with an `else if` branch,
@@ -56,7 +56,7 @@ impl EarlyLintPass for ElseIfWithoutElse {
5656

5757
while let ExprKind::If(_, _, Some(ref els)) = item.kind {
5858
if let ExprKind::If(_, _, None) = els.kind {
59-
span_help_and_lint(
59+
span_lint_and_help(
6060
cx,
6161
ELSE_IF_WITHOUT_ELSE,
6262
els.span,

clippy_lints/src/enum_variants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! lint on enum variants that are prefixed or suffixed by the same characters
22
33
use crate::utils::{camel_case, is_present_in_source};
4-
use crate::utils::{span_help_and_lint, span_lint};
4+
use crate::utils::{span_lint, span_lint_and_help};
55
use rustc_lint::{EarlyContext, EarlyLintPass, Lint};
66
use rustc_session::{declare_tool_lint, impl_lint_pass};
77
use rustc_span::source_map::Span;
@@ -201,7 +201,7 @@ fn check_variant(
201201
(false, _) => ("pre", pre),
202202
(true, false) => ("post", post),
203203
};
204-
span_help_and_lint(
204+
span_lint_and_help(
205205
cx,
206206
lint,
207207
span,

clippy_lints/src/eval_order_dependence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{get_parent_expr, span_lint, span_note_and_lint};
1+
use crate::utils::{get_parent_expr, span_lint, span_lint_and_note};
22
use if_chain::if_chain;
33
use rustc::hir::map::Map;
44
use rustc::ty;
@@ -307,7 +307,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
307307
// Check that this is a read, not a write.
308308
if !is_in_assignment_position(self.cx, expr);
309309
then {
310-
span_note_and_lint(
310+
span_lint_and_note(
311311
self.cx,
312312
EVAL_ORDER_DEPENDENCE,
313313
expr.span,

clippy_lints/src/formatting.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{differing_macro_contexts, snippet_opt, span_help_and_lint, span_note_and_lint};
1+
use crate::utils::{differing_macro_contexts, snippet_opt, span_lint_and_help, span_lint_and_note};
22
use if_chain::if_chain;
33
use rustc::lint::in_external_macro;
44
use rustc_lint::{EarlyContext, EarlyLintPass};
@@ -140,7 +140,7 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) {
140140
let op = UnOp::to_string(op);
141141
let eqop_span = lhs.span.between(sub_rhs.span);
142142
if eq_snippet.ends_with('=') {
143-
span_note_and_lint(
143+
span_lint_and_note(
144144
cx,
145145
SUSPICIOUS_ASSIGNMENT_FORMATTING,
146146
eqop_span,
@@ -178,7 +178,7 @@ fn check_unop(cx: &EarlyContext<'_>, expr: &Expr) {
178178
then {
179179
let unop_str = UnOp::to_string(op);
180180
let eqop_span = lhs.span.between(un_rhs.span);
181-
span_help_and_lint(
181+
span_lint_and_help(
182182
cx,
183183
SUSPICIOUS_UNARY_OP_FORMATTING,
184184
eqop_span,
@@ -221,7 +221,7 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) {
221221
let else_desc = if is_if(else_) { "if" } else { "{..}" };
222222

223223
then {
224-
span_note_and_lint(
224+
span_lint_and_note(
225225
cx,
226226
SUSPICIOUS_ELSE_FORMATTING,
227227
else_span,
@@ -260,7 +260,7 @@ fn check_array(cx: &EarlyContext<'_>, expr: &Expr) {
260260
if space_snippet.contains('\n');
261261
if indentation(cx, op.span) <= indentation(cx, lhs.span);
262262
then {
263-
span_note_and_lint(
263+
span_lint_and_note(
264264
cx,
265265
POSSIBLE_MISSING_COMMA,
266266
lint_span,
@@ -291,7 +291,7 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) {
291291
("an `else {..}`", "the next block")
292292
};
293293

294-
span_note_and_lint(
294+
span_lint_and_note(
295295
cx,
296296
SUSPICIOUS_ELSE_FORMATTING,
297297
else_span,

clippy_lints/src/functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{
22
attr_by_name, attrs::is_proc_macro, is_must_use_ty, iter_input_pats, match_def_path, must_use_attr, qpath_res,
3-
return_ty, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_then, trait_ref_of_method,
3+
return_ty, snippet, snippet_opt, span_lint, span_lint_and_help, span_lint_and_then, trait_ref_of_method,
44
type_is_unsafe_function,
55
};
66
use matches::matches;
@@ -433,7 +433,7 @@ fn check_needless_must_use(
433433
},
434434
);
435435
} else if !attr.is_value_str() && is_must_use_ty(cx, return_ty(cx, item_id)) {
436-
span_help_and_lint(
436+
span_lint_and_help(
437437
cx,
438438
DOUBLE_MUST_USE,
439439
fn_header_span,

clippy_lints/src/if_not_else.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
77
use syntax::ast::*;
88

9-
use crate::utils::span_help_and_lint;
9+
use crate::utils::span_lint_and_help;
1010

1111
declare_clippy_lint! {
1212
/// **What it does:** Checks for usage of `!` or `!=` in an if condition with an
@@ -56,7 +56,7 @@ impl EarlyLintPass for IfNotElse {
5656
if let ExprKind::Block(..) = els.kind {
5757
match cond.kind {
5858
ExprKind::Unary(UnOp::Not, _) => {
59-
span_help_and_lint(
59+
span_lint_and_help(
6060
cx,
6161
IF_NOT_ELSE,
6262
item.span,
@@ -65,7 +65,7 @@ impl EarlyLintPass for IfNotElse {
6565
);
6666
},
6767
ExprKind::Binary(ref kind, _, _) if kind.node == BinOpKind::Ne => {
68-
span_help_and_lint(
68+
span_lint_and_help(
6969
cx,
7070
IF_NOT_ELSE,
7171
item.span,

clippy_lints/src/indexing_slicing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
136136
(None, None) => return, // [..] is ok.
137137
};
138138

139-
utils::span_help_and_lint(cx, INDEXING_SLICING, expr.span, "slicing may panic.", help_msg);
139+
utils::span_lint_and_help(cx, INDEXING_SLICING, expr.span, "slicing may panic.", help_msg);
140140
} else {
141141
// Catchall non-range index, i.e., [n] or [n << m]
142142
if let ty::Array(..) = ty.kind {
@@ -147,7 +147,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
147147
}
148148
}
149149

150-
utils::span_help_and_lint(
150+
utils::span_lint_and_help(
151151
cx,
152152
INDEXING_SLICING,
153153
expr.span,

0 commit comments

Comments
 (0)