Merge pull request #2509 from ordovicia/redundant_field_names_range

Remove unused variable and a minor refactoring
This commit is contained in:
Oliver Schneider 2018-03-05 11:13:55 +01:00 committed by GitHub
commit 7dbf315cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,17 +36,17 @@ impl LintPass for RedundantFieldNames {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames {
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 ExprStruct(ref path, ref fields, _) = expr.node { // Do not care about range expressions.
// They could have redundant field name when desugared to structs.
// e.g. `start..end` is desugared to `Range { start: start, end: end }`
if is_range_expression(expr.span) {
return;
}
if let ExprStruct(_, ref fields, _) = expr.node {
for field in fields { for field in fields {
let name = field.name.node; let name = field.name.node;
// Do not care about range expressions.
// They could have redundant field name when desugared to structs.
// e.g. `start..end` is desugared to `Range { start: start, end: end }`
if is_range_expression(expr.span) {
continue;
}
if match_var(&field.expr, name) && !field.is_shorthand { if match_var(&field.expr, name) && !field.is_shorthand {
span_lint_and_sugg ( span_lint_and_sugg (
cx, cx,