-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
resolve: Fix variant namespacing #30882
Conversation
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
cc me (this might fix a bug I've encountered) |
r? @nrc |
I wonder if it is worth leaving struct variants in the value namespace? I don't suppose we'll ever need it, but it is future-proofing (e.g., if we someday get named arguments for functions, then we could make struct variants generate functions like other variants). |
Should probably decide on the behaviour before we give it a crater run, but it will need one before landing |
Adding struct variants into the value namespace (including cross-crate) will give us the "maximum breakage mode", best suited for evaluation with crater. I'll add a second commit doing this. |
Regarding keeping struct variants in the value namespace in the long term, I'm mildly against it. The pattern
is not especially idiomatic, but it exists and disallowing it would (presumably) break too much code. |
Updated with all variants in both namespaces. |
Also add tests for use of empty structs in cross-crate scenarios Some tests are commented out, they depend on fixes from #30882
@brson could you crater this please? |
@petrochenkov we often have this issue - do we want to be consistent between structs and struct variants or struct variants and other variants? I don't have an opinion in this case, but if we can get away with leaving our options open, I would like that. |
☔ The latest upstream changes (presumably #30896) made this pull request unmergeable. Please resolve the merge conflicts. |
a21f099
to
8058dbb
Compare
Rebased. |
Starting a crater run now |
Looks like there are three regressions (legitimate ones I believe) |
Zero regressions due to future-proofing of struct-variants suggested by @nrc |
Hi, feel free to ping me about the @petrochenkov, you are correct, |
cc @rust-lang/lang I'd be happy to take this and submit PRs to the breaking crates above. What do the rest of the team think? |
note: I do think of this as qualifying as a bug fix |
I'm on board with future-proofing here. |
Thanks to @brson, the bug in rotor-http is fixed now. This case looks more like an oversight rather than a valid use case. And I'm happy that compiler catches it now. |
☔ The latest upstream changes (presumably #31010) made this pull request unmergeable. Please resolve the merge conflicts. |
8058dbb
to
ff6b0aa
Compare
Rebased. |
@bors: r+ (discussed at lang team meeting today) |
📌 Commit ff6b0aa has been approved by |
Tuple and unit variants from other crates weren't put into type namespace. Now variant namespacing is aligned with struct namespacing and is not affected by the variant's crate of origin (struct -> type, tuple/unit -> type/value). Additionally, struct variants from other crates are put into value namespace (struct variants from local crate were already in it). This is not a necessity, but a future proofing measure. This fix can result in some new shadowing errors in cross-crate scenarios, crater reports [three regressions](#30882 (comment)). [breaking-change]
Just ran a crate report against nightly, and I wanted to confirm, but the regression of the |
Yes, this is an expected regression. |
Ok, thanks @petrochenkov! |
I've pushed the new version. |
Tuple and unit variants from other crates weren't put into type namespace.
Now variant namespacing is aligned with struct namespacing and is not affected by the variant's crate of origin (struct -> type, tuple/unit -> type/value).
Additionally, struct variants from other crates are put into value namespace (struct variants from local crate were already in it). This is not a necessity, but a future proofing measure.
This fix can result in some new shadowing errors in cross-crate scenarios, crater reports three regressions.
[breaking-change]