Skip to content

Commit d8db529

Browse files
committed
Don't buffer lints.
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.
1 parent 99ab2f4 commit d8db529

File tree

1 file changed

+7
-7
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+7
-7
lines changed

src/librustc_mir/borrow_check/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -321,20 +321,20 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
321321
continue;
322322
}
323323

324-
let mut err = tcx.struct_span_lint_node(
324+
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
325+
tcx.struct_span_lint_node(
325326
UNUSED_MUT,
326327
vsi[local_decl.source_info.scope].lint_root,
327328
span,
328329
"variable does not need to be mutable",
329-
);
330-
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
331-
err.span_suggestion_short_with_applicability(
330+
)
331+
.span_suggestion_short_with_applicability(
332332
mut_span,
333333
"remove this `mut`",
334334
String::new(),
335-
Applicability::MachineApplicable);
336-
337-
err.buffer(&mut mbcx.errors_buffer);
335+
Applicability::MachineApplicable,
336+
)
337+
.emit();
338338
}
339339
}
340340

0 commit comments

Comments
 (0)