Stream: t-compiler/wg-nll

Topic: ui/underscore-lifetime/dyn-trait-underscore.rs


nikomatsakis (May 31 2018 at 21:08, on Zulip):

but @David Wood let's continue here =)

davidtwco (May 31 2018 at 21:08, on Zulip):

Sure.

nikomatsakis (May 31 2018 at 21:08, on Zulip):

anyway I ran locally

nikomatsakis (May 31 2018 at 21:09, on Zulip):

do you know how to render those graphviz files as visible graphs?

nikomatsakis (May 31 2018 at 21:09, on Zulip):

I usually do dot -T svg foo.dot > foo.svg and open it in a browser

davidtwco (May 31 2018 at 21:10, on Zulip):

Yeah, I've done that before.

nikomatsakis (May 31 2018 at 21:12, on Zulip):

ok so anyway I'm looking at the graph now

nikomatsakis (May 31 2018 at 21:13, on Zulip):

however

nikomatsakis (May 31 2018 at 21:13, on Zulip):

it doesn't make it so easy to correlate with the file ;)

nikomatsakis (May 31 2018 at 21:16, on Zulip):

ok so @David Wood this is my theory :)

nikomatsakis (May 31 2018 at 21:16, on Zulip):

region constraints can come from a lot of places but

nikomatsakis (May 31 2018 at 21:17, on Zulip):

I think that it is helpful to distinguish those that arise from putting types "in tension" with one another — that's my term for it anyway. For example, if you do this: x = y, then you require that typeof(y) <: typeof(x)

nikomatsakis (May 31 2018 at 21:17, on Zulip):

I am calling y and x "in tension" there

nikomatsakis (May 31 2018 at 21:17, on Zulip):

in contrast, if you do let x: T = y, then we require that typeof(x) = T, which is not...

nikomatsakis (May 31 2018 at 21:18, on Zulip):

so anyway I sort of think we should be able to select — when type-checking — likely places like assignments that relate regions

nikomatsakis (May 31 2018 at 21:18, on Zulip):

well, I have to think about this some more :)

nikomatsakis (May 31 2018 at 21:18, on Zulip):

I had worked through some examples in the old regionck

nikomatsakis (May 31 2018 at 21:18, on Zulip):

I have to think how it relates to the new one

davidtwco (May 31 2018 at 21:19, on Zulip):

Sure thing, that makes sense so far.

nikomatsakis (May 31 2018 at 21:19, on Zulip):

I guess the TL;DR is I wodner if there is loower hanging fruit :)

nikomatsakis (May 31 2018 at 21:20, on Zulip):

but I'd sort of like to sit down with someone (maybe you! :) and talk this through

nikomatsakis (May 31 2018 at 21:20, on Zulip):

and see if we can find some heuristics we like

nikomatsakis (May 31 2018 at 21:20, on Zulip):

I guess to start we can add some causal information to the outlives, we are definitely going to need it

nikomatsakis (May 31 2018 at 21:20, on Zulip):

but maybe it's worth asking:

nikomatsakis (May 31 2018 at 21:20, on Zulip):

what would we like this error to look like anyway?

davidtwco (May 31 2018 at 21:21, on Zulip):

Yeah, that would probably help narrow down what all information we need to make it happen.

nikomatsakis (May 31 2018 at 21:21, on Zulip):

yeah that's usually how I start ...

nikomatsakis (May 31 2018 at 21:23, on Zulip):

I'm a bit torn here

nikomatsakis (May 31 2018 at 21:26, on Zulip):

I think my ideal message would be quite something like:

error[E0495]: `dyn` type can only capture static references
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                               ^^^^^^^^^^^^^^^^^^^^^ this `dyn` type has no bound and can only capture static references
...
18 |     Box::new(items.iter())
                  ------------ but non-static data flows into it from here
   = suggestion: try adding a bound
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> {
nikomatsakis (May 31 2018 at 21:26, on Zulip):

obviously that's pretty tailored to this case

nikomatsakis (May 31 2018 at 21:26, on Zulip):

but that's kind of how I want the errors to look ;)

nikomatsakis (May 31 2018 at 21:26, on Zulip):

otoh, that seems like "future work" potentially :)

nikomatsakis (May 31 2018 at 21:27, on Zulip):

it'd be interesting to look at some cases that are not about dyn

nikomatsakis (May 31 2018 at 21:27, on Zulip):

still, I can imagine doing this without that much difficulty

nikomatsakis (May 31 2018 at 21:27, on Zulip):

or at least something like it

nikomatsakis (May 31 2018 at 21:28, on Zulip):
error[E0495]: `dyn` type can only capture static references
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                               ^^^^^^^^^^^^^^^^^^^^^ this `dyn` type has a `'static` bound
...
18 |     Box::new(items.iter())
                  ------------ but non-static data flows into it from here
nikomatsakis (May 31 2018 at 21:28, on Zulip):

something like that might be quite doable

nikomatsakis (May 31 2018 at 21:28, on Zulip):

without undue changes

nikomatsakis (May 31 2018 at 21:29, on Zulip):

we'd have to track enough to know that the relationship to 'static derives from a dyn-type lifetime bound

nikomatsakis (May 31 2018 at 21:29, on Zulip):

and the parameter passing from items.iter() is what introduces the non-static ('1) free lifetime

nikomatsakis (May 31 2018 at 21:29, on Zulip):

the latter I think is fairly easy to do — we'd tag parameter passing as one of those "tension points" I was talking about

nikomatsakis (May 31 2018 at 21:29, on Zulip):

the former is a bit trickier, because that involves bridging some of the "older" region code

nikomatsakis (May 31 2018 at 21:30, on Zulip):

but it definitely knows

nikomatsakis (May 31 2018 at 21:30, on Zulip):

actually...

nikomatsakis (May 31 2018 at 21:30, on Zulip):

I think that comes from the casting code...

nikomatsakis (May 31 2018 at 21:31, on Zulip):

ah well I think requirement derives from the unsize cast,

nikomatsakis (May 31 2018 at 21:32, on Zulip):

and then from here in the traits code

nikomatsakis (May 31 2018 at 21:32, on Zulip):

so yeah not entirely trivial but doable

davidtwco (May 31 2018 at 21:33, on Zulip):

I think that this test was the only one that wasn't quite solved by the original issue-46983 PR - at least, it's the only one that I've found and seen mentioned in spreadsheets/paper docs against this issue.

nikomatsakis (May 31 2018 at 21:33, on Zulip):

which PR is that?

davidtwco (May 31 2018 at 21:33, on Zulip):

https://github.com/rust-lang/rust/pull/47329

nikomatsakis (May 31 2018 at 21:34, on Zulip):

I had forgotten about that...

davidtwco (May 31 2018 at 21:34, on Zulip):

(that's why I originally was in the issue-46983 topic as @pnkfelix had commented in that issue that this test was an example that needed fixed)

nikomatsakis (May 31 2018 at 21:34, on Zulip):

so I suspect we could do this without modifying the traits code

nikomatsakis (May 31 2018 at 21:35, on Zulip):

if we setup the "cause" appropriately -- i.e., use a cause that indicates this is a "unsizing cast"

nikomatsakis (May 31 2018 at 21:35, on Zulip):

and then extract that out for the ultimate outlives obligation

nikomatsakis (May 31 2018 at 21:36, on Zulip):

this in short is kind of the strategy I wanted to employ: we add causal information, but sparsely, driven by test cases, and only for "significant points" we can explain to a user

nikomatsakis (May 31 2018 at 21:36, on Zulip):

then when we display errors we can kind of look for things that lie along the path

nikomatsakis (May 31 2018 at 21:37, on Zulip):

which have causal information

nikomatsakis (May 31 2018 at 21:37, on Zulip):

as a step in that direction, we might just kind of dump out the causal information like the current checker does, and gradually make it more 'fluent"

nikomatsakis (May 31 2018 at 21:37, on Zulip):

I gotta run now but we could discuss in more depth tomorrow ;)

davidtwco (May 31 2018 at 21:38, on Zulip):

Sounds good, getting late here anyway.

nikomatsakis (Jun 01 2018 at 12:48, on Zulip):

If you want to chat about this, I'm around. I could also do some experimenting here, I wasn't sure how clearly I was able to communicate yesterday.

davidtwco (Jun 01 2018 at 13:20, on Zulip):

I'll be around in a few hours, at work just now.

davidtwco (Jun 01 2018 at 18:35, on Zulip):

Might not have time to chat about this today, my day is running on a bit. If you have some thoughts and want to dump them here than I can take a look when I've got a moment.

nikomatsakis (Jun 01 2018 at 18:35, on Zulip):

@David Wood ok

nikomatsakis (Jun 01 2018 at 18:35, on Zulip):

I may do a bit of hacking, but doing other things right now, so prob not (looking at perf)

nikomatsakis (Jun 01 2018 at 18:36, on Zulip):

if I do, I'll push a branch somewhere and leave a few notes

davidtwco (Jun 01 2018 at 18:36, on Zulip):

Sounds good.

davidtwco (Jun 04 2018 at 12:38, on Zulip):

@nikomatsakis Had a chance to look into this at all?

nikomatsakis (Jun 04 2018 at 12:38, on Zulip):

Actually, I was literally just making a branch to do some experimentation for a bit this morning

nikomatsakis (Jun 04 2018 at 12:38, on Zulip):

so no :)

nikomatsakis (Jun 04 2018 at 12:40, on Zulip):

I was thinking of extending Locations to track causal information

nikomatsakis (Jun 04 2018 at 12:41, on Zulip):

that reminds me that I really ought to try and land https://github.com/rust-lang/rust/pull/50938 at some point, as it simplifies Locations

nikomatsakis (Jun 04 2018 at 12:41, on Zulip):

@David Wood do you think you'd have time later today? (I presume you're working now)

nikomatsakis (Jun 04 2018 at 12:42, on Zulip):

I'd be interested in scheduling a time to do some pair experimentation

davidtwco (Jun 04 2018 at 12:47, on Zulip):

I reckon I should. It's 1.45pm here, I'll probably be available around 6.00pm for a while.

nikomatsakis (Jun 04 2018 at 12:59, on Zulip):

ok I realize that today I may be busy actually — have to see

nikomatsakis (Jun 04 2018 at 12:59, on Zulip):

but I'll poke a bit this morning and maybe see if I can leave some notes for you to pick up

davidtwco (Jun 04 2018 at 13:00, on Zulip):

:thumbs_up:

nikomatsakis (Jun 04 2018 at 16:20, on Zulip):

@David Wood I'm almost to the point of adding in some kind of very simple causal info; I'll push to a branch in a second

nikomatsakis (Jun 04 2018 at 16:21, on Zulip):

naturally got distracted by various things...

nikomatsakis (Jun 04 2018 at 16:21, on Zulip):

I'm hoping to render a graph soon showing it and see if we can figure out something from it :)

davidtwco (Jun 04 2018 at 16:23, on Zulip):

Great, just got in so I can have a look at it when you push.

nikomatsakis (Jun 04 2018 at 16:26, on Zulip):

ok, the branch is nll-borrow-diagnostics on my repository

nikomatsakis (Jun 04 2018 at 16:26, on Zulip):

I am still building locally though

nikomatsakis (Jun 04 2018 at 16:26, on Zulip):

the last commit is sloppy and mixes two things ;) but otherwise should be simple enough

nikomatsakis (Jun 04 2018 at 16:38, on Zulip):

ok, well, I got the imagine :) it's definitely still going to take some refinement

nikomatsakis (Jun 04 2018 at 16:38, on Zulip):

Screen-Shot-2018-06-04-at-12.39.05-PM.png

nikomatsakis (Jun 04 2018 at 16:38, on Zulip):

basically way too much interesting stuff :) I have to look more closely at theMIR

nikomatsakis (Jun 04 2018 at 16:39, on Zulip):

but it's a start...

nikomatsakis (Jun 04 2018 at 16:39, on Zulip):

I gotta run but I'll be online-ish

nikomatsakis (Jun 04 2018 at 21:05, on Zulip):

@David Wood still around?

davidtwco (Jun 04 2018 at 21:17, on Zulip):

@nikomatsakis yeah.

nikomatsakis (Jun 04 2018 at 22:25, on Zulip):

sorry, I left shortly before you wrote that :) back online for a bit

nikomatsakis (Jun 04 2018 at 22:25, on Zulip):

not sure if you got a chance to take a look at that branch :)

davidtwco (Jun 04 2018 at 22:25, on Zulip):

I had a glance through it, made some sense.

nikomatsakis (Jun 05 2018 at 10:13, on Zulip):

I tweaked the "interesting" criteria and now I think the set of edges is looking pretty good.

nikomatsakis (Jun 05 2018 at 10:13, on Zulip):

we still have to do a bit more refinement but it's basically pulling out the interesting spots...

nikomatsakis (Jun 05 2018 at 13:55, on Zulip):

you can see the SVG here

davidtwco (Jun 05 2018 at 14:02, on Zulip):

Nice - is there anything I can be doing related to this? This seems to be blocking my looking into #46983 (which is the topic this branched off from).

nikomatsakis (Jun 05 2018 at 14:39, on Zulip):

a good question :) I would definitely like to collaborate. i'm not sure the best way to set it up. Roughly what I had in mind is this:

1. the rough categorization of interesting vs boring is good, but to do better, we need to inspect the actions a bit more deeply. I think it's probably best to do this lazilly — arguably, the interesting vs boring categorization could wait entirely and be done lazilly, actually, but I suspect it's useful to have the ability to thread a bit of information down this way for later.
- in this case, the "interesting" cases boil down to Box::new and the various casts
- I think we can rule out Box::new as 'interesting' because it has a signature that is just taking the lifetime it gets as argument and propagating it to the return value; this is not something we have to highlight for the user
2. so basically I imagine a "general" output that kind of shows which regions have to be equal to 'static (we hsould discuss how to do that) and then highlights the interesting points in the MIR to show why

nikomatsakis (Jun 05 2018 at 14:40, on Zulip):

one thought I have is that we could still do a pair session maybe to go over this live, but I'm happy to try async

davidtwco (Jun 05 2018 at 14:55, on Zulip):

I'm happy to have a live session to look into it if we can work out a time.

davidtwco (Jun 05 2018 at 14:55, on Zulip):

Otherwise I just need pointed at something to work on and perhaps some pointers on what it should do/a starting point.

nikomatsakis (Jun 05 2018 at 14:57, on Zulip):

I'm happy to have a live session to look into it if we can work out a time.

yeah that's the tricky part :)

nikomatsakis (Jun 05 2018 at 14:57, on Zulip):

I'm actually free-ish this afternoon

nikomatsakis (Jun 05 2018 at 14:57, on Zulip):

(my time zone)

nikomatsakis (Jun 05 2018 at 14:57, on Zulip):

not sure what time you become available

davidtwco (Jun 05 2018 at 15:01, on Zulip):

Around the same as yesterday, two-to-three hours from now, roughly (and onwards from that).

nikomatsakis (Jun 05 2018 at 15:49, on Zulip):

great, ping me

davidtwco (Jun 05 2018 at 17:53, on Zulip):

@nikomatsakis around just now.

nikomatsakis (Jun 05 2018 at 19:40, on Zulip):

@David Wood argh I missed this! are you around after the meeting or is that too crazy late for you

davidtwco (Jun 05 2018 at 19:40, on Zulip):

I'm still around.

nikomatsakis (Jun 05 2018 at 19:40, on Zulip):

ok, I am free after this

nikomatsakis (Jun 05 2018 at 20:29, on Zulip):

@David Wood want to chat a bit then ?

davidtwco (Jun 05 2018 at 20:29, on Zulip):

Sure.

nikomatsakis (Jun 05 2018 at 20:30, on Zulip):

https://appear.in/i-heart-rust

davidtwco (Jun 05 2018 at 21:13, on Zulip):

@nikomatsakis that was helpful, I'll start looking into that, could you gist the file with the rough outline that you worked together?

nikomatsakis (Jun 05 2018 at 21:13, on Zulip):

yep!

nikomatsakis (Jun 05 2018 at 21:14, on Zulip):

https://gist.github.com/nikomatsakis/257ec66494a1fb2b0d5cde44ad24f1ce

nikomatsakis (Jun 05 2018 at 21:14, on Zulip):

what is the issue # again... @pnkfelix what was the issue that covered "nice region errors"?

davidtwco (Jun 05 2018 at 21:14, on Zulip):

https://github.com/rust-lang/rust/issues/46983 ?

davidtwco (Jun 05 2018 at 21:15, on Zulip):

You mentioned nice_region_errorrelated code in the original mentoring instructions.

nikomatsakis (Jun 05 2018 at 21:16, on Zulip):

that seems like a decent one to use I guess

nikomatsakis (Jun 05 2018 at 21:16, on Zulip):

I think there are a bunch of issues that kind of cover this point

nikomatsakis (Jun 05 2018 at 21:17, on Zulip):

ok, i'm encoding the video now

nikomatsakis (Jun 05 2018 at 21:17, on Zulip):

that...takes a while

nikomatsakis (Jun 05 2018 at 21:17, on Zulip):

~30 minutes claims the encoder :)

davidtwco (Jun 05 2018 at 21:18, on Zulip):

I doubt I'll properly dig in till tomorrow so it'll be done no doubt for me to refresh my memory with then.

nikomatsakis (Jun 05 2018 at 21:20, on Zulip):

+1

nikomatsakis (Jun 05 2018 at 21:20, on Zulip):

I realized I never posted the other one we made

nikomatsakis (Jun 05 2018 at 21:20, on Zulip):

forgot even what we talked about

nikomatsakis (Jun 05 2018 at 21:20, on Zulip):

I'll have to see if I still have the video file somewhere :)

davidtwco (Jun 05 2018 at 21:22, on Zulip):

I think we were looking at that function that was slow, ended up leading to the DFS change.

davidtwco (Jun 05 2018 at 21:22, on Zulip):

I realize that "that function that was slow" doesn't really narrow it down.

nikomatsakis (Jun 05 2018 at 21:22, on Zulip):

oh yes I recall

nikomatsakis (Jun 05 2018 at 21:23, on Zulip):

well, that worked

nikomatsakis (Jun 05 2018 at 21:23, on Zulip):

:)

davidtwco (Jun 07 2018 at 09:05, on Zulip):

@nikomatsakis a question regarding our previous discussion:

This is where the error we're seeing at present is reported. I imagine for the purposes of testing that I'll make an error at this point that has all the labels of interesting spots and so on.

I also think I understand roughly what the function that produces a ConstraintCategory will look like and similar with the ordering of those.

What I've not quite been able to figure out is how to glue all that together - am I right in thinking that I'd want to look at all the constraints that are relevant to the given function, consider only those that are interesting (based on your branch from earlier in the week) and for each of those find the ConstraintCategory - which will then be sorted and their spans labelled?

nikomatsakis (Jun 07 2018 at 09:06, on Zulip):

PS, first things first: you ought to move that code into its own module

nikomatsakis (Jun 07 2018 at 09:06, on Zulip):

traditionally called error_reporting.rs

davidtwco (Jun 07 2018 at 09:06, on Zulip):

Cool, I can do that.

nikomatsakis (Jun 07 2018 at 09:07, on Zulip):

I think what you want to do is probably similar to what blame_span does

nikomatsakis (Jun 07 2018 at 09:07, on Zulip):

basically, to do a depth-first search over the graph of constraints

nikomatsakis (Jun 07 2018 at 09:07, on Zulip):

er, dependencies is the one that actually does the search right now

nikomatsakis (Jun 07 2018 at 09:08, on Zulip):

but basically I imagined (a) getting a path through the graph

nikomatsakis (Jun 07 2018 at 09:08, on Zulip):

I suppose there could be multiple,

nikomatsakis (Jun 07 2018 at 09:08, on Zulip):

we can arbitrarily take the shortest one to make our lives easier...

nikomatsakis (Jun 07 2018 at 09:09, on Zulip):

well, dependencies is doing a kind of BFS

nikomatsakis (Jun 07 2018 at 09:09, on Zulip):

or a really inefficient version of a BFS ;)

nikomatsakis (Jun 07 2018 at 09:09, on Zulip):

but anyway I had imagined getting some kind of path (maybe a vec of paths, but let's start with one)

nikomatsakis (Jun 07 2018 at 09:10, on Zulip):

and then converting each edge on that path to a category

nikomatsakis (Jun 07 2018 at 09:10, on Zulip):

(for this purpose, you can ignore the uninterested ones, yes)

nikomatsakis (Jun 07 2018 at 09:10, on Zulip):

thus giving us a reduced vector of "categories"

nikomatsakis (Jun 07 2018 at 09:10, on Zulip):

so we go from Vec<ConstraintIndex> (the full path) to Vec<Category> (a shorter list of constraints)

nikomatsakis (Jun 07 2018 at 09:10, on Zulip):

then we can (a) find what looks like the best entry to call the "primary" span, and (b) issues labels for the rest

davidtwco (Jun 07 2018 at 09:11, on Zulip):

Alright, that makes sense.

nikomatsakis (Jun 07 2018 at 09:12, on Zulip):

actually a BFS (a true BFS) probably does make sense though

nikomatsakis (Jun 07 2018 at 09:12, on Zulip):

in the sense that it will find you a shortest path to start

nikomatsakis (Jun 07 2018 at 09:13, on Zulip):

otoh it's more of a pain to extract the path...

nikomatsakis (Jun 07 2018 at 09:13, on Zulip):

/me shrugs

nikomatsakis (Jun 07 2018 at 09:13, on Zulip):

the graph isn't that big so it shouldn't really matter that much

nikomatsakis (Jun 07 2018 at 09:13, on Zulip):

and it's only in the case of error

nikomatsakis (Jun 07 2018 at 09:13, on Zulip):

the graph isn't that big so it shouldn't really matter that much

"famous last words" if ever I heard them

nikomatsakis (Jun 07 2018 at 09:14, on Zulip):

anyway we can tweak that part later... =)

nikomatsakis (Jun 08 2018 at 13:27, on Zulip):

did you get a chance to look at this, @David Wood? (just curious)

davidtwco (Jun 08 2018 at 13:29, on Zulip):

I've only had a chance to dig around the existing code a little - intend to start on it tonight.

davidtwco (Jun 11 2018 at 22:10, on Zulip):

@nikomatsakis not had as much time to work on this as I'd have liked - but I've got the following branch so far - it has the BFS through the graph to find the paths and it then filters out the boring constraints. I still need to categorize and sort but I am not anticipating that being too bad.

nikomatsakis (Jun 12 2018 at 00:26, on Zulip):

@David Wood cool! I'll take a look

davidtwco (Jun 12 2018 at 19:45, on Zulip):

@nikomatsakis Made some more progress - now doing the categorization (albeit, poorly), sorting and emitting an error with labels. It looks pretty similar to what we drafted in the gist during our chat with lots of labelled points like "Cast" and so on.

The categorization however, is pretty poor, I'll need some guidance there on what categories should exist and how to work them out - right now I've got three and when I categorize my constraints I get "Cast" for each one..

davidtwco (Jun 13 2018 at 14:28, on Zulip):

@nikomatsakis Would you prefer I open a WIP PR with the above?

nikomatsakis (Jun 13 2018 at 14:34, on Zulip):

@David Wood yeah, that'd be great

nikomatsakis (Jun 13 2018 at 14:36, on Zulip):

this week is tough because of Moz All Hands; I skimmed the branch but...

davidtwco (Jun 13 2018 at 15:08, on Zulip):

That's fine, forgot it was All Hands week. :thumbs_up:

davidtwco (Jun 13 2018 at 15:20, on Zulip):

Submitted it as #51536 for next week.

davidtwco (Jun 18 2018 at 14:05, on Zulip):

@nikomatsakis Made some more progress - now doing the categorization (albeit, poorly), sorting and emitting an error with labels. It looks pretty similar to what we drafted in the gist during our chat with lots of labelled points like "Cast" and so on.

The categorization however, is pretty poor, I'll need some guidance there on what categories should exist and how to work them out - right now I've got three and when I categorize my constraints I get "Cast" for each one..

@nikomatsakis Whenever you've got some time, could you take a look at this?

nikomatsakis (Jun 18 2018 at 15:02, on Zulip):

@David Wood definitely, sorry about last week

davidtwco (Jun 18 2018 at 15:03, on Zulip):

No worries.

nikomatsakis (Jun 19 2018 at 18:27, on Zulip):

@David Wood hey, I'm talking about your branch with @pnkfelix now — did we have some place where we were taking notes?

nikomatsakis (Jun 19 2018 at 18:27, on Zulip):

I can't remember :)

davidtwco (Jun 19 2018 at 18:27, on Zulip):

I don't think so - other than the text file that we used when pair programming. At least, not that I recall.

nikomatsakis (Jun 19 2018 at 18:30, on Zulip):

ok, thanks

nikomatsakis (Jun 19 2018 at 18:30, on Zulip):

I found this, which was my sketch of "vaguely" the error I hoped we could produce

error[E0495]: this data would have to have static lifetime
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                  ---- fully elaborated type is `&'1 [T]`
18 |       Box::new(items.iter())
   |       ^^^^^^^^^^^^^^^^^^^^^^ casting this value to a `dyn Iterator` requires `'1` to outlive `'static`
19 |  }
davidtwco (Jun 19 2018 at 18:36, on Zulip):

Yeah. Right now, all I've got is the traversal of the constraints where we find a path, then filtering out interesting and boring constraints based on your work, then a very poor attempt at categorization, then sorting, then labelling. Like this example from the gist, but a bit worse:

error[E0495]: this data would have to have static lifetime
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                  ---- SourceArgument
18 |       Box::new(items.iter())
   |       ^^^^^^^^^^^^^^^^^^^^^^ InterestingSpot(Cast)
   |       |
   |       call to box
19 | }
nikomatsakis (Jun 19 2018 at 18:39, on Zulip):

let me read ...

nikomatsakis (Jun 20 2018 at 19:12, on Zulip):

@David Wood ping?

nikomatsakis (Jun 20 2018 at 19:31, on Zulip):

I left a review here, the TL;DR being that it looks good ...

davidtwco (Jun 20 2018 at 19:37, on Zulip):

@nikomatsakis pong

nikomatsakis (Jun 20 2018 at 19:38, on Zulip):

hey, just wanted to talk about next steps

davidtwco (Jun 20 2018 at 19:38, on Zulip):

Sounds good

davidtwco (Jun 20 2018 at 19:39, on Zulip):

Just taking a look at the review.

davidtwco (Jun 20 2018 at 22:13, on Zulip):

@nikomatsakis addressed the review comments and rebased that branch.

nikomatsakis (Jun 21 2018 at 16:07, on Zulip):

@David Wood great! However, I'm still confused, does it not affect the output of any tests yet?

nikomatsakis (Jun 21 2018 at 16:08, on Zulip):

What do you think we need to do to land it?

nikomatsakis (Jun 21 2018 at 16:08, on Zulip):

I'm trying to decide what's a good MVP

davidtwco (Jun 21 2018 at 16:08, on Zulip):

I've modified the it to show spans and their categories for whatever tests that part of the code normally handles.

davidtwco (Jun 21 2018 at 16:09, on Zulip):

That's useless as an actual diagnostic but it is useful to debug the categorization.

nikomatsakis (Jun 21 2018 at 16:09, on Zulip):

hmm ok let me read your latest commits more carefully

davidtwco (Jun 21 2018 at 16:10, on Zulip):

I'd like to get some feedback on the categorization - I think it's pretty poor so far, but the skeleton is there. You can scroll through the Travis output to see what it labels some spans as in tests that it affects.

davidtwco (Jun 21 2018 at 16:11, on Zulip):

After that we need to work out how we want to use those categories in making diagnostics.

nikomatsakis (Jun 21 2018 at 16:13, on Zulip):

ok :)

davidtwco (Jun 21 2018 at 16:13, on Zulip):

After our initial chat to plan the work, I think we decided that our first steps were just going to be categorization of interesting constraints, so I've not thought much past that.

nikomatsakis (Jun 21 2018 at 16:30, on Zulip):

After our initial chat to plan the work, I think we decided that our first steps were just going to be categorization of interesting constraints, so I've not thought much past that.

yes

nikomatsakis (Jun 21 2018 at 16:30, on Zulip):

ok so let me browse the travis errors

davidtwco (Jun 22 2018 at 15:05, on Zulip):

@nikomatsakis Any chance you could take a look at this before the weekend so I've got enough to keep me busy? No worries if you can't.

davidtwco (Jun 25 2018 at 10:19, on Zulip):

@nikomatsakis ping when you've got some time to chat about next steps for this.

nikomatsakis (Jun 25 2018 at 18:25, on Zulip):

@David Wood let's find a time

nikomatsakis (Jun 25 2018 at 18:25, on Zulip):

I'm around now-ish and should be around this week

nikomatsakis (Jun 25 2018 at 18:26, on Zulip):

it'd prob be helpful for me to schedule a time for us to chat (on zulip is prob fine) just to help me focus :)

davidtwco (Jun 25 2018 at 18:38, on Zulip):

@nikomatsakis I'm around just now.

nikomatsakis (Jun 25 2018 at 18:38, on Zulip):

ah, cool

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

ok so I guess the question is to figure out the next steps

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

I am very interesting in getting this to a MVP we can land

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

to some extent

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

the current messages are so bad

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

that it seems like we could land just about anything ;)

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

that said, I should get a local build going

nikomatsakis (Jun 25 2018 at 18:39, on Zulip):

it's hard to get a feeling for what's happening from the travis output

davidtwco (Jun 25 2018 at 18:41, on Zulip):

Right now I think the categorization needs improvement - but I'm not sure how to go about doing that (what categories we need, what we consider to be in what category). And then I'm not sure how we plan to use these categories in creating diagnostics.

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

ok so

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

it seems like there are a few things we could work on, yeah

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

one is improving categories

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

the other is the labels

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

my inclination is

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

that we should focus less on narrowing down the relevant points

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

and more on how to format them

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

i.e., we could land something first that adds too many labels

nikomatsakis (Jun 25 2018 at 18:42, on Zulip):

and then work on paring them down

nikomatsakis (Jun 25 2018 at 18:43, on Zulip):

I've got a local build of your branch going now, though it'll be a bit because this partcular directory has to rebuild LLVM

nikomatsakis (Jun 25 2018 at 18:45, on Zulip):

let me review again what you had

nikomatsakis (Jun 25 2018 at 18:45, on Zulip):
+/// Constraints that are considered interesting can be categorized to
+/// determine why they are interesting.
+#[derive(Debug, Eq, PartialEq, PartialOrd, Ord)]
+enum ConstraintCategory {
+    Assignment,
+    Cast,
+    CallArgument,
+    Other,
+}
davidtwco (Jun 25 2018 at 18:46, on Zulip):

I figured that there could probably be more categories.

nikomatsakis (Jun 25 2018 at 18:46, on Zulip):

I wonder if the "interesting" vs "not interersting" bit is really worth it

nikomatsakis (Jun 25 2018 at 18:46, on Zulip):

versus rolling everything into categories

nikomatsakis (Jun 25 2018 at 18:46, on Zulip):

it feels like two ways of getting at the same thing

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

in partcular, of those, I am nervous about "assignment"

davidtwco (Jun 25 2018 at 18:47, on Zulip):

Well, wasn't that so that we didn't label a span for a compiler-inserted temporary? My understanding was that was what was mostly being filtered out as boring.

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

because it seems to me that many assignments will be assignments into temporaries

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

that the user doesn't think of as assignments

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

Well, wasn't that so that we didn't label a span for a compiler-inserted temporary? My understanding was that was what was mostly being filtered out as boring.

well, my point is that we could do that filtering by mapping to a None category

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

which I guess you don't have here

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

or to Other

nikomatsakis (Jun 25 2018 at 18:47, on Zulip):

or Boring or something =)

davidtwco (Jun 25 2018 at 18:48, on Zulip):

Ah, I see, yeah, we could do that too.

nikomatsakis (Jun 25 2018 at 18:48, on Zulip):

we should also probably identify assignments to _0, which is the return slot

nikomatsakis (Jun 25 2018 at 18:49, on Zulip):

I think for a first draft we could create the following categories:

nikomatsakis (Jun 25 2018 at 18:49, on Zulip):

which is basically what you have

nikomatsakis (Jun 25 2018 at 18:49, on Zulip):

then the interesting thing is to figure out how to print them out

nikomatsakis (Jun 25 2018 at 18:50, on Zulip):

er, cast too is probably good :)

nikomatsakis (Jun 25 2018 at 18:50, on Zulip):

I think we do want to distinguish some kind of "miscellaneous" category from the "boring" category

davidtwco (Jun 25 2018 at 18:50, on Zulip):

Alright, I can do that.

nikomatsakis (Jun 25 2018 at 18:50, on Zulip):

basically, each of these will become an underline, and I think there is probably some set of things that seem important but we can use a kind of generic label about "data flow" or something for now

nikomatsakis (Jun 25 2018 at 18:50, on Zulip):

casts may fall in this category to start

nikomatsakis (Jun 25 2018 at 18:51, on Zulip):

since there are many kinds of casts

nikomatsakis (Jun 25 2018 at 18:51, on Zulip):

and really we will want to separate them out

nikomatsakis (Jun 25 2018 at 18:51, on Zulip):

so coming back to the output I was vaguely hoping for:

error[E0495]: this data would have to have static lifetime
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                  ---- fully elaborated type is `&'1 [T]`
18 |       Box::new(items.iter())
   |       ^^^^^^^^^^^^^^^^^^^^^^ casting this value to a `dyn Iterator` requires `'1` to outlive `'static`
19 |  }
davidtwco (Jun 25 2018 at 18:52, on Zulip):

Yeah, I wasn't sure how I'd transform the categorized constraints into something like that.

nikomatsakis (Jun 25 2018 at 18:57, on Zulip):

right so

nikomatsakis (Jun 25 2018 at 18:57, on Zulip):

there are a few parts

nikomatsakis (Jun 25 2018 at 18:58, on Zulip):

the "this data would have to have static lifetime" and "fully elaborated type" part

nikomatsakis (Jun 25 2018 at 18:58, on Zulip):

come from the original error

nikomatsakis (Jun 25 2018 at 18:58, on Zulip):

this part "casting this value to a dyn Iterator requires '1 to outlive 'static" comes from the constraint

nikomatsakis (Jun 25 2018 at 18:59, on Zulip):

( this is partly why i'd like to land something, as I think we could divide up these bits )

nikomatsakis (Jun 25 2018 at 18:59, on Zulip):

let's start with a simpler error which is closer to what we have...

nikomatsakis (Jun 25 2018 at 18:59, on Zulip):

I imagine something like this

nikomatsakis (Jun 25 2018 at 19:02, on Zulip):
error[E0495]: free region `` does not outlive free region `'static`
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                  ---- fully elaborated type is `&'1 [T]`
18 |       Box::new(items.iter())
   |       ^^^^^^^^^^^^^^^^^^^^^^ cast requires `` to outlive `'static`
19 |  }
nikomatsakis (Jun 25 2018 at 19:03, on Zulip):

this doesn't improve some of the core issues

nikomatsakis (Jun 25 2018 at 19:03, on Zulip):

but basically for each MIR statement with a "category"

davidtwco (Jun 25 2018 at 19:03, on Zulip):

I can take a stab at that, it seems doable. Understanding which parts of the diagnostic comes from what helps.

nikomatsakis (Jun 25 2018 at 19:03, on Zulip):

we would summarize the category with something like "foo requires SUB to outlive SUP"

nikomatsakis (Jun 25 2018 at 19:03, on Zulip):

where foo depends on the category

nikomatsakis (Jun 25 2018 at 19:04, on Zulip):

then we can separately attack how SUB and SUP are displayed (e.g., the empty string aspect :)

nikomatsakis (Jun 25 2018 at 19:04, on Zulip):

and also improving the categories and the wording thereof

davidtwco (Jun 25 2018 at 19:06, on Zulip):

:thumbs_up:

davidtwco (Jun 26 2018 at 21:33, on Zulip):

@nikomatsakis could you point me in the right direction with how I'd work out the span in your elaborated type label from the example? - can't figure out how to find that, it isn't one of the categorized spans.

error[E0495]: example
  --> dyn-trait-underscore.rs:18:20
   |
16 |   fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |                  ---- this span right here
18 |       Box::new(items.iter())
   |
19 |  }
nikomatsakis (Jun 26 2018 at 21:36, on Zulip):

ah, well, that's a tricky one

nikomatsakis (Jun 26 2018 at 21:36, on Zulip):

I don't think I expected you to have that span for the first commit :)

nikomatsakis (Jun 26 2018 at 21:37, on Zulip):

however, the way I would get it is to:

nikomatsakis (Jun 26 2018 at 21:37, on Zulip):

I can point you at some similar code that does that

davidtwco (Jun 26 2018 at 21:52, on Zulip):

@nikomatsakis So far I've added the "Boring" category and the "Return" category that you suggested adding yesterday. And I've got the following error message:

error: Cast requires that data must outlive free region `'static`
  --> src/test/ui/underscore-lifetime/dyn-trait-underscore.rs:18:5
   |
18 |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
   |     ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

I'd ideally like to have something a little better for the PR (it doesn't quite match your "lets start with something like this" suggestion from yesterday), but I guess we could try land that (if it's good enough) so we can get more people involved in the tasks that span out from this one. I can always branch off of this and work on a follow-up PR of improvements so similar code would be helpful.

nikomatsakis (Jun 26 2018 at 21:52, on Zulip):

where did the "cast requires" come from?

davidtwco (Jun 26 2018 at 21:53, on Zulip):

That's the category that the constraint had.

nikomatsakis (Jun 26 2018 at 21:53, on Zulip):

and in this csae there is only 1? (in general there might be multiple, right?)

davidtwco (Jun 26 2018 at 21:53, on Zulip):

There are multiple, this is the one that sorted first - the others point to roughly the same span though.

davidtwco (Jun 26 2018 at 21:54, on Zulip):

Well, there are multiple constraint paths, this is the shortest path and the constraint category that sorted lowest/highest/whichever-it-is in that path.

davidtwco (Jun 26 2018 at 21:55, on Zulip):

It finds all the constraint paths from the region we're reporting an error from, it takes the shortest of those paths, categorizes the constraints (edges) and then sorts them by the category (Ord on ConstraintCategory) and then picks the first one as the primary span.

nikomatsakis (Jun 26 2018 at 21:58, on Zulip):

ok well regardless it seems like an improvement

nikomatsakis (Jun 26 2018 at 21:58, on Zulip):

and that probably makes sense

nikomatsakis (Jun 26 2018 at 21:59, on Zulip):

as a means of deciding what to "highlight" in the error

davidtwco (Jun 26 2018 at 21:59, on Zulip):

It's what past-you wanted.

nikomatsakis (Jun 26 2018 at 21:59, on Zulip):

eventually we might do something else but basically having some heuristic that picks a category

nikomatsakis (Jun 26 2018 at 21:59, on Zulip):

ah, past-me was smart ;)

nikomatsakis (Jun 26 2018 at 21:59, on Zulip):

or at least -- shocking! -- I seem to agree with past-me

davidtwco (Jun 26 2018 at 22:01, on Zulip):

I'll check what tests it affects and then push the changes and see if I can't make Travis like this PR.

davidtwco (Jun 26 2018 at 22:32, on Zulip):

Pushed the above.

nikomatsakis (Jun 27 2018 at 19:51, on Zulip):

you around @David Wood ?

davidtwco (Jun 27 2018 at 19:51, on Zulip):

@nikomatsakis yeah

nikomatsakis (Jun 27 2018 at 19:51, on Zulip):

I am reviewing your PR

nikomatsakis (Jun 27 2018 at 19:51, on Zulip):

one very minor nit:

nikomatsakis (Jun 27 2018 at 19:51, on Zulip):

compiler error messages begin with a lower-case letter :)

nikomatsakis (Jun 27 2018 at 19:51, on Zulip):

think you can quickly patch that?

davidtwco (Jun 27 2018 at 19:51, on Zulip):

Yeah, sure thing.

davidtwco (Jun 27 2018 at 20:18, on Zulip):

@nikomatsakis Should have just fixed that.

nikomatsakis (Jun 27 2018 at 20:18, on Zulip):

cool

davidtwco (Jun 28 2018 at 18:19, on Zulip):

@nikomatsakis this branch has diverged so much from the current master.

davidtwco (Jun 28 2018 at 18:19, on Zulip):

Particularly the interesting/boring categorization that I built on.

davidtwco (Jun 28 2018 at 18:20, on Zulip):

Trying to tie these back together is painful.

nikomatsakis (Jun 28 2018 at 18:20, on Zulip):

oh hmm

nikomatsakis (Jun 28 2018 at 18:20, on Zulip):

/me tries to remember if he broke that

nikomatsakis (Jun 28 2018 at 18:20, on Zulip):

I can try to rebase that part if you want

davidtwco (Jun 28 2018 at 18:20, on Zulip):

I'd appreciate that.

nikomatsakis (Jun 28 2018 at 18:25, on Zulip):

working on it

nikomatsakis (Jun 28 2018 at 18:49, on Zulip):

heh yeah this is nasty

davidtwco (Jun 28 2018 at 18:49, on Zulip):

I got about three commits in but then it just got too different.

nikomatsakis (Jun 28 2018 at 18:55, on Zulip):

I have a rebased version that builds

nikomatsakis (Jun 28 2018 at 18:55, on Zulip):

I am going to run tests and see what it does :)

nikomatsakis (Jun 28 2018 at 19:13, on Zulip):

hmm something looks broken

test [ui] ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs has been running for over 60 seconds
test [ui] ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs has been running for over 60 seconds
test [ui] ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.rs has been running for over 60 seconds
test [ui] ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs has been running for over 60 seconds
test [ui] ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs has been running for over 60 seconds
test [ui] ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs has been running for over 60 seconds
test [ui] ui/nll/issue-50716.rs has been running for over 60 seconds
test [ui] ui/nll/ty-outlives/projection-one-region-closure.rs has been running for over 60 seconds
test [ui] ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs has been running for over 60 seconds
test [ui] ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs has been running for over 60 seconds
nikomatsakis (Jun 28 2018 at 19:13, on Zulip):

I'm guessing this is going into an infinite loop

davidtwco (Jun 28 2018 at 19:14, on Zulip):

:white_frowning_face:

nikomatsakis (Jun 28 2018 at 19:18, on Zulip):

investingating...

nikomatsakis (Jun 28 2018 at 20:12, on Zulip):

seems to be find_constraint_paths_from_region

davidtwco (Jun 28 2018 at 20:13, on Zulip):

Oh, that's strange.

davidtwco (Jun 28 2018 at 20:13, on Zulip):

I thought it checked to avoid re-visiting regions?

nikomatsakis (Jun 28 2018 at 20:13, on Zulip):

sample from debug output

nikomatsakis (Jun 28 2018 at 20:13, on Zulip):
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
DEBUG 2018-06-28T20:08:56Z: rustc_mir::borrow_check::nll::region_infer::error_reporting: find_constraint_paths_from_region: index=ConstraintIndex(30) region=Some('_#31r)
nikomatsakis (Jun 28 2018 at 20:14, on Zulip):

must be this loop

            while region.is_some() && region != Some(r0) {
                let p = previous.get(&region.unwrap()).unwrap();
                index = p.0;
                region = p.1;

                debug!("find_constraint_paths_from_region: index={:?} region={:?}", index, region);
                path.push(index);
            }
nikomatsakis (Jun 28 2018 at 20:14, on Zulip):

I'm not really clear on why this should've changed

nikomatsakis (Jun 28 2018 at 20:14, on Zulip):

but we might be generating slightly different constraints than we did before

nikomatsakis (Jun 28 2018 at 20:14, on Zulip):

want me to push the rebase, and you can debug?

nikomatsakis (Jun 28 2018 at 20:15, on Zulip):

/me is doing that

davidtwco (Jun 28 2018 at 20:15, on Zulip):

Yeah, no problem.

nikomatsakis (Jun 28 2018 at 20:15, on Zulip):

I'm realizing how little I understand that code ;)

nikomatsakis (Jun 28 2018 at 20:15, on Zulip):

I mean I understand it at a high level

nikomatsakis (Jun 28 2018 at 20:15, on Zulip):

:)

nikomatsakis (Jun 29 2018 at 19:10, on Zulip):

@David Wood how did this go? did you ever find the problem?

davidtwco (Jun 29 2018 at 19:14, on Zulip):

I didn't get a chance yesterday. Building it now.

davidtwco (Jun 29 2018 at 20:31, on Zulip):

@nikomatsakis what's the flag for graphviz output?

davidtwco (Jun 29 2018 at 20:31, on Zulip):

Forgotten it.

lqd (Jun 29 2018 at 20:38, on Zulip):

-Zdump_mir_graphviz ?

davidtwco (Jun 29 2018 at 20:39, on Zulip):

I'd been doing -Z dump-mir=all and getting no .dot files, very confusing.

davidtwco (Jun 29 2018 at 21:23, on Zulip):

@nikomatsakis Pushed a fix to that infinite loop issue. Not ran _all_ the tests, but one that was infinite looping is no longer infinite looping.

davidtwco (Jun 29 2018 at 22:25, on Zulip):

Well, as it turns out I should have ran all the tests.

davidtwco (Jun 29 2018 at 23:11, on Zulip):

N-th time lucky.

davidtwco (Jul 01 2018 at 15:15, on Zulip):

@nikomatsakis Can you r+ the PR before I need to rebase again?

nikomatsakis (Jul 01 2018 at 15:15, on Zulip):

er, yes, done

nikomatsakis (Jul 01 2018 at 15:15, on Zulip):

I didn't get a chance to read that closely yet your latest changes, but it's ok

davidtwco (Jul 01 2018 at 15:16, on Zulip):

There's been no changes other than rebasing and the infinite loop fix (which was just moving a line) since you last r+'d.

nikomatsakis (Jul 01 2018 at 15:18, on Zulip):

ok

nikomatsakis (Jul 01 2018 at 15:18, on Zulip):

it was the infinite loop fix I hadn't read :)

davidtwco (Jul 01 2018 at 15:19, on Zulip):

I had to move when I considered a region visited in the DFS to before I looked at the edges going from it instead of after. This meant that if a region had a constraint to itself (which it must have had after the rebase) then it wouldn't cause an issue later when working out the paths.

davidtwco (Jul 01 2018 at 20:18, on Zulip):

@nikomatsakis Now that's merged, what are the next steps for it?

nikomatsakis (Jul 02 2018 at 14:07, on Zulip):

@David Wood good question! :) I'll try to prep an answer shortly, fits well with the planning I was hoping to do today

nikomatsakis (Jul 02 2018 at 19:25, on Zulip):

@David Wood ok so I am noticing some mildly surprising behavior from the current region inference stuff

nikomatsakis (Jul 02 2018 at 19:25, on Zulip):

in particular it's not finding the "interesting constriants" I expect

nikomatsakis (Jul 02 2018 at 19:25, on Zulip):

in at least one test case :)

nikomatsakis (Jul 02 2018 at 19:25, on Zulip):

I may try to debug it, or else to leave a comment if you want to take a look

nikomatsakis (Jul 02 2018 at 19:25, on Zulip):

I'm trying to figure out how to manage this region error thing, there are a lot of moving parts

davidtwco (Jul 02 2018 at 19:26, on Zulip):

Oh, that's interesting.

nikomatsakis (Jul 02 2018 at 19:26, on Zulip):

so in particular I see this graph:

nikomatsakis (Jul 02 2018 at 19:26, on Zulip):

Screen-Shot-2018-07-02-at-3.22.14-PM.png

nikomatsakis (Jul 02 2018 at 19:27, on Zulip):

from the borrowck/issue-45983.rs test case

nikomatsakis (Jul 02 2018 at 19:27, on Zulip):

the two regions in question are '_#2r and '_#3r

nikomatsakis (Jul 02 2018 at 19:27, on Zulip):

so it seems like the "interesting" one is bb0[2]

nikomatsakis (Jul 02 2018 at 19:27, on Zulip):

but right now we are .. not finding that

nikomatsakis (Jul 02 2018 at 19:27, on Zulip):

I can't quite figure out how to interpret the debug! output

nikomatsakis (Jul 02 2018 at 19:28, on Zulip):

I have to look at the code a bit more closely I think

nikomatsakis (Jul 02 2018 at 19:28, on Zulip):

anyway, that is the right answer it turns out

nikomatsakis (Jul 02 2018 at 19:28, on Zulip):

(I'm writing up some comments about how to handle the closure errors, and this is the test case I am looking at)

davidtwco (Jul 02 2018 at 19:31, on Zulip):

For that to be a boring region, doesn't that mean it acts on a temporary?

nikomatsakis (Jul 02 2018 at 19:41, on Zulip):

hmm perhaps that is the problem

nikomatsakis (Jul 02 2018 at 19:41, on Zulip):

some notes here:

https://github.com/rust-lang/rust/issues/51027#issuecomment-401912102

nikomatsakis (Jul 02 2018 at 19:42, on Zulip):

on the closure problem anyway

nikomatsakis (Jul 02 2018 at 19:42, on Zulip):

I want to turn my attention back to the dyn-underscore problem now — I feel like we're getting close to a more "unified region error reporting" thing but I don't quite see it yet :)

nikomatsakis (Jul 02 2018 at 19:42, on Zulip):

that said, I should probably take what little time I have left today (grr, that took forever to dig into) and focus on finding some lower hanging fruit

nikomatsakis (Jul 02 2018 at 19:42, on Zulip):

I dont' really have much idea what issues to highlight just now...

nikomatsakis (Jul 02 2018 at 19:45, on Zulip):

jfyi the assignment is writing to

(*(_1.0: &'_#5r mut std::option::Option<&'_#6r ()>))

where _1.0 is an upvar field projection

davidtwco (Jul 02 2018 at 19:46, on Zulip):

That's a captured variable in a closure, right?

davidtwco (Jul 02 2018 at 19:47, on Zulip):

Is there a way to check if something is a upvar before considering it boring?

nikomatsakis (Jul 02 2018 at 19:51, on Zulip):

ultimately I think the boring idea was not the right one, on my part

nikomatsakis (Jul 02 2018 at 19:51, on Zulip):

that is, I think we should just use the categorization later on

nikomatsakis (Jul 02 2018 at 19:51, on Zulip):

and deciding boring/interesting then

nikomatsakis (Jul 02 2018 at 19:51, on Zulip):

I don't think there is any context that we have in the beginning

nikomatsakis (Jul 02 2018 at 19:51, on Zulip):

which we lack later on

nikomatsakis (Jul 02 2018 at 19:52, on Zulip):

in any case, yes, it is easy to tell upvar projections

davidtwco (Jul 02 2018 at 19:52, on Zulip):

Perhaps that's a decent small next step?

nikomatsakis (Jul 02 2018 at 20:00, on Zulip):

perhaps so

nikomatsakis (Jul 02 2018 at 20:00, on Zulip):

are you interested in poking at the closure stuff? you might try skimming those notes

nikomatsakis (Jul 02 2018 at 20:00, on Zulip):

and see if they make some measure of sense to you :)

davidtwco (Jul 02 2018 at 20:01, on Zulip):

I'll take a look when I've got a moment.

nikomatsakis (Jul 03 2018 at 09:12, on Zulip):

@David Wood so I'm taking a closer look at the region error reporting code on master and doing a bit of experimentation

nikomatsakis (Jul 03 2018 at 09:12, on Zulip):

jfyi

nikomatsakis (Jul 03 2018 at 09:13, on Zulip):

I noticed (to start) some opportunities for cleanup, so I might just open a cleanup PR and r? you

davidtwco (Jul 03 2018 at 09:13, on Zulip):

Sounds good, there's likely plenty of room for improvement.

nikomatsakis (Jul 03 2018 at 15:30, on Zulip):

@David Wood ok I have some progress, gonna open a PR soon

nikomatsakis (Jul 03 2018 at 15:34, on Zulip):

e.g., output for issue-45983.rs is:

error: unsatisfied lifetime constraints
  --> borrowck/issue-45983.rs:17:18
   |
16 |     let x = None;
   |         - region `'2` appears in the type of `x`
17 |     give_any(|y| x = Some(y));
   |               -  ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
   |               |
   |               region `'1` appears in this argument
nikomatsakis (Jul 03 2018 at 15:34, on Zulip):

(that's one of the closure ones)

nikomatsakis (Jul 03 2018 at 15:34, on Zulip):

the "region '2 appears in the type of x" message was intended to eventually become something like "fully elaborated type of x is ..."

nikomatsakis (Jul 03 2018 at 15:35, on Zulip):

obviously this is not specialized to closures at all

nikomatsakis (Jul 03 2018 at 15:36, on Zulip):

the dyn-trait-underscore is printing:

error: unsatisfied lifetime constraints
  --> underscore-lifetime/dyn-trait-underscore.rs:18:5
   |
16 | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |         ----- region `'1` appears in this argument
17 |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
   |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`
nikomatsakis (Jul 03 2018 at 15:36, on Zulip):

which is ... kinda good :)

nikomatsakis (Jul 03 2018 at 15:36, on Zulip):

it'd be nice to underline the return type, didn't get to that yet

nikomatsakis (Jul 03 2018 at 15:36, on Zulip):

that'd be some more special cases

nikomatsakis (Jul 03 2018 at 15:36, on Zulip):

my goal though is to get something where we can make smaller PRs adding various special cases :)

nikomatsakis (Jul 03 2018 at 15:38, on Zulip):

this might be a perfect place for an error code actually

nikomatsakis (Jul 03 2018 at 15:38, on Zulip):

that is, maybe we can explain "how to read this error", once we get closer

nikomatsakis (Jul 03 2018 at 15:38, on Zulip):

hopefully we can get it good enough that — with a bit of guidance — mere mortals can actually do so

davidtwco (Jul 03 2018 at 16:10, on Zulip):

That certainly simplifies what I had for finding paths.

davidtwco (Jul 03 2018 at 16:11, on Zulip):

In the most recent example you've sent here, I think we need to break down "cast" more - it's not obvious (at least to me) that what is being highlighted is a cast (from a end-user reading their code perspective).

nikomatsakis (Jul 03 2018 at 16:11, on Zulip):

presuming that https://github.com/rust-lang/rust/pull/51987 turns out to be a win,

nikomatsakis (Jul 03 2018 at 16:11, on Zulip):

the code likely gets simpler still

nikomatsakis (Jul 03 2018 at 16:11, on Zulip):

since we can just walk the tree of constraints...

nikomatsakis (Jul 03 2018 at 16:12, on Zulip):

yes, that's Yet Another orthogonal sort of problem

nikomatsakis (Jul 03 2018 at 16:12, on Zulip):

but a tricky one

nikomatsakis (Jul 03 2018 at 16:12, on Zulip):

it's particularly not obvious here I guess

nikomatsakis (Jul 03 2018 at 16:12, on Zulip):

since the "cast" is an implicit coercion

nikomatsakis (Jul 03 2018 at 16:12, on Zulip):

we need to thread more information through there

nikomatsakis (Jul 03 2018 at 16:12, on Zulip):

still, you gotta remember the competition for this particular error :)

nikomatsakis (Jul 03 2018 at 16:13, on Zulip):
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
  --> underscore-lifetime/dyn-trait-underscore.rs:18:20
   |
18 |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
   |                    ^^^^
   |
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 16:1...
  --> underscore-lifetime/dyn-trait-underscore.rs:16:1
   |
16 | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
17 | |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
18 | |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
19 | | }
   | |_^
note: ...so that reference does not outlive borrowed content
  --> underscore-lifetime/dyn-trait-underscore.rs:18:14
   |
18 |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
   |              ^^^^^
   = note: but, the lifetime must be valid for the static lifetime...
   = note: ...so that the expression is assignable:
           expected std::boxed::Box<(dyn std::iter::Iterator<Item=&T> + 'static)>
              found std::boxed::Box<dyn std::iter::Iterator<Item=&T>>
nikomatsakis (Jul 03 2018 at 16:13, on Zulip):

not exactly super comprehensible

davidtwco (Jul 03 2018 at 16:13, on Zulip):

The first example you gave with the closure is much improved.

davidtwco (Jul 03 2018 at 16:13, on Zulip):

Yeah, just naming the regions is a significant improvement.

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

that said,

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

it is interesting that this one

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

highlights the source more

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

i.e., the items

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

and not the cast

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

we can do that too

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

another follow-up :)

nikomatsakis (Jul 03 2018 at 16:14, on Zulip):

it basically all comes down to using more of the information in that causal chain

Last update: Nov 21 2019 at 13:55UTC