Skip to content

Commit e23881e

Browse files
committed
Rename ctx->cx in needless_continue
1 parent 4068ff4 commit e23881e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

clippy_lints/src/needless_continue.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ declare_clippy_lint! {
119119
declare_lint_pass!(NeedlessContinue => [NEEDLESS_CONTINUE]);
120120

121121
impl EarlyLintPass for NeedlessContinue {
122-
fn check_expr(&mut self, ctx: &EarlyContext<'_>, expr: &ast::Expr) {
122+
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
123123
if !expr.span.from_expansion() {
124-
check_and_warn(ctx, expr);
124+
check_and_warn(cx, expr);
125125
}
126126
}
127127
}
@@ -283,39 +283,39 @@ const DROP_ELSE_BLOCK_AND_MERGE_MSG: &str = "consider dropping the `else` clause
283283

284284
const DROP_ELSE_BLOCK_MSG: &str = "consider dropping the `else` clause";
285285

286-
fn emit_warning<'a>(ctx: &EarlyContext<'_>, data: &'a LintData<'_>, header: &str, typ: LintType) {
286+
fn emit_warning<'a>(cx: &EarlyContext<'_>, data: &'a LintData<'_>, header: &str, typ: LintType) {
287287
// snip is the whole *help* message that appears after the warning.
288288
// message is the warning message.
289289
// expr is the expression which the lint warning message refers to.
290290
let (snip, message, expr) = match typ {
291291
LintType::ContinueInsideElseBlock => (
292-
suggestion_snippet_for_continue_inside_else(ctx, data),
292+
suggestion_snippet_for_continue_inside_else(cx, data),
293293
MSG_REDUNDANT_ELSE_BLOCK,
294294
data.else_expr,
295295
),
296296
LintType::ContinueInsideThenBlock => (
297-
suggestion_snippet_for_continue_inside_if(ctx, data),
297+
suggestion_snippet_for_continue_inside_if(cx, data),
298298
MSG_ELSE_BLOCK_NOT_NEEDED,
299299
data.if_expr,
300300
),
301301
};
302302
span_lint_and_help(
303-
ctx,
303+
cx,
304304
NEEDLESS_CONTINUE,
305305
expr.span,
306306
message,
307307
&format!("{}\n{}", header, snip),
308308
);
309309
}
310310

311-
fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext<'_>, data: &'a LintData<'_>) -> String {
312-
let cond_code = snippet(ctx, data.if_cond.span, "..");
311+
fn suggestion_snippet_for_continue_inside_if<'a>(cx: &EarlyContext<'_>, data: &'a LintData<'_>) -> String {
312+
let cond_code = snippet(cx, data.if_cond.span, "..");
313313

314-
let continue_code = snippet_block(ctx, data.if_block.span, "..", Some(data.if_expr.span));
314+
let continue_code = snippet_block(cx, data.if_block.span, "..", Some(data.if_expr.span));
315315

316-
let else_code = snippet_block(ctx, data.else_expr.span, "..", Some(data.if_expr.span));
316+
let else_code = snippet_block(cx, data.else_expr.span, "..", Some(data.if_expr.span));
317317

318-
let indent_if = indent_of(ctx, data.if_expr.span).unwrap_or(0);
318+
let indent_if = indent_of(cx, data.if_expr.span).unwrap_or(0);
319319
format!(
320320
"{indent}if {} {}\n{indent}{}",
321321
cond_code,
@@ -325,24 +325,24 @@ fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext<'_>, data: &
325325
)
326326
}
327327

328-
fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext<'_>, data: &'a LintData<'_>) -> String {
329-
let cond_code = snippet(ctx, data.if_cond.span, "..");
328+
fn suggestion_snippet_for_continue_inside_else<'a>(cx: &EarlyContext<'_>, data: &'a LintData<'_>) -> String {
329+
let cond_code = snippet(cx, data.if_cond.span, "..");
330330

331331
// Region B
332-
let block_code = erode_from_back(&snippet_block(ctx, data.if_block.span, "..", Some(data.if_expr.span)));
332+
let block_code = erode_from_back(&snippet_block(cx, data.if_block.span, "..", Some(data.if_expr.span)));
333333

334334
// Region C
335335
// These is the code in the loop block that follows the if/else construction
336336
// we are complaining about. We want to pull all of this code into the
337337
// `then` block of the `if` statement.
338338
let indent = span_of_first_expr_in_block(data.if_block)
339-
.and_then(|span| indent_of(ctx, span))
339+
.and_then(|span| indent_of(cx, span))
340340
.unwrap_or(0);
341341
let to_annex = data.block_stmts[data.stmt_idx + 1..]
342342
.iter()
343343
.map(|stmt| original_sp(stmt.span, DUMMY_SP))
344344
.map(|span| {
345-
let snip = snippet_block(ctx, span, "..", None).into_owned();
345+
let snip = snippet_block(cx, span, "..", None).into_owned();
346346
snip.lines()
347347
.map(|line| format!("{}{}", " ".repeat(indent), line))
348348
.collect::<Vec<_>>()
@@ -351,7 +351,7 @@ fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext<'_>, data:
351351
.collect::<Vec<_>>()
352352
.join("\n");
353353

354-
let indent_if = indent_of(ctx, data.if_expr.span).unwrap_or(0);
354+
let indent_if = indent_of(cx, data.if_expr.span).unwrap_or(0);
355355
format!(
356356
"{indent_if}if {} {}\n{indent}// merged code follows:\n{}\n{indent_if}}}",
357357
cond_code,
@@ -362,7 +362,7 @@ fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext<'_>, data:
362362
)
363363
}
364364

365-
fn check_and_warn<'a>(ctx: &EarlyContext<'_>, expr: &'a ast::Expr) {
365+
fn check_and_warn<'a>(cx: &EarlyContext<'_>, expr: &'a ast::Expr) {
366366
with_loop_block(expr, |loop_block, label| {
367367
for (i, stmt) in loop_block.stmts.iter().enumerate() {
368368
with_if_expr(stmt, |if_expr, cond, then_block, else_expr| {
@@ -376,13 +376,13 @@ fn check_and_warn<'a>(ctx: &EarlyContext<'_>, expr: &'a ast::Expr) {
376376
};
377377
if needless_continue_in_else(else_expr, label) {
378378
emit_warning(
379-
ctx,
379+
cx,
380380
data,
381381
DROP_ELSE_BLOCK_AND_MERGE_MSG,
382382
LintType::ContinueInsideElseBlock,
383383
);
384384
} else if is_first_block_stmt_continue(then_block, label) {
385-
emit_warning(ctx, data, DROP_ELSE_BLOCK_MSG, LintType::ContinueInsideThenBlock);
385+
emit_warning(cx, data, DROP_ELSE_BLOCK_MSG, LintType::ContinueInsideThenBlock);
386386
}
387387
});
388388
}

0 commit comments

Comments
 (0)