Use new spans for expansion checking in loop lints
This commit is contained in:
parent
406e89a00c
commit
9e166e09b8
1 changed files with 10 additions and 8 deletions
|
@ -476,15 +476,21 @@ declare_lint_pass!(Loops => [
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops {
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||||
|
if let Some((pat, arg, body)) = higher::for_loop(expr) {
|
||||||
|
// we don't want to check expanded macros
|
||||||
|
// this check is not at the top of the function
|
||||||
|
// since higher::for_loop expressions are marked as expansions
|
||||||
|
if body.span.from_expansion() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
check_for_loop(cx, pat, arg, body, expr);
|
||||||
|
}
|
||||||
|
|
||||||
// we don't want to check expanded macros
|
// we don't want to check expanded macros
|
||||||
if expr.span.from_expansion() {
|
if expr.span.from_expansion() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((pat, arg, body)) = higher::for_loop(expr) {
|
|
||||||
check_for_loop(cx, pat, arg, body, expr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for never_loop
|
// check for never_loop
|
||||||
if let ExprKind::Loop(ref block, _, _) = expr.kind {
|
if let ExprKind::Loop(ref block, _, _) = expr.kind {
|
||||||
match never_loop_block(block, expr.hir_id) {
|
match never_loop_block(block, expr.hir_id) {
|
||||||
|
@ -1039,10 +1045,6 @@ fn check_for_loop_range<'a, 'tcx>(
|
||||||
body: &'tcx Expr,
|
body: &'tcx Expr,
|
||||||
expr: &'tcx Expr,
|
expr: &'tcx Expr,
|
||||||
) {
|
) {
|
||||||
if expr.span.from_expansion() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(higher::Range {
|
if let Some(higher::Range {
|
||||||
start: Some(start),
|
start: Some(start),
|
||||||
ref end,
|
ref end,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue