Stream: t-compiler/wg-nll

Topic: issue-52663-lifetimes-not-included-in-span


davidtwco (Aug 02 2018 at 10:06, on Zulip):

@pnkfelix opened #52973 to address this diagnostic improvement.

pnkfelix (Aug 02 2018 at 10:32, on Zulip):

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?

pnkfelix (Aug 02 2018 at 10:33, on Zulip):

I totally understand if figuring out which use(s) are the relevant ones is too difficult for the short term

davidtwco (Aug 02 2018 at 10:37, on Zulip):

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".

davidtwco (Aug 02 2018 at 10:43, on Zulip):

I might have a idea how to work that out, not too sure, will experiment for a little bit.

davidtwco (Aug 02 2018 at 11:37, on Zulip):

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.

pnkfelix (Aug 02 2018 at 11:38, on Zulip):

Okay that's fine. Lets just land this one and I'll open an issue for the longer-term feature request.

davidtwco (Aug 02 2018 at 11:39, on Zulip):

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.

davidtwco (Aug 02 2018 at 11:42, on Zulip):

In fact, had an idea, let me experiment a little more.

pnkfelix (Aug 02 2018 at 11:43, on Zulip):

okay, well I already r+'ed your PR

pnkfelix (Aug 02 2018 at 11:43, on Zulip):

so now you're on a race with bors

pnkfelix (Aug 02 2018 at 11:43, on Zulip):

but in my experience, bors tends to be the tortoise in these races.

pnkfelix (Aug 02 2018 at 11:43, on Zulip):

:)

davidtwco (Aug 02 2018 at 11:48, on Zulip):

@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?

pnkfelix (Aug 02 2018 at 11:49, on Zulip):

... hmm... no lets not do that

pnkfelix (Aug 02 2018 at 11:49, on Zulip):

or at least, that sounds pretty fragile

pnkfelix (Aug 02 2018 at 11:50, on Zulip):

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?

davidtwco (Aug 02 2018 at 11:50, on Zulip):

Yeah, I'm not sure.

davidtwco (Aug 02 2018 at 11:51, on Zulip):

For a test like this one (nll.stderr) what would you have it highlight ideally?

pnkfelix (Aug 02 2018 at 11:52, on Zulip):

/me is looking

pnkfelix (Aug 02 2018 at 11:53, on Zulip):

The occurrence of 'x in x: &'x isize, I think.

davidtwco (Aug 02 2018 at 11:53, on Zulip):

Yeah, that's what I figured it would be.

pnkfelix (Aug 02 2018 at 11:53, on Zulip):

what's the alternative you're considering? Not any of the 'z's, right?

davidtwco (Aug 02 2018 at 11:53, on Zulip):

I thought the same as you, the argument.

davidtwco (Aug 02 2018 at 11:53, on Zulip):

I'm close to having that, it just doesn't have the type in the span currently, just the name.

pnkfelix (Aug 02 2018 at 11:54, on Zulip):

This is of course a case where highlighting the binding <'x> is a fine UX, since the whole line gets printed.

pnkfelix (Aug 02 2018 at 11:54, on Zulip):

Oh, can we not find the span of the type via the LocalDecl?

davidtwco (Aug 02 2018 at 11:54, on Zulip):

But yeah, it could fail in where clauses.

pnkfelix (Aug 02 2018 at 11:54, on Zulip):

yeah

pnkfelix (Aug 02 2018 at 11:54, on Zulip):

you know

davidtwco (Aug 02 2018 at 11:54, on Zulip):

mir.local_decls[local].source_info.span is just the name, not the type annotation.

pnkfelix (Aug 02 2018 at 11:54, on Zulip):

looking at the stderr for the AST-borrowck

pnkfelix (Aug 02 2018 at 11:55, on Zulip):

it clearly does what you did

davidtwco (Aug 02 2018 at 11:55, on Zulip):

A quick glance didn't spot the type annotation span.

davidtwco (Aug 02 2018 at 11:55, on Zulip):

That's exactly where I got it from.

pnkfelix (Aug 02 2018 at 11:55, on Zulip):

i.e. highlights the binding site

pnkfelix (Aug 02 2018 at 11:55, on Zulip):

okay so lets not worry too much about this then

davidtwco (Aug 02 2018 at 11:55, on Zulip):

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.

pnkfelix (Aug 02 2018 at 11:55, on Zulip):

Our primary goal is just to make sure we're not egregiously worse than AST-borrowck

davidtwco (Aug 02 2018 at 11:56, on Zulip):

Alright, we can leave this as a potential future improvement then.

nikomatsakis (Aug 06 2018 at 12:22, on Zulip):

@davidtwco there is code to identify the 'a as part of the type that I wrote some time back

nikomatsakis (Aug 06 2018 at 12:22, on Zulip):

it was targeting anonymous lifetimes but could with relative ease be repurposed to named lifetimes, I think

Last update: Nov 21 2019 at 14:20UTC