-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
finish up type alias PRs #55222
Comments
cc @Centril |
Seems good to RC2-block on this, as it might otherwise not get done at all. :) |
So I spent a few hours today studying the PRs and rebasing #54090. Landing this PR as is is clearly not an option:
Obviously, moving to a warning on Rust 2015 would help with the "breaks Diesel" thing. I'm feeling a bit nervous about trying to block on this for the edition, simply from a "Project Management" point of view -- and especially for RC2. I am worried that there will be unexpected fallout and I'm not sure if it's a change we have to do, at least not now. Obviously, it would lay the groundwork for a rationalization of On the other hand, it adds a certain amount of risk, as the Diesel example shows. It's not going to be so easy to do the migration without elaborating and normalizing, and that creates a cycle error right now. I might rather hold off for now and then add lints for all editions that warn about extra bounds and globally non-WF types. We can use the At that point, once we have warnings in place, we can tighten them and eventually move to a hard-error. The crater runs do suggest we could migrate the ecosystem globally but at worst we can do it for Rust 2021. All in all, it feels better to me to make this transition slowly rather than trying to squeeze it in last minute. |
I am in agreement that we should land this in a slow transition via gradual lints. We are very close to the release for the 2018 edition and the risk/reward proposition strikes me as pointing clearly towards taking the gradual route. @Centril said that we should RC2-block on this, or else it might not get done at all. Usually I take that to mean “if we don’t make this adjustment before initial deployment, too much code will be written that relies on the undesirable semantics” But in this case we’re taking about a feature that has been in Rust since 1.0; there’s going to be pain associationed with the shift here no matter what (unless Am I misunderstanding something about why @Centril says we should RC2-block on this? |
(I do understand the idea that new code will be written targeting the 2018 edition, and that’s why it’s good to try to time the painful shifts with that transition; that’s been part of why I’ve pushed to couple the initial NLL deployment with the edition. But again: I’m trying to understand the risk/reward proposition in this case.) |
I wanted to note one other thing: I feel like we ought to be able to make rustfix able to handle this, at least in the majority of cases. This may not change anything fundamental, just an interesting thing to note.
indeed, the difference being that NLL is also a major edition "deliverable" -- i.e., a big part of the reason to have an edition in the first place is being able to tout "come experience the new Rust borrow checker, it's friendlier" |
Yeah; basically that's it. But if you think it won't be a problem and we can do the gradual way instead, then I'll defer to y'all's judgement. |
At this point I just don't see a path to get this into RC2 at all. I'm removing from milestones — I think we have no real choice but the gradual path. Slow and steady, we'll get there! |
I'm really sorry I wasn't able to carry this to completion. Solving the Excluding But overall, if we don't break anything on the edition, there's still hope. I think one of my PRs has enough type/trait diagnostic infrastructure improvements for this, we just need to get lazy normalization to be able to defer resolving the alias. |
(I still plan on following up on this, though I'm focusing my immediate energy more on the universe transition and lazy normalization.) |
🙏 |
I was thinking about this some more. It may be that we can preserve the existing behavior, though it's not entirely clear we want to, for consistency reasons. But backwards compatibility may be king here. The basic idea was that we wanted to treat the use
as effectively "desugaring" to something like
The problem here is that we would, given our ordinary rules around impls, try to prove that (in chalk terms):
and -- for many types However, we could also desugar to an impl like this: impl<P0...Pn> FooTrait<P0..Pn> for ()
where
WF(Bar)
{
type Out = Bar;
} This would effectively push the problem of proving that the expansion type At this point you could certainly imagine transitioning this scheme "slightly" on an edition boundary, and it'd be relatively easy to do. (cc @scalexm, who may have thoughts on whether this makes any sense) |
@nikomatsakis Would we actually want to desugar to trait and impl, or directly to Chalk. Anyway, I am intuitively in favour of "including the where-clause" and thus pushing the duty of proving the WF up to the use site site. I reckon that would work fairly well. Should we get @eddyb's thoughts on this too? |
We would not actually desugar to traits/impls, but rather to (roughly equivalent) chalk predicates. |
@nikomatsakis I've not followed everything. So the deal is that in this program: struct Bar<T: Clone>(T);
type Foo<T> = Bar<T>; // (*) we'd want the line Regarding your desugaring, I'm always a bit wary about having I presume that in every case, we need chalk to implement your desugaring (because having type Foo<P1...Pn> = Bar<...>;
// Desugars to
trait FooTrait<X> {
type Out;
}
impl<P1...Pn> FooTrait<Bar<...>> for (P1, ..., Pn) {
type Out = Bar<...>;
} This way, Then it would be used like so: let x: Foo<X1...Xn>;
// Desugars to
let x: <(X1, ..., Xn) as FooTrait<_>>::Out; Because |
Actually, if we adopted the desugaring I was proposed, then I would not expect any error in that program. The error would occur later, when I think that — all things being equal — I would want your example to be an error at the point you indicated. But backwards compatibility may be a factor here; I could imagine trying to make that change over an edition, for example.
What makes that seem like a hack to you? It doesn't seem particularly different to me from the usual shift we do on where-clauses.
Interesting. I suppose that is equivalent. (I think this also means that we wouldn't get an error until the use-site, right?) |
On where-clauses, we map
Right. |
cc'ing #51626, which presents an interesting case to remember -- basically, if you have a |
cc #21903 |
We had a design meeting on this topic, notes and recording available here. |
@rust-lang/types I assume the general problem area around type aliases falls under your purview? I wonder what the plans are here for properly Wf-checking type aliases? |
I'm assuming we'll need something like #97974 as a first step, though there may be other implementation avenues we could explore. |
I am going to pick up @eddyb's type-alias PRs, at least the ones that should become hard errors in Rust 2018:
T: ?Sized
in this case)The plan is to issue warnings in Rust 2015 and hard errors in Rust 2018, at least for now. "Too few bounds" unfortunately had too many regressions to make into a hard error without some form of migration. We'll tackle that too, but later.
Adding this issue to help us keep track of this.
Question: Do we feel it's an RC2 blocker?
The text was updated successfully, but these errors were encountered: