Uh oh!
There was an error while loading. Please reload this page.
rustc: fixed regionck for owned trait casts. - #13129
Conversation
huonw
commented
Mar 25, 2014
Looks like something for @nikomatsakis to review. |
flaper87
commented
Mar 25, 2014
Does this fix #10751 too? If not, I guess it probably could. |
dmski
commented
Mar 25, 2014
It doesn't - from the look of it, #10751 seems similar to #12470, probably happens for the same reason: trait stores not being considered when inferring variance, which leads to respective regions not being related in a cast (please see #12828 for details). |
dmski
commented
Mar 25, 2014
dmski
commented
Mar 26, 2014
I've had a more thorough look at #10751 and i think it's happening because type bounds declared in trait impl just aren't taken into account when matching the type being cast to a trait and the type that the trait is implemented for (vtable.rs:361-372), so i think that is also not a bug i tried to fix here. |
pnkfelix
commented
Mar 26, 2014
cc me |
There was a problem hiding this comment.
nit: could you use just maybe_region to keep it consistent in style with the next arm?
There was a problem hiding this comment.
Done - i've squashed those two arms together actually, as they both do the same thing.
dmski
commented
Mar 27, 2014
Travis failures are because of #13079 and should go away with the next snapshot. |
dmski
commented
Apr 1, 2014
@bors: retry |
alexcrichton
commented
Apr 1, 2014
The tests need to be fixed for windows. The run-pass tests added need to have |
alexcrichton
commented
Apr 1, 2014
Sorry, not for windows, but for the check-fast target in the makefiles. |
dmski
commented
Apr 1, 2014
@alexcrichton ah, thanks! I somehow only saw "interrupted" everywhere and thought it was spurious. |
alexcrichton
commented
Apr 1, 2014
Sadly the |
dmski
commented
Apr 1, 2014
Have pushed an update - this passes both fast-check and check locally. |
dmski
commented
Apr 4, 2014
r? @cmr, @alexcrichton ? |
alexcrichton
commented
Apr 4, 2014
I don't consider myself qualified enough to review this portion of the compiler, I think @pnkfelix or @nikomatsakis would be more appropriate. There's some introductions of lifetimes which don't quite make sense to me, but perhaps it's more sound now... |
dmski
commented
Apr 4, 2014
@alexcrichton Ah, sorry then. It's just that this was r+'ed by @cmr earlier and failed in fast-check on windows due to non-pub fn main and i thought that it won't require another full-blown review. |
Regionck didn't do any checks for casts/coercions to an owned trait, which resulted in lifetimes of the source pointer to be ignored in the result of such cast. This fix constraints all regions of the source type of the cast/coercion to be superregions of each region of the target type (if target trait definition has some lifetime params), or of 'static lifetime (if there're no lifetime params in target trait's definition). Closesrust-lang#5723Closesrust-lang#9745Closesrust-lang#11971
nikomatsakis
commented
Apr 22, 2014
This code is headed in the right direction, but the details are off. There is really a general notion of a type being bounded by a lifetime L (meaning: all borrowed data reachable by the type has lifetime L or longer). The code doesn't really handle these cases correctly, leading to the bugs. I've been wanting to go in and refactor this for a while and your patch is definitely in the correct direction. What is perhaps surprising is that this bound has nothing to do with the lifetime parameters of the trait type. So, for example, if you have: To see what I mean, consider this example: Here the type In any case, I think limiting the check to the trait bound is in the right direction and would be enough for this patch. But when I tried to modify your branch locally I got some other compilation errors for the owned-ptr-static-bound test that I don't fully understand. I'll investigate tomorrow. |
dmski
commented
Apr 22, 2014
Thanks for the thorough explanation! As i understand, The solution with constraining casts to I guess the one possible 'correct' solution would be to actually allow one to write |
alexcrichton
commented
May 2, 2014
Closing due to inactivity, but feel free to reopen with a rebase! Also, perhaps some of this work will be enabled by #13898? |
dmski
commented
May 3, 2014
I've actually started moving in the general direction of my previous comment, having changed libsyntax to allow arbitrary lifetimes in bounds (i.e. roughly the same thing #13898 does). Got sidetracked by another project, but i'm still interested in implementing a proper fix for this. Does it make sense for me to continue here (rebasing my changes atop #13898), or is it better to find something else to work on, now that @nikomatsakis is working on this? |
alexcrichton
commented
May 3, 2014
I know that @nikomatsakis is deep in a number of large changes right now, so I would coordinate with him if you'd like to work on this area. |
nikomatsakis
commented
May 5, 2014
@dmski sorry for being incommunicative, I am about ... oh, I don't know, 90% of the way through enabling a more general notion of bounds. I agree this is the proper fix. |
dmski
commented
May 5, 2014
@nikomatsakis Thanks for letting me know. I'll keep an eye on PRs for this then. |
…xFrednet Add xFrednet back to Clippy's reviewer roulette What the title says. --- cc: rust-lang/rust-clippy#12947 changelog: none r? `@ghost`
Regionck didn't do any checks for casts/coercions to an owned trait,
which resulted in lifetimes of the source pointer
to be ignored in the result of such cast.
This fix constraints all regions of the source type of the cast/coercion to be superregions
of each region of the target type (if target trait definition has some lifetime params),
or of 'static lifetime (if there're no lifetime params in target trait's definition).
Closes#5723
Closes#9745
Closes#11971