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

Inherit `#[stable(..)]` annotations in enum variants and fields from its item #71481

Merged
merged 3 commits into from Mar 5, 2021

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Apr 23, 2020

Lint changes for #65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.

@rust-highfive
Copy link
Collaborator

@rust-highfive rust-highfive commented Apr 23, 2020

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

This comment has been hidden.

@estebank estebank force-pushed the estebank:inherit-stability branch from 06a9316 to 8b3c6ee Apr 23, 2020
@rust-highfive

This comment has been hidden.

@estebank
Copy link
Contributor Author

@estebank estebank commented May 7, 2020

CC @rust-lang/compiler who might be interested in this.

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented May 7, 2020

I still don't think this is a good idea.

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented May 7, 2020

Items in trait impls don't currently require stability attributes.
This PR at least should use the same mechanism.

@estebank
Copy link
Contributor Author

@estebank estebank commented May 7, 2020

I still don't think this is a good idea.

Does this refer to this implementation, the general idea of stability stable attributes flowing down in general or the specific case of them flowing down from ADTs to their variants and fields?

From the first diff section in https://github.com/rust-lang/rust/pull/71481/files#diff-6bfe08b41853465a10867dc22a4a548c it seems to me that we originally intended this new behavior to be the correct one.

It's also making me realize that after landing this when we update the used beta in this repo we'll also need to in the same commit update the current usages, as having two different nested stable attributes with the same value in the feature field is denied by this PR (in currently existing code) and would require a more significant change.

Items in trait impls don't currently require stability attributes.
This PR at least should use the same mechanism.

The mechanism used for impls is a visitor boolean field. This PR adds an argument and can be changed to be a field, but I find using fields tracking current state harder to follow, at least when trying things out first. It should be easy to change it to use a field if necessary.

@estebank

This comment has been hidden.

#![feature(staged_api)]
#![stable(feature = "test", since = "0")]

#[stable(feature = "test", since = "0")]
pub struct Reverse<T>(pub T); //~ ERROR field has missing stability attribute
pub struct Reverse<T>(pub T);

This comment has been minimized.

@nagisa

nagisa Jun 6, 2020
Contributor

I feel like this is potentially dangerous change that also limits our options in the future.

I can see an use-case in adding an unstable new field to a struct and not impacting any stable uses of the struct.

Similarly for #[non_exhaustive] enums (the only kind of enum to which it is valid to add a variant), though perhaps significantly more debatable depending on the specific case.

This comment has been minimized.

@estebank

estebank Jun 11, 2020
Author Contributor

I can see an use-case in adding an unstable new field to a struct and not impacting any stable uses of the struct.

I'm not sure I follow. This PR makes the linked code semantically the same as the current

#[stable(feature = "test", since = "0")]
pub struct Reverse<T>(#[stable(feature = "test", since = "0")] pub T);

but you can still add unstable (and stable with different feature name) annotations to individual fields as you add to them. You currently get a compile error with the presented code. I don't see how this change limits us?

This comment has been minimized.

@nikomatsakis

nikomatsakis Jun 12, 2020
Contributor

I guess the point is more that we might accidentally stabilize struct fields without intending to?

This comment has been minimized.

@nagisa

nagisa Jun 12, 2020
Contributor

Yeah, the reason this comment ended up being here is because I’m expressing my observation based on the removed error message, not because the struct is in any way interesting.

@nikomatsakis summarized my point well.

@Dylan-DPC
Copy link
Member

@Dylan-DPC Dylan-DPC commented Jun 30, 2020

@matthewjasper any updates on this?

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Jun 30, 2020

I'm nominating to discuss in a triage meeting and decide next steps here.

@spastorino spastorino added I-nominated and removed I-nominated labels Jul 2, 2020
@spastorino
Copy link
Member

@spastorino spastorino commented Jul 2, 2020

Removed I-nominated by mistake and re-added it again, we didn't have time to discuss this issue during this week triage meeting. So keeping it nominated for the next one.

@spastorino
Copy link
Member

@spastorino spastorino commented Jul 9, 2020

This was discussed in today's weekly meeting. Removing nomination.

@rust-log-analyzer
Copy link
Collaborator

@rust-log-analyzer rust-log-analyzer commented Mar 2, 2021

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

@bors bors commented Mar 3, 2021

Testing commit 49310ce with merge 68b7120...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 3, 2021
…sakis

Inherit `#[stable(..)]` annotations in enum variants and fields from its item

Lint changes for rust-lang#65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
@bors
Copy link
Contributor

@bors bors commented Mar 3, 2021

💥 Test timed out

@rust-log-analyzer
Copy link
Collaborator

@rust-log-analyzer rust-log-analyzer commented Mar 3, 2021

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@estebank
Copy link
Contributor Author

@estebank estebank commented Mar 3, 2021

@bors retry

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 4, 2021
…atsakis

Inherit `#[stable(..)]` annotations in enum variants and fields from its item

Lint changes for rust-lang#65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 4, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#71481 (Inherit `#[stable(..)]` annotations in enum variants and fields from its item)
 - rust-lang#76570 (Implement RFC 2945: "C-unwind" ABI )
 - rust-lang#80527 (Make rustdoc lints a tool lint instead of built-in)
 - rust-lang#80723 (Implement NOOP_METHOD_CALL lint)
 - rust-lang#80763 (resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint)
 - rust-lang#81136 (Improved IO Bytes Size Hint)
 - rust-lang#82304 (Add `-Z unpretty` flags for the AST)
 - rust-lang#82310 (Load rustdoc's JS search index on-demand.)
 - rust-lang#82315 (Improve page load performance in rustdoc)
 - rust-lang#82411 (Fixes to ExitStatus and its docs)
 - rust-lang#82564 (Revert `Vec::spare_capacity_mut` impl to prevent pointers invalidation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

@bors bors commented Mar 4, 2021

Testing commit 49310ce with merge d81b0db...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 4, 2021
…sakis

Inherit `#[stable(..)]` annotations in enum variants and fields from its item

Lint changes for rust-lang#65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
@rust-log-analyzer
Copy link
Collaborator

@rust-log-analyzer rust-log-analyzer commented Mar 4, 2021

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Removing intermediate container befbf413490f
 ---> 0862050eff83
Step 5/10 : RUN npm install es-check -g
 ---> Running in 019c2ce940b3
/node-v14.4.0-linux-x64/bin/es-check -> /node-v14.4.0-linux-x64/lib/node_modules/es-check/index.js

> spawn-sync@1.0.15 postinstall /node-v14.4.0-linux-x64/lib/node_modules/es-check/node_modules/spawn-sync
> node postinstall
+ es-check@5.2.1
added 95 packages from 44 contributors in 3.844s
Removing intermediate container 019c2ce940b3
 ---> 85daf0875536
---
Cloning into 'rust-toolstate'...
<Nothing changed>
+ es-check es5 ../src/librustdoc/html/static/main.js ../src/librustdoc/html/static/settings.js ../src/librustdoc/html/static/source-script.js ../src/librustdoc/html/static/storage.js

Cannot read property 'includes' of undefined
@bors
Copy link
Contributor

@bors bors commented Mar 4, 2021

💔 Test failed - checks-actions

@JohnTitor
Copy link
Member

@JohnTitor JohnTitor commented Mar 4, 2021

Unrelated CI failure, @bors retry

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 5, 2021
…atsakis

Inherit `#[stable(..)]` annotations in enum variants and fields from its item

Lint changes for rust-lang#65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
@bors
Copy link
Contributor

@bors bors commented Mar 5, 2021

Testing commit 49310ce with merge a0d66b5...

@bors
Copy link
Contributor

@bors bors commented Mar 5, 2021

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing a0d66b5 to master...

@bors bors added the merged-by-bors label Mar 5, 2021
@bors bors merged commit a0d66b5 into rust-lang:master Mar 5, 2021
11 checks passed
11 checks passed
PR (mingw-check, ubuntu-latest-xl)
Details
PR (x86_64-gnu-llvm-9, ubuntu-latest-xl)
Details
PR (x86_64-gnu-tools, 1, ubuntu-latest-xl)
Details
auto
Details
try
Details
master
Details
bors build finished
Details
bors build finished
Details
bors build finished
Details
bors build finished
Details
homu Test successful
Details
@rustbot rustbot added this to the 1.52.0 milestone Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet