Uh oh!
There was an error while loading. Please reload this page.
Partially implement type ascription - #30184
Conversation
petrochenkov
commented
Dec 3, 2015
Hm, @rust-highfive failed to assign a reviewer. r? @eddyb |
eddyb
commented
Dec 3, 2015
I wrote the original version of this code, so I'd rather have someone else look over it. |
bors
commented
Dec 4, 2015
☔ The latest upstream changes (presumably #29850) made this pull request unmergeable. Please resolve the merge conflicts. |
petrochenkov
commented
Dec 4, 2015
Rebased. |
bors
commented
Dec 16, 2015
☔ The latest upstream changes (presumably #30206) made this pull request unmergeable. Please resolve the merge conflicts. |
+ Apply parser changes manually + Add feature gate
petrochenkov
commented
Dec 16, 2015
Rebased. |
nikomatsakis
commented
Dec 17, 2015
Sorry for the delay! I'll get to this soon. |
There was a problem hiding this comment.
This doesn't seem right. I think we probably want to convert this to a ExprKind::Cast.
There was a problem hiding this comment.
/me reconsiders. Actually, let me read a bit more and get back to this point!
nikomatsakis
commented
Dec 18, 2015
@petrochenkov I didn't notice at first that you skipped over the coercion aspect. Makes sense for a first pass, this certainly simplifies things. The code looks great. The only thing I would want to add are some parsing tests that test the relative precedence of |
nikomatsakis
commented
Dec 18, 2015
Some examples tests for precedence:
The only tricky part is how to write such at est. I envisioned testing this by setting up some scenarios that will fail to type-check if the precedence is not correct? I'm not sure if there is a better way. |
petrochenkov
commented
Dec 18, 2015
Thanks! In fact my free time is coming to an end rapidly, so I have to wrap up my work on rustc ASAP (at least for now). |
nikomatsakis
commented
Dec 18, 2015
:( Let me know if there is work you think you will not have time for! I'd be happy to land this PR (or privacy) and then do the followup work myself. |
+ Rebase fixes
petrochenkov
commented
Dec 18, 2015
Updated with the operator precedence tests. |
nikomatsakis
commented
Dec 19, 2015
@bors r+ Another nice PR. Thanks @petrochenkov! |
bors
commented
Dec 19, 2015
📌 Commit 95fdaf2 has been approved by |
bors
commented
Dec 19, 2015
This PR is a rebase of the original PR by @eddyb#21836 with some unrebasable parts manually reapplied, feature gate added + type equality restriction added as described below. This implementation is partial because the type equality restriction is applied to all type ascription expressions and not only those in lvalue contexts. Thus, all difficulties with detection of these contexts and translation of coercions having effect in runtime are avoided. So, you can't write things with coercions like `let slice = &[1, 2, 3]: &[u8];`. It obviously makes type ascription less useful than it should be, but it's still much more useful than not having type ascription at all. In particular, things like `let v = something.iter().collect(): Vec<_>;` and `let u = t.into(): U;` work as expected and I'm pretty happy with these improvements alone. Part of #23416
bors
commented
Dec 19, 2015
petrochenkov
commented
Dec 19, 2015
This should probably be marked with |
This PR is a rebase of the original PR by @eddyb#21836 with some unrebasable parts manually reapplied, feature gate added + type equality restriction added as described below.
This implementation is partial because the type equality restriction is applied to all type ascription expressions and not only those in lvalue contexts. Thus, all difficulties with detection of these contexts and translation of coercions having effect in runtime are avoided.
So, you can't write things with coercions like
let slice = &[1, 2, 3]: &[u8];. It obviously makes type ascription less useful than it should be, but it's still much more useful than not having type ascription at all.In particular, things like
let v = something.iter().collect(): Vec<_>;andlet u = t.into(): U;work as expected and I'm pretty happy with these improvements alone.Part of #23416