Skip to content
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

Merged
merged 5 commits into from
Sep 6, 2023

Conversation

recatek
Copy link
Contributor

@recatek recatek commented Mar 11, 2023

Let's make it more elegant to conditionally compile trait bounds by allowing cfg-attributes directly in where clauses.

Rendered

@ehuss ehuss added the T-lang Relevant to the language team, which will review and decide on the RFC. label Mar 11, 2023
# 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
Copy link
Contributor

@teor2345 teor2345 Mar 17, 2023

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.

Copy link
Contributor Author

@recatek recatek Mar 17, 2023

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.

Copy link
Contributor

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.

@joshtriplett joshtriplett added the I-lang-nominated Indicates that an issue has been nominated for prioritizing at the next lang team meeting. label Jul 15, 2023
@scottmcm scottmcm removed the I-lang-nominated Indicates that an issue has been nominated for prioritizing at the next lang team meeting. label Jul 18, 2023
@joshtriplett
Copy link
Member

@rfcbot merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jul 18, 2023

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.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. disposition-merge This RFC is in PFCP or FCP with a disposition to merge it. labels Jul 18, 2023
@scottmcm
Copy link
Member

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

@rfcbot rfcbot added final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. and removed proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. labels Aug 15, 2023
@rfcbot
Copy link
Collaborator

rfcbot commented Aug 15, 2023

🔔 This is now entering its final comment period, as per the review above. 🔔

@teor2345
Copy link
Contributor

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.

@scottmcm
Copy link
Member

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.)

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this RFC. and removed final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. labels Aug 25, 2023
@rfcbot
Copy link
Collaborator

rfcbot commented Aug 25, 2023

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.

@pnkfelix pnkfelix merged commit 188cc17 into rust-lang:master Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This RFC is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this RFC. T-lang Relevant to the language team, which will review and decide on the RFC. to-announce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants