Skip to content

Revert revert of constness in #86003 - #86295

Merged
bors merged 11 commits into
rust-lang:masterfrom
usbalbin:revert_revert_of_constness
Jun 27, 2021
Merged

Revert revert of constness in #86003#86295
bors merged 11 commits into
rust-lang:masterfrom
usbalbin:revert_revert_of_constness

Conversation

@usbalbin

@usbalbinusbalbin commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

Re-constify mem::swap, mem::replace, ptr::write which were marked as not const in #86003

Once the checks pass, this should solve #86236

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 14, 2021
@rust-log-analyzer

This comment has been minimized.

@usbalbinusbalbin mentioned this pull request Jun 14, 2021
5 tasks
@usbalbin

Copy link
Copy Markdown
ContributorAuthor

Would it make sense to make a tracking issue for const_ptr_write?

Comment threadlibrary/core/src/ptr/mod.rs Outdated
@RalfJung

Copy link
Copy Markdown
Member

@pnkfelix any objections to this? I am not sure why these were de-constified to begin with, so just making sure I am not missing anything here. :)

@rust-log-analyzer

This comment has been minimized.

@usbalbinusbalbin mentioned this pull request Jun 14, 2021
9 tasks
@rust-log-analyzer

This comment has been minimized.

Comment threadlibrary/core/src/ptr/mod.rs Outdated
@RalfJung

Copy link
Copy Markdown
Member

@usbalbin we also lost src/test/ui/consts/copy-intrinsic.rs in #86003; could you add that back as well?

@RalfJung

Copy link
Copy Markdown
Member

LGTM -- r=me, except that it'd be good to hear back from @pnkfelix. Let's give them a few more days.

r? @RalfJung

@rust-log-analyzer

This comment has been minimized.

@usbalbin

Copy link
Copy Markdown
ContributorAuthor

Sorry but I am not quite sure what to do with the errors (or rather lack of errors)

@usbalbin

Copy link
Copy Markdown
ContributorAuthor

Are those things that are no longer checked? Should I remove those tests or somehow make sure the errors are detected again?

@RalfJung

Copy link
Copy Markdown
Member

Something is strange, it looks like none of the errors showed up -- but the exit status is still 1...?

@RalfJung

RalfJung commented Jun 15, 2021

Copy link
Copy Markdown
Member

Ah, I think I know what happens: the errors now have the wrong span; they are shown with spans in the standard library.

To fix this, you should call the intrinsics directly in this test. You will probably need to add a extern "rust-intrinsic" block to import them.

@RalfJung

Copy link
Copy Markdown
Member

So, something like this. But at least on the playground this doesn't change the spans that are shown...

@usbalbin

Copy link
Copy Markdown
ContributorAuthor

Thanks :)

What should I do about

error: module has missing stability attribute
--> src/main.rs:2:1

?
Same error in your playground

@RalfJung

Copy link
Copy Markdown
Member

Ah... well we'll need to add a stability attribute. This should do it:

#![stable(feature = "dummy", since = "1.0.0")]

@usbalbin

Copy link
Copy Markdown
ContributorAuthor

So if you write code which calls unstable code than you have to be explicit about the stabilitiy of your code?

Again thanks :)

Would you like me to squash the two latest commits (2faa57a and d1ae4e2) onto one?

@RalfJung

RalfJung commented Jun 15, 2021

Copy link
Copy Markdown
Member

A chain of things happens here:

  • To call copy_nonoverlapping, it needs to be const fn
  • To make an intrinsic const fn, we need to add rustc_const_unstable
  • To be allowed to use that attribute we need to enable the staged_api feature
  • Once we enable that feature we need to give stability attributes to everything; the easiest thing is to make is all stable so that we don't have to enable feature gates to call our own stuff. (Maybe we don't actually need that, and #![unstable(...)] would also work.

Would you like me to squash the two latest commits (2faa57a and d1ae4e2) onto one?

Seems fine to me to keep this separate.

@usbalbin

Copy link
Copy Markdown
ContributorAuthor

Ah, okay

@usbalbin
usbalbin marked this pull request as ready for review June 15, 2021 19:06
@RalfJung

Copy link
Copy Markdown
Member

@pnkfelix confirmed that as long as we don't touch copy/copy_nonoverlapping, we should be good. So, let's (re-)land this. Thanks @usbalbin :)
@bors r+

@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Jun 27, 2021

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 Jun 27, 2021
@RalfJung

Copy link
Copy Markdown
Member

Looks like #86194 changed the output of some tests added here.

@usbalbin
usbalbinforce-pushed the revert_revert_of_constness branch from d1ae4e2 to c012553CompareJune 27, 2021 11:48
@rust-log-analyzer

This comment has been minimized.

Comment threadsrc/test/ui/const-ptr/out_of_bounds_read.rs
@usbalbin

Copy link
Copy Markdown
ContributorAuthor

@pnkfelix confirmed that as long as we don't touch copy/copy_nonoverlapping, we should be good. So, let's (re-)land this. Thanks @usbalbin :)
@bors r+

Thank you :)

@RalfJung

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Jun 27, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 4aa1267 has been approved by RalfJung

@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 Jun 27, 2021
@bors

bors commented Jun 27, 2021

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 4aa1267 with merge 49ba936...

@bors

bors commented Jun 27, 2021

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 49ba936 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Jun 27, 2021
@bors
bors merged commit 49ba936 into rust-lang:masterJun 27, 2021
@rustbotrustbot added this to the 1.55.0 milestone Jun 27, 2021
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@usbalbin@rust-highfive@rust-log-analyzer@RalfJung@bors@Mark-Simulacrum@rustbot