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

Require stable/unstable annotations for the constness of all stable fns with a const modifier #67136

Merged
merged 9 commits into from
Dec 14, 2019

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Dec 8, 2019

r? @RalfJung @Centril

Every #[stable] const fn now needs either a #[rustc_const_unstable] attribute or a #[rustc_const_stable] attribute. You can't silently stabilize the constness of a function anymore.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 8, 2019
@rust-highfive

This comment has been minimized.

src/librustc/ty/constness.rs Show resolved Hide resolved
src/librustc/ty/constness.rs Outdated Show resolved Hide resolved
src/librustc_feature/builtin_attrs.rs Show resolved Hide resolved
@rust-highfive

This comment has been minimized.

@@ -83,15 +88,36 @@ impl<'tcx> TyCtxt<'tcx> {
}

if self.features().staged_api {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function this is in is called is_min_const_fn, but the body comments make it sounds more like "is the fn required to conform to min_const_fn restrictions", which is not reflected in the function name. Maybe must_be_min_const_fn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well... it's both :D We call is_min_const_fn to check whether a function can be called from other min const fn. When checking a function we call is_min_const_fn to check if we are callable from other min const fn and thus must conform.

// Note: this is an arbitrary choice that does not affect stability or const
// safety or anything, it just changes whether we need to annotate some
// internal functions with `rustc_const_stable` or with `rustc_const_unstable`
true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So internal unannounced functions are more restricted than stable functions with #[rustc_const_unstable]? That seems odd.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see @Centril asked for this. Well I think this is somewhat silly and would prefer to treat functions without staging attributes the same as unstable functions, but I won't fight over this.^^

@RalfJung
Copy link
Member

RalfJung commented Dec 8, 2019

I'm strongly in favor of the general approach! However, I am unfamiliar with how stability checking is implemented, so I'll have to pass on the review.

r? @Centril

@rust-highfive rust-highfive assigned Centril and unassigned RalfJung Dec 8, 2019
@bors

This comment has been minimized.

Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with comments addressed

src/libcore/sync/atomic.rs Outdated Show resolved Hide resolved
src/librustc/ty/constness.rs Outdated Show resolved Hide resolved
find_stability_generic(sess, attrs.iter(), item_sp)
}

fn find_stability_generic<'a, I>(sess: &ParseSess,
attrs_iter: I,
item_sp: Span)
-> Option<Stability>
-> (Option<Stability>, Option<ConstStability>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling this function is doing way too much but let's not overhaul it here; making a note-to-self for now tho. I think the right structure would be to look for each attribute form independently and then do a post-processing step to merge information.

src/libsyntax_expand/base.rs Outdated Show resolved Hide resolved
src/librustc/ty/constness.rs Show resolved Hide resolved
@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 11, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 12, 2019

@bors r=Centril

@bors
Copy link
Contributor

bors commented Dec 12, 2019

📌 Commit 50bc0d2f72babab9d9038274a0ba1e93ebcca85c has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 12, 2019
@bors
Copy link
Contributor

bors commented Dec 12, 2019

⌛ Testing commit 50bc0d2f72babab9d9038274a0ba1e93ebcca85c with merge 49c221ca4e14ea4210101b3be94ee74be1e6b444...

@rust-highfive
Copy link
Collaborator

The job x86_64-apple of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-12T19:47:45.0485160Z [RUSTC-TIMING] build_script_build test:false 0.920
2019-12-12T19:47:52.7953620Z error: `sync::atomic::AtomicI128::new` is not yet stable as a const fn
2019-12-12T19:47:52.7954470Z     --> src/libcore/sync/atomic.rs:1221:48
2019-12-12T19:47:52.7955030Z      |
2019-12-12T19:47:52.7955660Z 1180 | / macro_rules! atomic_int {
2019-12-12T19:47:52.7956260Z 1181 | |     ($cfg_cas:meta,
2019-12-12T19:47:52.7956880Z 1182 | |      $stable:meta,
2019-12-12T19:47:52.7957540Z 1183 | |      $stable_cxchg:meta,
2019-12-12T19:47:52.7958090Z ...    |
2019-12-12T19:47:52.7958730Z 1221 | |         pub const $atomic_init: $atomic_type = $atomic_type::new(0);
2019-12-12T19:47:52.7959980Z ...    |
2019-12-12T19:47:52.7960570Z 1973 | |     }
2019-12-12T19:47:52.7961130Z 1974 | | }
2019-12-12T19:47:52.7961760Z      | |_- in this expansion of `atomic_int!`
2019-12-12T19:47:52.7961760Z      | |_- in this expansion of `atomic_int!`
2019-12-12T19:47:52.7962420Z ...
2019-12-12T19:47:52.7963000Z 2121 | / atomic_int! {
2019-12-12T19:47:52.7964480Z 2122 | |     cfg(target_has_atomic = "128"),
2019-12-12T19:47:52.7965220Z 2123 | |     unstable(feature = "integer_atomics", issue = "32976"),
2019-12-12T19:47:52.7965940Z 2124 | |     unstable(feature = "integer_atomics", issue = "32976"),
2019-12-12T19:47:52.7966510Z ...    |
2019-12-12T19:47:52.7967140Z 2136 | |     i128 AtomicI128 ATOMIC_I128_INIT
2019-12-12T19:47:52.7968370Z      | |_- in this macro invocation
2019-12-12T19:47:52.7968900Z      |
2019-12-12T19:47:52.7969530Z      = help: add `#![feature(const_integer_atomics)]` to the crate attributes to enable
2019-12-12T19:47:52.7969830Z 
2019-12-12T19:47:52.7969830Z 
2019-12-12T19:47:52.8354650Z error: `sync::atomic::AtomicU128::new` is not yet stable as a const fn
2019-12-12T19:47:52.8355400Z     --> src/libcore/sync/atomic.rs:1221:48
2019-12-12T19:47:52.8355950Z      |
2019-12-12T19:47:52.8356570Z 1180 | / macro_rules! atomic_int {
2019-12-12T19:47:52.8357180Z 1181 | |     ($cfg_cas:meta,
2019-12-12T19:47:52.8357810Z 1182 | |      $stable:meta,
2019-12-12T19:47:52.8358460Z 1183 | |      $stable_cxchg:meta,
2019-12-12T19:47:52.8359040Z ...    |
2019-12-12T19:47:52.8359720Z 1221 | |         pub const $atomic_init: $atomic_type = $atomic_type::new(0);
2019-12-12T19:47:52.8360980Z ...    |
2019-12-12T19:47:52.8361560Z 1973 | |     }
2019-12-12T19:47:52.8362170Z 1974 | | }
2019-12-12T19:47:52.8362820Z      | |_- in this expansion of `atomic_int!`
2019-12-12T19:47:52.8362820Z      | |_- in this expansion of `atomic_int!`
2019-12-12T19:47:52.8363340Z ...
2019-12-12T19:47:52.8363950Z 2139 | / atomic_int! {
2019-12-12T19:47:52.8364590Z 2140 | |     cfg(target_has_atomic = "128"),
2019-12-12T19:47:52.8365280Z 2141 | |     unstable(feature = "integer_atomics", issue = "32976"),
2019-12-12T19:47:52.8365960Z 2142 | |     unstable(feature = "integer_atomics", issue = "32976"),
2019-12-12T19:47:52.8366520Z ...    |
2019-12-12T19:47:52.8367160Z 2154 | |     u128 AtomicU128 ATOMIC_U128_INIT
2019-12-12T19:47:52.8368700Z      | |_- in this macro invocation
2019-12-12T19:47:52.8369250Z      |
2019-12-12T19:47:52.8369860Z      = help: add `#![feature(const_integer_atomics)]` to the crate attributes to enable
2019-12-12T19:47:52.8369960Z 
---
2019-12-12T19:49:01.4101010Z   local time: Thu Dec 12 19:49:01 UTC 2019
2019-12-12T19:49:01.4654960Z   network time: Thu, 12 Dec 2019 19:49:01 GMT
2019-12-12T19:49:01.4656250Z == end clock drift check ==
2019-12-12T19:49:01.4702650Z 
2019-12-12T19:49:01.4830100Z ##[error]Bash exited with code '1'.
2019-12-12T19:49:01.4873710Z ##[section]Starting: Checkout
2019-12-12T19:49:01.4876260Z ==============================================================================
2019-12-12T19:49:01.4876370Z Task         : Get sources
2019-12-12T19:49:01.4876450Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Dec 12, 2019

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 12, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 13, 2019

@bors r=Centril

@bors
Copy link
Contributor

bors commented Dec 13, 2019

📌 Commit f12affe has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 13, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 13, 2019

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 13, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 13, 2019

@bors r=Centril

@bors
Copy link
Contributor

bors commented Dec 13, 2019

📌 Commit 0b47ba7 has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 13, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 13, 2019
Require stable/unstable annotations for the constness of all stable fns with a const modifier

r? @RalfJung @Centril

Every `#[stable]` const fn now needs either a `#[rustc_const_unstable]` attribute or a `#[rustc_const_stable]` attribute. You can't silently stabilize the constness of a function anymore.
@bors
Copy link
Contributor

bors commented Dec 14, 2019

⌛ Testing commit 0b47ba7 with merge c8ea4ac...

bors added a commit that referenced this pull request Dec 14, 2019
Require stable/unstable annotations for the constness of all stable fns with a const modifier

r? @RalfJung @Centril

Every `#[stable]` const fn now needs either a `#[rustc_const_unstable]` attribute or a `#[rustc_const_stable]` attribute. You can't silently stabilize the constness of a function anymore.
@bors
Copy link
Contributor

bors commented Dec 14, 2019

☀️ Test successful - checks-azure
Approved by: Centril
Pushing c8ea4ac to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 14, 2019
@bors bors merged commit 0b47ba7 into rust-lang:master Dec 14, 2019
This was referenced Dec 14, 2019
@oli-obk oli-obk deleted the const_stability branch March 16, 2021 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants