-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
should let _: T = RHS
be synonymous with let _ = RHS: T
?
#56715
Comments
(Also, the aforementioned patch would also fix the test from #55748 (play) where NLL is causing us to accept code that we previously would have rejected. So could be used as an attempt to argue that the aforemented patch is "good"; but its entirely possible that a different path exists for a fix to #55748, so I won't further attempt to argue for the change on that basis. Instead I think the decision should be made based on the presentation of the various cases given above in this issue #56715 ) |
I think this is a T-lang issue as well as an NLL one. The change I am suggesting seems like it might only impact NLL (and will be downgraded to a warning when it errors under migration mode), but it still is something I want the T-lang team to look at. So I'll add that label here too. |
We discussed this a bit in the @rust-lang/lang meeting and decided that we needed to have further discussion. @pnkfelix -- one thing I would note though is that, as presently implemented, |
This seems likely. I wasn't aware it was meant to be a temporary hack. I'll go see if I can find record of discussion of that matter. |
@pnkfelix You might want to take a look here: rust-lang/rfcs#2522. |
@Centril hmm while I do see that RFC discusses lifetimes, I'm not sure if it goes so far as to discuss whether |
@pnkfelix See judgements in the section on static semantics. The first and second subsections notes that given types |
During a discussion on zulip, @nikomatsakis pointed out to me that given I found that to be a pretty compelling argument against what I am proposing here. |
Spawned off of #55748 (comment)
The Rust test suite currently has the following test of how subtyping and "covariance" (*) works with respect to regions.
rust/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs
Lines 24 to 31 in 3a31213
The problem is that there are small variations on this test that exercise very different parts of the compiler, and potentially expose incoherence in the semantics.
Here is some code that explores the different behaviors one might witness (play):
The entry in the summary that says "PATCHED" is for a 2018 compiler with the following patch applied to the following line of code:
rust/src/librustc_mir/build/matches/mod.rs
Lines 1339 to 1340 in 3a31213
The original reasoning behind that patch is that every other place that we use
AscribeUserType
, we use anInvariant
relation, not aCovariant
one.Note that the PATCHED version continues to handle the VAR and ARG cases in a manner consistent with the previous editions of Rust. In other words, in this instance, it just changes how
let _: T = RHS;
behaves to act more likelet _ = RHS: T;
(*): I put "covariance" in quote because I think Rust's definition of co/contravariance on regions is tied to a mental model that is not ideal for practical usage, see also rust-lang/rfcs#391
The text was updated successfully, but these errors were encountered: