1
Fork 0

Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank

Shorten def_span of closures to just their header

Continuation of https://github.com/rust-lang/rust/pull/93967.
This commit is contained in:
bors 2022-07-08 03:05:15 +00:00
commit eba361ae36
175 changed files with 957 additions and 1341 deletions

View file

@ -861,7 +861,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let arg_pos = args
.iter()
.enumerate()
.filter(|(_, arg)| arg.span == self.body.span)
.filter(|(_, arg)| arg.hir_id == closure_id)
.map(|(pos, _)| pos)
.next();
let def_id = hir.local_def_id(item_id);
@ -903,9 +903,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if let Some(span) = arg {
err.span_label(span, "change this to accept `FnMut` instead of `Fn`");
err.span_label(func.span, "expects `Fn` instead of `FnMut`");
if self.infcx.tcx.sess.source_map().is_multiline(self.body.span) {
err.span_label(self.body.span, "in this closure");
}
err.span_label(self.body.span, "in this closure");
look_at_return = false;
}
}