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

feature(const_ptr_write) is broken #86236

Closed
AaronKutch opened this issue Jun 12, 2021 · 6 comments
Closed

feature(const_ptr_write) is broken #86236

AaronKutch opened this issue Jun 12, 2021 · 6 comments

Comments

@AaronKutch
Copy link
Contributor

As of a very recent nightly (rustc 1.54.0-nightly (0a8629bff 2021-06-11)), it appears to me that feature(const_ptr_write) is no longer working and broke my code. Sample code:

#![feature(const_ptr_write)]
const unsafe fn ex(x: *mut usize) {
    unsafe {
        x.write(0);
    }
}
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
 --> src/lib.rs:5:9
  |
5 |         x.write(0);
  |         ^^^^^^^^^^

I see a tracking issue for many other pointer operations such as const_ptr_read, but strangely a tracking issue for const_ptr_write is missing.

@ChrisDenton
Copy link
Member

It seems there were problems with it. See #86003.

Looks like this feature was started as an experiment which is why there's no specific tracking issue.

@AaronKutch
Copy link
Contributor Author

This can fortunately be worked around with plain pointer dereferencing and feature(const_raw_ptr_deref), but I prefer ptr::write to make things more explicit

@slightlyoutofphase
Copy link
Contributor

Yeah, this is an extremely annoying reversion that I hope is able to be un-reverted ASAP. So back to how things were a little over a week ago basically. It doesn't even just effect write, but like every single pointer method that was constified recently, basically.

@nagisa
Copy link
Member

nagisa commented Jun 13, 2021

I'm not sure if broken is the right classification here, rather than that it is just gone. Given that this was an unstable functionality, I'm not seeing any benefit in tracking this disappearance.

Closing.

@RalfJung
Copy link
Member

See #86295 for hopefully bringing these functions back.

@RalfJung
Copy link
Member

There's now also a proper tracking issue for this feature: #86302

bors added a commit to rust-lang-ci/rust that referenced this issue Jun 27, 2021
…r=RalfJung

Revert revert of constness in rust-lang#86003

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

Once the checks pass, this should solve rust-lang#86236
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants