-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow cfg-attributes in where clauses #3399
Conversation
text/3399-cfg-attribute-in-where.md
Outdated
# Unresolved questions | ||
[unresolved-questions]: #unresolved-questions | ||
|
||
In theory, I don't see any harm in cfg-attributes decorating individual bounds on the right hand side of the colon. Is it worth adding that |
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 could help in scenarios where the right-hand side is complex, for example:
T: Iterator<Item = (U #[cfg(send_bounds)] + Send)>
But in that case I think a conditionally-compiled type alias is the way to go. (As you can see, the syntax is already a bit weird.)
This is already what many crates do, for example, type aliases like BoxError
.
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.
That's fair. I don't have a strong opinion on that either way. What I think this would already enable locally is:
where
T: Iterator<Item = U>,
#[cfg(send_bounds)]
<T as Iterator>::Item: Send,
which IMO would be enough of an ergonomics improvement on its own without needing further complication.
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.
Yes, that seems much clearer.
If users try to add a where bound on the right, the compiler might want to suggest adding it on the left using a fully qualified path instead. But I'm not sure how easy it is to detect those scenarios.
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
TBH I much prefer when we can put attributes on grouped constructs so it's clear where they end, but the parallel to existing behaviour in the generic declaration list convinced me that this is consistent enough with existing practice to just do it. And doing it at that list level makes me feel way better than doing it in the RHS, since the RHS can just be split up if it really needs to be cfg'd separately. @rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Oh, I just noticed that this RFC is already in its final comment period, and my suggestions are minor wording changes. So feel free to ignore them. |
So long as the approach doesn't change, updates to the RFC are fine until it's merged. (New FAQ entries in the rationale or wording fixes are certainly welcome.) And the FCP exists to get concerns from the community, so if you have concerns, do raise them! (You can also put things in the tracking issue later if needed. This FCP is for the RFC, but there will be another before stabilization.) |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Co-authored-by: teor <[email protected]> Co-authored-by: Mario Carneiro <[email protected]>
Let's make it more elegant to conditionally compile trait bounds by allowing cfg-attributes directly in where clauses.
Rendered