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

no longer promote non-pattern const functions #67531

Merged
merged 1 commit into from Jan 4, 2020

Conversation

@RalfJung
Copy link
Member

RalfJung commented Dec 22, 2019

This is trying to pack-pedal a bit on promotion feature creep, as proposed by @eddyb here: possibly, a sane subset of const fn that we could promote are those that are just constructors -- the same subset that we might want to allow in pattern position at some point.

So, this removes the rustc_promotable attribute from the three functions they identified that do not fit this pattern. The first step is to run crater to see if there is code in the wild that relies on this being promotable.

r? @oli-obk

@RalfJung

This comment has been minimized.

Copy link
Member Author

RalfJung commented Dec 22, 2019

@bors try

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 22, 2019

⌛️ Trying commit 368ac73 with merge 662bf71...

bors added a commit that referenced this pull request Dec 22, 2019
WIP: no longer promote non-pattern const functions

This is trying to pack-pedal a bit on promotion feature creep, as proposed by @eddyb [here](rust-lang/const-eval#19 (comment)): possibly, a sane subset of `const fn` that we could promote are those that are just constructors -- the same subset that we might want to allow in pattern position at some point.

So, this removes the `rustc_promotable` attribute from the three functions they identified that do not fit this pattern. The first step is to run crater to see if there is code in the wild that relies on this being promotable.

r? @oli-obk
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 22, 2019

☀️ Try build successful - checks-azure
Build commit: 662bf71 (662bf71cc5bbfe44a109ab5b7205e12ec319754c)

@RalfJung

This comment has been minimized.

Copy link
Member Author

RalfJung commented Dec 22, 2019

@pietroalbini could we get a check-only crater run for this?

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Dec 22, 2019

@craterbot check

(@RalfJung you should be able to do ^-- as well.)

@craterbot

This comment has been minimized.

Copy link
Collaborator

craterbot commented Dec 22, 2019

👌 Experiment pr-67531 created and queued.
🤖 Automatically detected try build 662bf71
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot

This comment has been minimized.

Copy link
Collaborator

craterbot commented Dec 26, 2019

🚧 Experiment pr-67531 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot

This comment has been minimized.

Copy link
Collaborator

craterbot commented Dec 28, 2019

🎉 Experiment pr-67531 is completed!
📊 0 regressed and 0 fixed (81904 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Dec 28, 2019

Noone seems to be using this.

nominating for @rust-lang/libs discussion

This PR breaks hypothetical uses of

let x: &'static Duration = &Duration::from_millis(42);

The above happened because the Duration constructors were one of the very first const fn, created when we didn't know about the unfortunate side effects of permitting const fn calls to get promoted. A detailed explanation of the issues can be found in rust-lang/const-eval#19

The following two snippets will keep working as they would with any user defined const fn. Only the backwards compat hack in libstd will be removed.

let x: &Duration = &Duration::from_millis(42);

and

const X: &Duration = &Duration::from_millis(42);

will keep working as they do now, as promotion inside constants has none of the problematic side effects.

@Centril Centril added the T-lang label Dec 28, 2019
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Dec 28, 2019

Adding the language team as well; I think it would be quite desirable from a language POV to nix the promotability of these non-constructor functions.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 2, 2020

We discussed in the 2020-01-02 @rust-lang/lang team meeting and decided to approve this.

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 2, 2020

📋 Looks like this PR is still in progress, ignoring approval.

Hint: Remove WIP from this PR's title when it is ready for review.

@RalfJung RalfJung changed the title WIP: no longer promote non-pattern const functions no longer promote non-pattern const functions Jan 2, 2020
@RalfJung

This comment has been minimized.

Copy link
Member Author

RalfJung commented Jan 2, 2020

Awesome, thanks :)

@bors r=nikomatsakis

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 2, 2020

📌 Commit 368ac73 has been approved by nikomatsakis

Centril added a commit to Centril/rust that referenced this pull request Jan 3, 2020
…akis

no longer promote non-pattern const functions

This is trying to pack-pedal a bit on promotion feature creep, as proposed by @eddyb [here](rust-lang/const-eval#19 (comment)): possibly, a sane subset of `const fn` that we could promote are those that are just constructors -- the same subset that we might want to allow in pattern position at some point.

So, this removes the `rustc_promotable` attribute from the three functions they identified that do not fit this pattern. The first step is to run crater to see if there is code in the wild that relies on this being promotable.

r? @oli-obk
bors added a commit that referenced this pull request Jan 4, 2020
Rollup of 8 pull requests

Successful merges:

 - #66913 (Suggest calling method when first argument is `self`)
 - #67531 (no longer promote non-pattern const functions)
 - #67770 (More reductions in error handling diversity)
 - #67773 (Add a test for #37333)
 - #67789 (Cleanup linkchecker whitelist)
 - #67810 (Implement uncommon_codepoints lint.)
 - #67835 (tweak wording of mismatched delimiter errors)
 - #67845 (Also remove const-hack for abs)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 4, 2020

⌛️ Testing commit 368ac73 with merge 1eb8aca...

bors added a commit that referenced this pull request Jan 4, 2020
no longer promote non-pattern const functions

This is trying to pack-pedal a bit on promotion feature creep, as proposed by @eddyb [here](rust-lang/const-eval#19 (comment)): possibly, a sane subset of `const fn` that we could promote are those that are just constructors -- the same subset that we might want to allow in pattern position at some point.

So, this removes the `rustc_promotable` attribute from the three functions they identified that do not fit this pattern. The first step is to run crater to see if there is code in the wild that relies on this being promotable.

r? @oli-obk
Centril added a commit to Centril/rust that referenced this pull request Jan 4, 2020
…akis

no longer promote non-pattern const functions

This is trying to pack-pedal a bit on promotion feature creep, as proposed by @eddyb [here](rust-lang/const-eval#19 (comment)): possibly, a sane subset of `const fn` that we could promote are those that are just constructors -- the same subset that we might want to allow in pattern position at some point.

So, this removes the `rustc_promotable` attribute from the three functions they identified that do not fit this pattern. The first step is to run crater to see if there is code in the wild that relies on this being promotable.

r? @oli-obk
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Jan 4, 2020

Rolled up into #67853, @bors retry

bors added a commit that referenced this pull request Jan 4, 2020
Rollup of 8 pull requests

Successful merges:

 - #66913 (Suggest calling method when first argument is `self`)
 - #67531 (no longer promote non-pattern const functions)
 - #67773 (Add a test for #37333)
 - #67786 (Nix reexports from `rustc_span` in `syntax`)
 - #67789 (Cleanup linkchecker whitelist)
 - #67810 (Implement uncommon_codepoints lint.)
 - #67835 (tweak wording of mismatched delimiter errors)
 - #67845 (Also remove const-hack for abs)

Failed merges:

r? @ghost
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 4, 2020

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.

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 added a commit that referenced this pull request Jan 4, 2020
Rollup of 8 pull requests

Successful merges:

 - #66913 (Suggest calling method when first argument is `self`)
 - #67531 (no longer promote non-pattern const functions)
 - #67773 (Add a test for #37333)
 - #67786 (Nix reexports from `rustc_span` in `syntax`)
 - #67789 (Cleanup linkchecker whitelist)
 - #67810 (Implement uncommon_codepoints lint.)
 - #67835 (tweak wording of mismatched delimiter errors)
 - #67845 (Also remove const-hack for abs)

Failed merges:

r? @ghost
@bors bors merged commit 368ac73 into rust-lang:master Jan 4, 2020
4 of 5 checks passed
4 of 5 checks passed
homu Testing commit 368ac73c11662dbb860db178dc170768078b282d with merge 1eb8aca1a6dc799978a3c9f82147de7e9f909748...
Details
pr Build #20191222.51 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@RalfJung RalfJung deleted the RalfJung:tame-promotion branch Jan 8, 2020
@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Jan 16, 2020

I wonder if we could add a check, forcing a very trivial body for #[rustc_promotable] functions.

This might be easy, if entire MIR body looks like _0 = Foo { x: _1, y: _2, ... } (it should be using all of the fn arguments as fields, possibly using constants for some other fields).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.