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

Get rid of is_min_const_fn #84547

Merged
merged 6 commits into from
Apr 26, 2021
Merged

Get rid of is_min_const_fn #84547

merged 6 commits into from
Apr 26, 2021

Conversation

RalfJung
Copy link
Member

This removes the last trace of the min_const_fn mechanism by making the unsafety checker agnostic about whether something is a min or "non-min" const fn. It seems this distinction was used to disallow some features inside const fn, but that is the responsibility of the const checker, not of the unsafety checker. No test seems to even notice this change in the unsafety checker so I guess we are good...

r? @oli-obk
Cc #84510

Rejecting the forbidden unsafe ops is done by const checking, not by unsafety checking
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 25, 2021
@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

Some checks used ::General before (and thus would have lead to an error in min_const_fn):

Those should all be rejected by our regular const checks, right?

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 25, 2021

Those should all be rejected by our regular const checks, right?

Yea, we already have feature gates for them, that is independent

@oli-obk
Copy link
Contributor

oli-obk commented Apr 25, 2021

Can you double check that we still make some things unsafe in const fn that are safe in regular fns? (Like pointer comparisons)

@RalfJung
Copy link
Member Author

(Like pointer comparisons)

I don't think pointer comaprisons were ever unsafe? They should just be forbidden.
Ptr-to-int casts are unsafe. I extended the corresponding test in the last commit.

@RalfJung
Copy link
Member Author

Raw ptr comparison is checked here

self.check_op(ops::RawPtrComparison);

There is no feature gate for RawPtrComparison, it is just always forbidden... is it deliberate that ops are used both for "must never be allowed" and "is currently unstable"?

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 25, 2021

is it deliberate that ops are used both for "must never be allowed" and "is currently unstable"?

Yes, otherwise unleash can't know what checks it can skip

@oli-obk
Copy link
Contributor

oli-obk commented Apr 25, 2021

r=me with ci passing

@RalfJung
Copy link
Member Author

RalfJung commented Apr 25, 2021 via email

@RalfJung
Copy link
Member Author

r=me with ci passing

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Apr 25, 2021

📌 Commit 421d54e has been approved by oli-obk

@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 Apr 25, 2021
@RalfJung
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Apr 25, 2021

📌 Commit 588530d has been approved by oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Apr 25, 2021

I am not sure if unleashing should allow raw ptr comparisons... but yeah makes sense.

We should skip the static check on raw pointer comparisons in unleash mode in order to demonstrate the interpretation time behaviour if there are actual relocations involved

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 25, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#84235 (refactor StyledBuffer)
 - rust-lang#84450 (Give a better error when `std` or `core` are missing)
 - rust-lang#84486 (Handle pretty printing of `else if let` clauses without ICEing)
 - rust-lang#84499 (Tweak trait not `use`d suggestion)
 - rust-lang#84516 (Add suggestion to "use break" when attempting to implicit-break a loop)
 - rust-lang#84520 (Improve diagnostics for function passed when a type was expected.)
 - rust-lang#84541 (Inline most raw socket, fd and handle conversions)
 - rust-lang#84547 (Get rid of is_min_const_fn)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants