Skip to content

Commit

Permalink
Fix breakage from rust-lang/rust#52949
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Aug 2, 2018
1 parent f43d0e5 commit 40349b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/redundant_field_names.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::hir::*;
use crate::utils::{in_macro, is_range_expression, match_var, span_lint_and_sugg};
use crate::utils::{in_macro, match_var, span_lint_and_sugg};

/// **What it does:** Checks for fields in struct literals where shorthands
/// could be used.
Expand Down Expand Up @@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames {
// Ignore all macros including range expressions.
// They can have redundant field names when expanded.
// e.g. range expression `start..end` is desugared to `Range { start: start, end: end }`
if in_macro(expr.span) || is_range_expression(expr.span) {
if in_macro(expr.span) {
return;
}

Expand Down
20 changes: 2 additions & 18 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::str::FromStr;
use std::rc::Rc;
use syntax::ast::{self, LitKind};
use syntax::attr;
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, Span, DUMMY_SP};
use syntax::codemap::{Span, DUMMY_SP};
use syntax::errors::DiagnosticBuilder;
use syntax::ptr::P;
use syntax::symbol::keywords;
Expand Down Expand Up @@ -58,23 +58,7 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {

/// Returns true if this `expn_info` was expanded by any macro.
pub fn in_macro(span: Span) -> bool {
span.ctxt().outer().expn_info().map_or(false, |info| {
match info.format {
// don't treat range expressions desugared to structs as "in_macro"
ExpnFormat::CompilerDesugaring(kind) => kind != CompilerDesugaringKind::DotFill,
_ => true,
}
})
}

/// Returns true if `expn_info` was expanded by range expressions.
pub fn is_range_expression(span: Span) -> bool {
span.ctxt().outer().expn_info().map_or(false, |info| {
match info.format {
ExpnFormat::CompilerDesugaring(CompilerDesugaringKind::DotFill) => true,
_ => false,
}
})
span.ctxt().outer().expn_info().is_some()
}

/// Check if a `DefId`'s path matches the given absolute type path usage.
Expand Down

0 comments on commit 40349b2

Please sign in to comment.