Fix breakage from rust-lang/rust#52949
This commit is contained in:
parent
f43d0e53b2
commit
40349b23ea
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user