mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-07 12:48:30 +00:00
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::lint::*;
|
||||||
use rustc::{declare_lint, lint_array};
|
use rustc::{declare_lint, lint_array};
|
||||||
use rustc::hir::*;
|
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
|
/// **What it does:** Checks for fields in struct literals where shorthands
|
||||||
/// could be used.
|
/// could be used.
|
||||||
@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames {
|
|||||||
// Ignore all macros including range expressions.
|
// Ignore all macros including range expressions.
|
||||||
// They can have redundant field names when expanded.
|
// They can have redundant field names when expanded.
|
||||||
// e.g. range expression `start..end` is desugared to `Range { start: start, end: end }`
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ use std::str::FromStr;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::ast::{self, LitKind};
|
use syntax::ast::{self, LitKind};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, Span, DUMMY_SP};
|
use syntax::codemap::{Span, DUMMY_SP};
|
||||||
use syntax::errors::DiagnosticBuilder;
|
use syntax::errors::DiagnosticBuilder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::keywords;
|
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.
|
/// Returns true if this `expn_info` was expanded by any macro.
|
||||||
pub fn in_macro(span: Span) -> bool {
|
pub fn in_macro(span: Span) -> bool {
|
||||||
span.ctxt().outer().expn_info().map_or(false, |info| {
|
span.ctxt().outer().expn_info().is_some()
|
||||||
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,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a `DefId`'s path matches the given absolute type path usage.
|
/// Check if a `DefId`'s path matches the given absolute type path usage.
|
||||||
|
Loading…
Reference in New Issue
Block a user