I left a comment, but I'll ask here: Do you think it would be feasible to highlight the specific uses of
'a rather than the site where it is bound?
I totally understand if figuring out which use(s) are the relevant ones is too difficult for the short term
I'm not sure. It occurs to me that I misread the comment as "highlight where this
'a thing comes from" rather than "highlight why this
'a thing is part of the error".
I might have a idea how to work that out, not too sure, will experiment for a little bit.
Unless @nikomatsakis has any suggestions how I might go about working this out, I can't figure out from some brief experimentation how to do this @pnkfelix.
Okay that's fine. Lets just land this one and I'll open an issue for the longer-term feature request.
I tried looking at the span of the region one constraint away but that wasn't quite what we were after I don't think.
In fact, had an idea, let me experiment a little more.
okay, well I already r+'ed your PR
so now you're on a race with bors
but in my experience, bors tends to be the tortoise in these races.
@pnkfelix I can have it highlight the argument (not the type of the argument just yet, but the argument name) where the lifetime is used rather than where the lifetime is defined in the generics - not sure if that's better?
... hmm... no lets not do that
or at least, that sounds pretty fragile
especially when you have things like
where clauses or bounds on type parameters, so the actual occurrecne of
'a might be quite far from the relevant variable name, right?
Yeah, I'm not sure.
/me is looking
The occurrence of
x: &'x isize, I think.
Yeah, that's what I figured it would be.
what's the alternative you're considering? Not any of the
I thought the same as you, the argument.
I'm close to having that, it just doesn't have the type in the span currently, just the name.
This is of course a case where highlighting the binding
<'x> is a fine UX, since the whole line gets printed.
Oh, can we not find the span of the type via the LocalDecl?
But yeah, it could fail in
mir.local_decls[local].source_info.span is just the name, not the type annotation.
looking at the stderr for the AST-borrowck
it clearly does what you did
A quick glance didn't spot the type annotation span.
That's exactly where I got it from.
i.e. highlights the binding site
okay so lets not worry too much about this then
I like diagnostics because I can search for error messages and find out how it was done in AST or where it is done in MIR.
Our primary goal is just to make sure we're not egregiously worse than AST-borrowck
Alright, we can leave this as a potential future improvement then.
@davidtwco there is code to identify the
'a as part of the type that I wrote some time back
it was targeting anonymous lifetimes but could with relative ease be repurposed to named lifetimes, I think