Skip to content

Remove unused variable and a minor refactoring #2509

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions clippy_lints/src/redundant_field_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ impl LintPass for RedundantFieldNames {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames {
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 {
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 {
span_lint_and_sugg (
cx,
Expand Down