Skip to content

Commit

Permalink
Don't buffer lints.
Browse files Browse the repository at this point in the history
When lints are emitted from the AST borrow checker, they do not signal
an error as it is not known at that time whether, due to attributes,
that lint will error or warn. This means that when lints are buffered
in the MIR they will always be downgraded, as the AST borrowck will not
have been marked as having errored, even if a lint was upgraded to
an error after being emitted from the AST borrowck. The simple solution
to this is to not buffer any lints from the MIR borrowck.
  • Loading branch information
davidtwco committed Oct 16, 2018
1 parent 99ab2f4 commit d8db529
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/librustc_mir/borrow_check/mod.rs
Expand Up @@ -321,20 +321,20 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
continue;
}

let mut err = tcx.struct_span_lint_node(
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
tcx.struct_span_lint_node(
UNUSED_MUT,
vsi[local_decl.source_info.scope].lint_root,
span,
"variable does not need to be mutable",
);
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
err.span_suggestion_short_with_applicability(
)
.span_suggestion_short_with_applicability(
mut_span,
"remove this `mut`",
String::new(),
Applicability::MachineApplicable);

err.buffer(&mut mbcx.errors_buffer);
Applicability::MachineApplicable,
)
.emit();
}
}

Expand Down

0 comments on commit d8db529

Please sign in to comment.