Skip to content

make ConstEvaluatable more strict - #74595

Merged
bors merged 7 commits into
rust-lang:masterfrom
lcnr:ConstEvaluatable-fut-compat
Sep 9, 2020
Merged

make ConstEvaluatable more strict#74595
bors merged 7 commits into
rust-lang:masterfrom
lcnr:ConstEvaluatable-fut-compat

Conversation

@lcnr

@lcnrlcnr commented Jul 21, 2020

Copy link
Copy Markdown
Contributor

relevant zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60ConstEvaluatable.60.20generic.20functions/near/204125452

Let's see how much this impacts. Depending on how this goes this should probably be a future compat warning.

Short explanation: we currently forbid anonymous constants which depend on generic types, e.g. [0; std::mem::size_of::<T>] currently errors.

We previously checked this by evaluating the constant and returned an error if that failed. This however allows things like

constfnfoo<T>() -> usize{if std::mem::size_of::<*mutT>() < 8{// size of *mut T does not depend on T
std::mem::size_of::<T>()}else{8}}fntest<T>(){let _ = [0;foo::<T>()];}

which is a backwards compatibility hazard. This also has worrying interactions with mir optimizations (#74491 (comment)) and intrinsics (#74538).

r? @oli-obk@eddyb

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 21, 2020
@lcnr

lcnr commented Jul 21, 2020

Copy link
Copy Markdown
ContributorAuthor

@bors try

@bors

bors commented Jul 21, 2020

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 617f7ad0b02ca21994b4cf28d14634486163b166 with merge 536076e3df53cc305e0c3c5f38bdc73f6d9f08bb...

Comment threadsrc/librustc_middle/mir/mod.rs Outdated
@bors

bors commented Jul 21, 2020

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions, checks-azure
Build commit: 536076e3df53cc305e0c3c5f38bdc73f6d9f08bb (536076e3df53cc305e0c3c5f38bdc73f6d9f08bb)

@lcnr

lcnr commented Jul 21, 2020

Copy link
Copy Markdown
ContributorAuthor

It looks like the crater queue is fairly full. @Mark-Simulacrum do we currently have the capacity to do another check run?

I also did some small changes here, so once again @bors try

@bors

bors commented Jul 21, 2020

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 65395c0710061f8745bdfab3520256a178e92c9d with merge a5913924b14838b364c42230cae014cc2534331d...

@bors

bors commented Jul 21, 2020

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions, checks-azure
Build commit: a5913924b14838b364c42230cae014cc2534331d (a5913924b14838b364c42230cae014cc2534331d)

@lcnr

lcnr commented Jul 22, 2020

Copy link
Copy Markdown
ContributorAuthor

Well, will go ahead and add this PR into the crate queue. If we don't have the capacity for this we can just remove it again.

@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-74595 created and queued.
🤖 Automatically detected try build a5913924b14838b364c42230cae014cc2534331d
🔍 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

@craterbotcraterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2020
@withoutboatswithoutboats added I-nominated T-lang Relevant to the language team labels Jul 23, 2020
@craterbot

Copy link
Copy Markdown
Collaborator

🚧 Experiment pr-74595 is now running

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

@craterbot

Copy link
Copy Markdown
Collaborator

🚨 Experiment pr-74595 has encountered an error: command Command { std: "/workspace/cargo-home/bin/rustup-toolchain-install-master" "8ad7bc3f428300aee6764f6e23527e19eb235e81" "-c" "cargo", kill_on_drop: false } failed
🛠️ If the error is fixed use the retry command.

🆘 Can someone from the infra team check in on this? @rust-lang/infra
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@craterbot retry seems to have been spurious

@craterbot

Copy link
Copy Markdown
Collaborator

🚨 Error: failed to parse the command

🆘 If you have any trouble with Crater please ping @rust-lang/infra!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@lcnr

lcnr commented Jul 28, 2020

Copy link
Copy Markdown
ContributorAuthor

@craterbot retry

@craterbot

Copy link
Copy Markdown
Collaborator

🛠️ Experiment pr-74595 queued again.

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

@lcnrlcnr mentioned this pull request Jul 28, 2020
8 tasks
@lcnr

lcnr commented Jul 31, 2020

Copy link
Copy Markdown
ContributorAuthor

This behavior was introduced in #70452 which was merged on the 15.04.2020, meaning that this has been only stable for 2 stable versions. (since 1.43.0)

So hopefully there aren't many uses of this yet

@craterbot

Copy link
Copy Markdown
Collaborator

🚧 Experiment pr-74595 is now running

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

@craterbot

Copy link
Copy Markdown
Collaborator

🚨 Experiment pr-74595 has encountered an error: command Command { std: "/workspace/cargo-home/bin/rustup-toolchain-install-master" "8ad7bc3f428300aee6764f6e23527e19eb235e81" "-c" "cargo", kill_on_drop: false } failed
🛠️ If the error is fixed use the retry command.

🆘 Can someone from the infra team check in on this? @rust-lang/infra
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@craterbot retry

@craterbot

Copy link
Copy Markdown
Collaborator

🛠️ Experiment pr-74595 queued again.

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

@craterbot

Copy link
Copy Markdown
Collaborator

🚧 Experiment pr-74595 is now running

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

@lcnr
lcnrforce-pushed the ConstEvaluatable-fut-compat branch from 1a1c3dc to 1dd00e6CompareSeptember 8, 2020 14:44
@lcnr

lcnr commented Sep 8, 2020

Copy link
Copy Markdown
ContributorAuthor

I wasn't able to reproduce this locally, but added a #[warn(const_evaluatable_unchecked)] anyways.

@oli-obk

Copy link
Copy Markdown
Contributor

r=me with CI passing

@lcnr

lcnr commented Sep 8, 2020

Copy link
Copy Markdown
ContributorAuthor

@bors r=oli-obk

@bors

bors commented Sep 8, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 4226a17 has been approved by oli-obk

@borsbors 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 Sep 8, 2020
@Aaron1011

Copy link
Copy Markdown
Contributor

@bors retry

@bors

bors commented Sep 8, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 4226a17 with merge 8d92815944e001c9703489b285f04a9eb6567699...

@bors

bors commented Sep 8, 2020

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-actions

@borsbors 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 Sep 8, 2020
@lcnr

lcnr commented Sep 9, 2020

Copy link
Copy Markdown
ContributorAuthor

How can I reproduce this locally? I don't understand this error

@oli-obk

Copy link
Copy Markdown
Contributor

The only thing I can come up with that could cause this difference is --target=i586-unknown-linux-gnu. You may be able to do a --pass=check test run of that specific test and check why it does this. I'm fine with just ignoring the test on that platform once we know why it's happening

@lcnr

lcnr commented Sep 9, 2020

Copy link
Copy Markdown
ContributorAuthor

@bors r=oli-obk

@bors

bors commented Sep 9, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 74e0719 has been approved by oli-obk

@borsbors 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 Sep 9, 2020
@bors

bors commented Sep 9, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 74e0719 with merge e2be5f5...

@bors

bors commented Sep 9, 2020

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions, checks-azure
Approved by: oli-obk
Pushing e2be5f5 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Sep 9, 2020
@bors
bors merged commit e2be5f5 into rust-lang:masterSep 9, 2020
@rustbotrustbot added this to the 1.48.0 milestone Sep 9, 2020
@lcnr
lcnr deleted the ConstEvaluatable-fut-compat branch September 10, 2020 05:46
@Mark-Simulacrum

Copy link
Copy Markdown
Member

This was an improvement of up to 2% on wf-projection-stress. Presumably not an expected result?

@lcnr

lcnr commented Sep 16, 2020

Copy link
Copy Markdown
ContributorAuthor

We were afraid of causing a regression here and had similar results 🤔 Probably some inlining changes or something

but not really expected

edit: https://perf.rust-lang.org/compare.html?start=3cfc7fe78eccc754b16981704a098d7bd520e2fd&end=2ce316b2752e1543bc064357871d77fd4896ca27

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-langRelevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@lcnr@bors@craterbot@Mark-Simulacrum@rust-timer@oli-obk@LeSeulArtichaut@nikomatsakis@Aaron1011@rust-highfive@withoutboats@rustbot