Uh oh!
There was an error while loading. Please reload this page.
Disallow subtyping between T and U in T: Unsize<U>. - #40319
Hidden character warning
Conversation
rust-highfive
commented
Mar 7, 2017
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
eddyb
commented
Mar 7, 2017
(starting crater run now) |
nikomatsakis
commented
Mar 7, 2017
nikomatsakis
commented
Mar 7, 2017
The code looks good to me, curious to hear the results of the crater run. I'll try to do a quick skim through the code to convince myself that these are all the relevant cases though. |
152f1c7 to
608d080CompareThere was a problem hiding this comment.
Don't you need this also on the raw ptr path? better to subtype source as one unit.
There was a problem hiding this comment.
Subtype first, then resolve the variable, then reborrow from &mut and/or to raw pointers?
There was a problem hiding this comment.
Aaaaah, that would also keep Rc working! I'll try to do it that way and add more testcases.
608d080 to
721f5b8CompareCrater report shows
EDIT: some were false positives, see #40319 (comment) |
Stebalien
commented
Mar 8, 2017
Different crates but the issue in both stems from the |
@Stebalien I hadn't even realized that was the original report! Alright, I'm more confident now. Assuming only |
So the crates that other crates depend on are:
Everything else we can break without having a cascade of regressions. |
abonander
commented
Mar 8, 2017
I've already got this fixed in |
@abonander (and everyone else) Ping me when you have the fix on a branch somewhere, or a patch in a gist, etc. if you want a confirmation that it indeed compiles with the changes in this PR. |
abonander
commented
Mar 8, 2017
@eddyb branch |
eddyb
commented
Mar 8, 2017
@abonander It compiles 👍 |
abonander
commented
Mar 8, 2017
@eddyb Published. |
mikedilger
commented
Mar 8, 2017
@eddyb Not sure I understand the bug very well, but I hope a simple sub-scope makes the borrow issue go away. Let me know if thats right or if I need some other fix. https://github.com/mikedilger/mime-multipart/tree/rust40288 |
@mikedilger Almost! I was getting confused by not knowing what is actually keeping the borrow alive. |
mikedilger
commented
Mar 8, 2017
@eddyb Ok, I (evilly) force-pushed https://github.com/mikedilger/mime-multipart/tree/rust40288 and also created https://github.com/mikedilger/mime-multipart/tree/rust40288_03 for the 0.3 branch. Once they are confirmed to work I'll pull them in and publish new versions. |
eddyb
commented
Mar 8, 2017
@mikedilger Those do indeed work, thank you! |
mikedilger
commented
Mar 8, 2017
@eddyb Published. |
There was a problem hiding this comment.
Not needing use_lub felt wrong, and it is! Reordering these twomatch arms "fixes" the false positive, but both orders should work identically.
I'm preparing an improved version that should not have this problem.
Rollup of 38 pull requests - Successful merges: #39202, #39820, #39918, #39921, #40092, #40146, #40199, #40225, #40239, #40257, #40259, #40261, #40277, #40278, #40287, #40297, #40311, #40315, #40319, #40324, #40336, #40340, #40344, #40345, #40367, #40369, #40372, #40373, #40379, #40385, #40386, #40389, #40400, #40404, #40410, #40422, #40423, #40424 - Failed merges: #40220, #40329, #40426
Rollup of 38 pull requests - Successful merges: #39202, #39820, #39918, #39921, #40092, #40146, #40199, #40225, #40239, #40257, #40259, #40261, #40277, #40278, #40287, #40297, #40311, #40315, #40319, #40324, #40336, #40340, #40344, #40345, #40367, #40369, #40372, #40373, #40379, #40385, #40386, #40389, #40400, #40404, #40410, #40422, #40423, #40424 - Failed merges: #40220, #40329, #40426
…r=nikomatsakis Disallow subtyping between T and U in T: Unsize<U>. Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixesrust-lang#40288. E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes. Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
…r=nikomatsakis Disallow subtyping between T and U in T: Unsize<U>. Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixesrust-lang#40288. E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes. Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
Because
&mut Tcan be coerced to&mut U,TandUmust be unified invariantly. Fixes#40288.E.g. coercing
&mut [&'a X; N]to&mut [&'b X]must require'abe equal to'b, otherwise you can convert between&'a Xand&'b X(in either direction), potentially unsoundly lengthening lifetimes.Subtyping here was introduced with
Unsizein #24619 (landed in 1.1, original PR is #23785).