-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Stabilize raw ref macros #80886
Stabilize raw ref macros #80886
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
7454ba7
to
6854bf5
Compare
This comment has been minimized.
This comment has been minimized.
|
6854bf5
to
215f96e
Compare
@mark-i-m I don't think "raw references" are a term I've ever seen. |
I like the new names in this PR better; although using addr is slightly suboptimal (pointers are not (just) addresses yadda yadda), but besides that pedantic nit I think "addr of" conveys the meaning of C's Also, tiny nit: could |
Maybe a misunderstand from the feature name: |
Sure, done. |
Should there be a UI test for this? |
The error comes from the underlying |
Yeah I think "raw pointers" is the usual term, sometimes just "pointers". The macros are in the But |
unsafe // Safety: keep it cool :)
fn bikeshed (x: *mut SomeStruct)
{
use ::core::ptr;
ptr::raw_const!((*x).some_field);
ptr::raw_mut!((*x).some_field);
ptr::const_addr_of!((*x).some_field);
ptr::mut_addr_of!((*x).some_field);
// Personal modification of the `{const,mut}_raw_ptr!` suggestion
ptr::const_ptr_to!((*x).some_field);
ptr::mut_ptr_to!((*x).some_field);
// Another personal suggestion
ptr::raw_ptr!(&raw const (*x).some_field);
ptr::raw_ptr!(&raw mut (*x).some_field);
use ::core::ptr::*;
raw_const!((*x).some_field);
raw_mut!((*x).some_field);
const_addr_of!((*x).some_field);
mut_addr_of!((*x).some_field);
const_ptr_to!((*x).some_field);
mut_ptr_to!((*x).some_field);
raw_ptr!(&raw const (*x).some_field);
raw_ptr!(&raw mut (*x).some_field);
} My personal stance (fwiw)I don't have a strong preference here, except for |
I don't think we want |
@RalfJung We could have it be "generic" though: |
This comment has been minimized.
This comment has been minimized.
d57bc9b
to
3d93784
Compare
Since this is tagged as The names The name Do you have any alternatives for the names in mind? What would you think of something like |
Yeah, I know. This is even worse with
Indeed, we have
Some thoughts:
I feel like all choices are bad here, and I had hoped that the libs team would have some good ideas since they certainly have more experience naming Rust APIs than I do. :) |
We already do that for
Even though const/mut in pointers is mostly meaningless, isn't
How would you pronounce |
I guess it is, but personally on the few occasions that I have been writing raw pointer code, that's not how I thought about this. But maybe I am thinking about this in weird ways.
I'd say "mutable raw pointer", and "const(ant) raw pointer" for |
35e670f
to
13ffa43
Compare
All right, I renamed the macros accordingly. I left the version at 1.51, hoping this will land until the next beta branches on Monday. :D EDIT: Oh, it's Monday the week after the next. No rush then.^^ |
FCP with the old names ( The new names are the result of a meeting which was attended by five libs team members. So, no need for a new FCP, as the names are just a small change. @bors r+ |
📌 Commit 13ffa43 has been approved by |
Rollup of 16 pull requests Successful merges: - rust-lang#79023 (Add `core::stream::Stream`) - rust-lang#80562 (Consider Scalar to be a bool only if its unsigned) - rust-lang#80886 (Stabilize raw ref macros) - rust-lang#80959 (Stabilize `unsigned_abs`) - rust-lang#81291 (Support FRU pattern with `[feature(capture_disjoint_fields)]`) - rust-lang#81409 (Slight simplification of chars().count()) - rust-lang#81468 (cfg(version): treat nightlies as complete) - rust-lang#81473 (Warn write-only fields) - rust-lang#81495 (rustdoc: Remove unnecessary optional) - rust-lang#81499 (Updated Vec::splice documentation) - rust-lang#81501 (update rustfmt to v1.4.34) - rust-lang#81505 (`fn cold_path` doesn't need to be pub) - rust-lang#81512 (Add missing variants in match binding) - rust-lang#81515 (Fix typo in pat.rs) - rust-lang#81519 (Don't print error output from rustup when detecting default build triple) - rust-lang#81520 (Don't clone LLVM submodule when download-ci-llvm is set) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…here `raw_ref_macros` has been stabilized by <rust-lang/rust#80886>.
…=m-ou-se Stabilize core::task::ready! _Tracking issue: https://github.com/rust-lang/rust/issues/70922_ This PR stabilizes the `task::ready!` macro. Similar to rust-lang#80886, this PR was waiting on rust-lang#74355 to be fixed. The `task::ready!` API has existed in the futures ecosystem for several years, and was added on nightly last year in rust-lang#70817. The motivation for this macro is the same as it was back then: virtually every single manual future implementation makes use of this; so much so that it's one of the few things included in the [futures-core](https://docs.rs/futures-core/0.3.12/futures_core) library. r? `@tmandry` cc/ `@rust-lang/wg-async-foundations` `@rust-lang/libs` ## Example ```rust use core::task::{Context, Poll}; use core::future::Future; use core::pin::Pin; async fn get_num() -> usize { 42 } pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> { let mut f = get_num(); let f = unsafe { Pin::new_unchecked(&mut f) }; let num = ready!(f.poll(cx)); // ... use num Poll::Ready(()) } ```
…=m-ou-se Stabilize core::task::ready! _Tracking issue: https://github.com/rust-lang/rust/issues/70922_ This PR stabilizes the `task::ready!` macro. Similar to rust-lang#80886, this PR was waiting on rust-lang#74355 to be fixed. The `task::ready!` API has existed in the futures ecosystem for several years, and was added on nightly last year in rust-lang#70817. The motivation for this macro is the same as it was back then: virtually every single manual future implementation makes use of this; so much so that it's one of the few things included in the [futures-core](https://docs.rs/futures-core/0.3.12/futures_core) library. r? ``@tmandry`` cc/ ``@rust-lang/wg-async-foundations`` ``@rust-lang/libs`` ## Example ```rust use core::task::{Context, Poll}; use core::future::Future; use core::pin::Pin; async fn get_num() -> usize { 42 } pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> { let mut f = get_num(); let f = unsafe { Pin::new_unchecked(&mut f) }; let num = ready!(f.poll(cx)); // ... use num Poll::Ready(()) } ```
This stabilizes
raw_ref_macros
(#73394), which is possible now that #74355 is fixed.However, as I already said in #73394 (comment), I am not particularly happy with the current names of the macros. So I propose we also change them, which means I am proposing to stabilize the following in
core::ptr
:The macro name change means we need another round of FCP. Cc @rust-lang/libs
Fixes #73394