From 40349b23ea1730f9a5ef4056edf4854908073a48 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 Aug 2018 13:00:14 -0700 Subject: [PATCH] Fix breakage from rust-lang/rust#52949 --- clippy_lints/src/redundant_field_names.rs | 4 ++-- clippy_lints/src/utils/mod.rs | 20 ++------------------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 4f28d36e2a8..27f890ccd90 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -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. @@ -40,7 +40,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // 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; } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 0b2103ca7ea..a8c20ef4fa3 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -19,7 +19,7 @@ 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; @@ -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.