-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Warn on codegen attributes on required trait methods #148756
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
base: main
Are you sure you want to change the base?
Warn on codegen attributes on required trait methods #148756
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
r? jdonszelmann |
|
@rfcbot fcp merge lang |
|
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
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. |
|
@rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
So, I'd like to file a concern here that we should do a crater run on this before landing. Here's my reasoning: This is landing as a FCW, which means that the team wants to remove this behavior, In my mind, this means that the team should know what the barriers are for that. If, for example, crater says that nobody is relying on it, it may mean that we want to move rather fast on that. If crater shows that a bunch of crates are relying on this, we should know that to be able to plan (I think Niko mentioned e.g. making the change over an edition in that case would be a possibility). Essentially, the concern from me is that a FCW here indicates it's important enough for people to think about, and I think that the lang team should have the data about who it effects. And, not blocking landing this on that data runs the (high) risk of it falling through the cracks. |
|
@rfcbot concern jackh726-concern |
|
@JonathanBrouwer could you make a parallel PR that makes this a full error, then we crater that. Or at least I believe we wouldn't see this warning in a crate run right? |
… r=<try> Crater for #148756
|
Crater run will happen here: #149137 |
|
@rustbot blocked |
|
The crater results are here https://crater-reports.s3.amazonaws.com/pr-149137/index.html
That's more results than I expected, mostly due to one popular crate making this mistake. I'm still convinced we need to add the warning here, since putting a cold attribute on a required trait method currently has no effect and users might expect it to. But this means we might need to be more careful in transitioning this into an error. @nikomatsakis @jackh726 does this address your concern? |
|
I still think we should do this, as it's consistent with other things that we've done previously (like breaking Given that this has never worked and the fix is removing something that doesn't do anything -- and thus has no semver concerns -- I don't have concerns. It would be nice to send PRs to rhai (and any of the others that are "real", at least), of course. @rfcbot reviewed |
|
Great - thank you @JonathanBrouwer for doing that. The results certainly make it clear that we couldn't make this a hard error immediately, but also that it definitely makes sense as a FCW. I do think it'd be pretty quick and easy to make PRs to the affected crates and then switch this to be an error or deny-by-default FCW, but I don't think we typically do that for FCWs. For rhai, it's pretty reasonable given it makes up to large majority of affected cases, I'm happy to send a PR though myself if you aren't able to @JonathanBrouwer. @nikomatsakis will have to resolve the concern for me, but happy from my side here |
|
I'll make a PR for rhai later tonight :) |
|
☔ The latest upstream changes (presumably #149397) made this pull request unmergeable. Please resolve the merge conflicts. |
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
699748b to
c49ff7a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This PR turns applying the following attributes on required trait methods (that is, trait methods without a default implementation) into a FCW:
#[cold]#[link_section]#[linkage](unstable)#[rustc_allow_const_fn_unstable](internal attribute)These attributes already had no effect when applied to a required trait method, this PR only adds a warning.
Furthermore, it adds a comment in the code that the following codegen attributes are inherited when applied to a required trait method:
#[track_caller]#[align](unstable)@rustbot labels +I-lang-nominated
@rust-lang/lang
Two questions for the lang team:
Fixes #147432