-
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
Don't allow opaque ty aliases in ADT fields #86928
Don't allow opaque ty aliases in ADT fields #86928
Conversation
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
6084d3c
to
cba8b4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, some minor changes.
LL | struct Bar {a : X} | ||
| ^^^^^^^^^^^^-----^ | ||
| | | ||
| this field contains a type alias impl trait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worthwhile to put the name of the type alias in this message, if the alias is part of some larger nested type then identifying it might be helpful.
e.g. this field contains a type alias impl trait: `X`
So this diagnostic should only be emitted in |
@davidtwco Thanks for the review and sorry for the late update. Previously this didn't allow nested type alias impl trait types to be caught, I added a visitor for this. Also tried to improve the error labels for the nested types. |
@jackh726 Since rejecting impl trait type aliases requires |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I've left some nitpicks regarding the exact error messages that we're adding here.
I wasn't sure if "type alias impl traits are not allowed as field types in enums" is something someone who is new to Rust and have stumbled upon this error when trying things out would understand. If nothing else, I believe we normally refer to "impl traits" as `impl Trait`
in diagnostics, and it would be good if that were consistent. You don't need to accept these exact suggestions if you have better alternatives.
916f69b
to
21548b4
Compare
@davidtwco Fixed. |
@bors r+ |
📌 Commit 21548b4 has been approved by |
@bors r- Hold on, this still isn't correct. We only want to emit this when there is only For example, |
Isn't the functionality in |
Yes. Just check if the |
Ok did this. Can anybody maybe help me with the attributes in the tests, so that the error is not thrown in the
How can I not include I currently use |
@b-naber I think that looks correct. In the |
Doesn't work. I suppose what you want is the field error not to be thrown if only the There doesn't seem to be a way to conditionally include a feature attribute. |
As it currently is, if you want to use In the tests, you either have I'm confused what you're having problems with? |
Yes, that's my point. I don't see how |
So, whether than (just) checking in |
@jackh726 That would make |
I'm really not following. Full tait is a superset of min tait. As such, there are things that will be implemented but not allowed with only min. This is one of those things. In fact, this feature is only allowed when full tait is enabled. There is no extra condition regarding min tait (it being on, stabilized, or off doesn't affect this PR). |
Ok, I think my confusion stems from not knowing the reason why we want to reject these opaque ty aliases in fields in the first place or rather what features of full tait would later make it ok to use them in fields. I was assuming that if we reject them in min tait, we would also have to do that in full tait. I'll update the PR later, don't have time right now. |
Updated. One unexpected thing I encountered is that the following now throws an error in the
|
☔ The latest upstream changes (presumably #87141) made this pull request unmergeable. Please resolve the merge conflicts. |
Oof, I missed that this was updated. Unfortunately, looks like there's been some movement on the TAIT work that essentially means that So...we should probably just close this. Sorry @b-naber! I really appreciate the effort here :/ |
Fixes #86732