Stream: t-compiler/wg-nll

Topic: mutability-lint


nikomatsakis (May 10 2018 at 14:21, on Zulip):

@Keith Yeung do you think you'll have a chance to check out https://github.com/rust-lang/rust/issues/50463 ?

Keith Yeung (May 10 2018 at 16:19, on Zulip):

I was indeed looking at it yesterday

Keith Yeung (May 10 2018 at 16:19, on Zulip):

The fix I envisioned in there doesn't actually work

nikomatsakis (May 10 2018 at 16:20, on Zulip):

ok, I've not looked at all

Keith Yeung (May 10 2018 at 16:35, on Zulip):

Oh, it just hit me

Keith Yeung (May 10 2018 at 16:35, on Zulip):

The problem is likely because we treat the first assignment as initialization

Keith Yeung (May 10 2018 at 21:07, on Zulip):

huh, so we treat mutable fn args as uninitialized at the beginning?

nikomatsakis (May 10 2018 at 21:07, on Zulip):

we have a "simple case" (no pattern) and a more complex case (pattern)

nikomatsakis (May 10 2018 at 21:07, on Zulip):

mut probably gets treated like the latter?

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

sometimes there are things like (a, b): (Foo, Bar)

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

in which case we have the actual argument, which has type (Foo, Bar)

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

and we then destructure it into locals for a and b

Keith Yeung (May 13 2018 at 18:12, on Zulip):

so i've switched from checking MaybeInitializedPlaces into EverInitializedPlaces in the mutability lint analysis, and the test cases all seem to pass

Keith Yeung (May 13 2018 at 18:13, on Zulip):

here's a complimentary PR to go with it: https://github.com/rust-lang/rust/pull/50697

nikomatsakis (May 14 2018 at 09:19, on Zulip):

ok :) I don't remember well enough to say if that makes sense but I can sort of imagine why it would

Keith Yeung (May 14 2018 at 21:13, on Zulip):

@pnkfelix you said that we'd need another unit test for testing out the changes in the WriteKind::MutableBorrow(BorrowKind::Unique) branch, what kind of code generates this MIR statement?

pnkfelix (May 15 2018 at 09:39, on Zulip):

BorrowKind::Unique arises from certain kinds of free variables in closures

pnkfelix (May 15 2018 at 09:40, on Zulip):

I'll try to set aside time to make an example later today

Keith Yeung (May 16 2018 at 18:49, on Zulip):

@pnkfelix looks like someone is depending on the fix, do you know how to create a test case that you mentioned?

Keith Yeung (May 16 2018 at 18:53, on Zulip):

if you're too busy, i can just remove that change altogether

pnkfelix (May 17 2018 at 10:22, on Zulip):

Hi @Keith Yeung sorry it took me so long to get back around to this. I posted a comment (some might say a shortish essay) on the PR, here

pnkfelix (May 17 2018 at 10:23, on Zulip):

Oh I missed your followup comment where you suggested removing the change. That is actually what I ended up coming around to by the end of writing that comment on the PR. So yes, removing that part of the change is probably best at this point.

Keith Yeung (May 17 2018 at 17:42, on Zulip):

I basically added that line because I recall from a previous conversation on a GH issue that you mentioned that we were supposed to have this check there

Keith Yeung (May 17 2018 at 19:14, on Zulip):

@pnkfelix ok, i removed that part of the change, can either you or @nikomatsakis approve it? https://github.com/rust-lang/rust/pull/50697

pnkfelix (May 17 2018 at 19:15, on Zulip):

thanks!

Keith Yeung (May 22 2018 at 04:47, on Zulip):

@pnkfelix i forgot to add a break statement in the previous PR, and i have a new one adding it: https://github.com/rust-lang/rust/pull/50958

Last update: Nov 21 2019 at 14:25UTC