[NLL] Use span of the closure args in free region errors by matthewjasper · Pull Request #53088 · rust-lang/rust (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do better here, too. mir.span is pretty horrific in all cases. Maybe we leave that for another issue though. We would want to extract (from the HIR) the span of the return type, I suppose. Really, we should do the same "return type is &'1 u32" sort of thing we do for arguments, right?

I wonder if, for closures, we can highlight just the final |?

So it would look like:

error: unsatisfied lifetime constraints
  --> $DIR/E0621-does-not-trigger-for-closures.rs:25:26
   |
LL |     invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
   |                    --    ^^^^^ requires that `'1` must outlive `'2`
   |                    ||
   |                    |return type of closure is `&'2 i32`
   |                    has type `&'1 i32`