mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
Update closure errors to emit context for FnMut
It now handles both FnMut and FnOnce case.
This commit is contained in:
parent
9cbb5f9a24
commit
94c808c1d3
@ -657,13 +657,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
};
|
||||
|
||||
if let Some(tables) = infer_tables {
|
||||
if let Some(&(ty::ClosureKind::FnOnce, Some((span, name)))) =
|
||||
tables.closure_kinds.get(&node_id)
|
||||
{
|
||||
err.span_note(
|
||||
span,
|
||||
&format!("closure is `FnOnce` because it moves the \
|
||||
variable `{}` out of its environment", name));
|
||||
match tables.closure_kinds.get(&node_id) {
|
||||
Some(&(ty::ClosureKind::FnOnce, Some((span, name)))) => {
|
||||
err.span_note(span, &format!(
|
||||
"closure is `FnOnce` because it moves the \
|
||||
variable `{}` out of its environment", name));
|
||||
},
|
||||
Some(&(ty::ClosureKind::FnMut, Some((span, name)))) => {
|
||||
err.span_note(span, &format!(
|
||||
"closure is `FnMut` because it mutates the \
|
||||
variable `{}` here", name));
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
} else {
|
||||
err.span_note(
|
||||
|
Loading…
Reference in New Issue
Block a user