Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptrigger unsized coercions keyed on Sized bounds #56219
Conversation
rust-highfive
assigned
eddyb
Nov 25, 2018
rust-highfive
added
the
S-waiting-on-review
label
Nov 25, 2018
arielb1
force-pushed the
arielb1:never-coerce-box
branch
2 times, most recently
from
116ecff
to
33db7c0
Nov 25, 2018
eddyb
reviewed
Nov 25, 2018
| } | ||
| } | ||
|
|
||
| /// FIXME: impl Trait why u give me lifetime errors? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
LGTM, r? @nikomatsakis |
rust-highfive
assigned
nikomatsakis
and unassigned
eddyb
Nov 25, 2018
Centril
added
the
T-lang
label
Nov 25, 2018
Centril
reviewed
Nov 25, 2018
src/librustc_typeck/check/mod.rs Outdated
This comment has been minimized.
This comment has been minimized.
We should test that with a crater run? |
This comment has been minimized.
This comment has been minimized.
I first tried to have the function return
I then tried to use the
Of course, my original design had closures instead of a struct implementing It would be nice if you could pinpoint a particular shortcoming with |
This comment has been minimized.
This comment has been minimized.
|
You need to write something like this (see #34511 (comment) for more details): impl Iterator<Item=ty::PolyTraitRef<'tcx>> + Captures<'gcx> + 'bIn general, add |
This comment was marked as resolved.
This comment was marked as resolved.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
So does this require a lang-team FCP? |
Centril
added
the
I-nominated
label
Nov 27, 2018
This comment has been minimized.
This comment has been minimized.
|
@arielb1 I think if not FCP we should at least discuss it (and so I've nominated it) since this has user observable type system changes. |
Centril
removed
the
I-nominated
label
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
|
We had a discussion in the @rust-lang/lang meeting and concluded that we should go ahead with this change, at least in some form. Although we are now taking more things into consideration for coercions (namely, pending coercions) and that's a bit risky, it's nice to fix a real problem, and this doesn't seem like a "fundamental complexity change" in the coercion rules. They've always taken into account "information gained from type-checking thus far" and now we are just expanding that to the "complete set of information" (i.e. not just equality constraints, but arbitrary obligations). I'd still personally like to spend some time tomorrow to think over some examples and try to be careful about precisely which obligations we consider, but the lang team is |
nikomatsakis
approved these changes
Nov 30, 2018
|
OK, I read over the changes, which look good. My only real hesitation is whether we want to try to be "intensional" about the set of obligations we consider for this role -- i.e., to trace the set of obligations that arise from the surrounding context in the same way we trace the 'expected type'. I believe that the existing closure checking code, which also uses obligations, was sort of aiming for this sort of limitation by tying itself to the case where (a) you have an expected type of an inference variable and (b) you have obligations directly referencing that variable. Pretty hacky, though. I want to experiment a bit with this branch -- which for example checks for unifications of the expected type inference variable -- to see which things work and which things don't, and if there's much real change. I'm building a local copy for this purpose. |
| proj_predicate | ||
| ) | ||
| }) | ||
| Some(()).filter(|()| { |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Nov 30, 2018
Contributor
What is the purpose of this construct? I suspect there's a clearer one out there =)
This comment has been minimized.
This comment has been minimized.
Note that the obligations here are on the "found type" (i.e., the result of Consider cases like fn let_expansion() -> Box<Error> {
let x = Box::new(!);
x /* should this work? */
}My personal expectation is that this code will work (BTW, it does not work ATM because of subtyping (the "is sized" relationship doesn't propagate through that) - should I change that?), with
I added the |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
Ping on this-- did you have a chance to experiment? I'd love to see this land, since it unblocks both |
arielb1
force-pushed the
arielb1:never-coerce-box
branch
from
c0e0d82
to
98faeb5
Dec 15, 2018
This comment has been minimized.
This comment has been minimized.
|
|
arielb1
added some commits
Nov 25, 2018
arielb1
force-pushed the
arielb1:never-coerce-box
branch
from
98faeb5
to
eeb8c8d
Dec 16, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r+ OK. I did another read through the code and gave a bit of thought to alternative approaches -- I decided that I'm game to land this, but I would really like us to prioritize modeling the Rust type checker and its coercions (I expect that to be done in a chalk-like setting). It feels really important that we have a good handle on what the compiler knows in order to make its judgements at any time etc. With regard to the subtyping rule, @arielb1, I'd rather take it slow. Let's open a FIXME perhaps and consider it as a follow-up? I think in my ideal world we would try to model the type-checker in a chalk-like style, so that we can express these coercions in that world (and ideally try to address the problem of over-eager coercions as well, although I'm not sure how easy that will be). This would probably be best to do in the context of the Traits Working Group, I guess. Seems like maybe a good Rust All Hands discussion topic. |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Dec 18, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
bors
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Dec 19, 2018
bors
added a commit
that referenced
this pull request
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
bors
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
@bors retry |
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Dec 20, 2018
This comment has been minimized.
This comment has been minimized.
|
|
arielb1 commentedNov 25, 2018
•
edited
This PR causes unsized coercions to not be disabled by
$0: Unsize<dyn Object>coercion obligations when we have an$0: Sizedobligation somewhere.This should be mostly backwards-compatible, because in these cases not doing the unsize coercion should have caused the
$0: Sizedobligation to fail.Note that
X: Unsize<dyn Object>obligations can't fail as obligations ifX: Sizedholds, so this still maintains some version of monotonicity (I think that an unsized coercion can't be converted to no coercion by unifying type variables).Fixes #49593 (unblocking never_type).
r? @eddyb
cc @nikomatsakis