-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
add raw_ref macros #72279
add raw_ref macros #72279
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This was discussed again in the @rust-lang/lang team meeting, and the general consensus in #64490 (comment) has not changed. The question of whether some form of rust-lang/rfcs#2919 before stabilizing these macros was briefly discussed but not conclusively answered. AFAIK, all this needs is sign-off from T-libs on the precise syntax and the implementation. |
@rfcbot fcp merge ProposalIntroduce two macros
which borrow the contents at Motivation for exposing these capabilitiesUnlike the Motivation for using macro-based syntaxThis is an alternative to the previous syntax specified in RFC 2582, which was The motivations for making this change is that the syntax
Further, we think that there may be an opportunity to revisit raw-pointer ergonomics in a bigger way that could improve the language overall (some background available in these three messages, particularly the final one). We don't feel ready to decide if that opportunity is worth the resulting churn, but we don't feel the need to commit to syntax like Future possibilitiesThe On the other hand, if we wind up deciding that larger "raw pointer reform" doesn't make sense, we might add some more "builtin" syntax than the |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
r? @cramertj |
Nominating for next lang-team meeting to draw attention these checkboxes. |
4648: Support raw_ref_op's raw reference operator r=matklad a=robojumper Fixes #4642. This syntax (and its semantics) are implemented in rustc behind the `raw_ref_op` feature. It is not entirely clear whether this is the syntax that will become stable, but [it seems like](rust-lang/rust#72279) rust-analyzer must still support this unstable syntax to support future stable rust. Also fixes a random inference failure involving a direct coercion from `&[T, _]` to `*const [T]`. Co-authored-by: robojumper <robojumper@gmail.com>
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot reviewed Definitely no concerns with this as unstable. |
Due to the const provenance issues @Gankra mentioned in #64490 (comment), I would think that we'd want people to prefer using Perhaps |
The usual Rust naming convention would be Another alternative would be |
I can change the name to anything as long as there's consensus. :) Don't really care myself. |
maybe even raw_const_ptr / raw_mut_ptr. These are exposed from the root of std, right? |
Yes, but I can also make them "macro 2.0" macros and put them into some module -- I was not sure if that is already acceptable to do. |
I don't have a strong opinion about the names we use, and I would love @rust-lang/libs feedback on the best way to expose them. I think something like |
I'd definitely prefer to have them be located in |
I think having them available only at the paths |
@bors r+ |
📌 Commit 0265e4e has been approved by |
…akis add raw_ref macros In rust-lang#64490, various people were in favor of exposing `&raw` as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros. I'll create the tracking issue if we're okay moving forward with this.
…akis add raw_ref macros In rust-lang#64490, various people were in favor of exposing `&raw` as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros. I'll create the tracking issue if we're okay moving forward with this.
…akis add raw_ref macros In rust-lang#64490, various people were in favor of exposing `&raw` as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros. I'll create the tracking issue if we're okay moving forward with this.
…akis add raw_ref macros In rust-lang#64490, various people were in favor of exposing `&raw` as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros. I'll create the tracking issue if we're okay moving forward with this.
…akis add raw_ref macros In rust-lang#64490, various people were in favor of exposing `&raw` as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros. I'll create the tracking issue if we're okay moving forward with this.
…akis add raw_ref macros In rust-lang#64490, various people were in favor of exposing `&raw` as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros. I'll create the tracking issue if we're okay moving forward with this.
…arth Rollup of 17 pull requests Successful merges: - rust-lang#70551 (Make all uses of ty::Error delay a span bug) - rust-lang#71338 (Expand "recursive opaque type" diagnostic) - rust-lang#71976 (Improve diagnostics for `let x += 1`) - rust-lang#72279 (add raw_ref macros) - rust-lang#72628 (Add tests for 'impl Default for [T; N]') - rust-lang#72804 (Further tweak lifetime errors involving `dyn Trait` and `impl Trait` in return position) - rust-lang#72814 (remove visit_terminator_kind from MIR visitor) - rust-lang#72836 (Complete the std::time documentation to warn about the inconsistencies between OS) - rust-lang#72968 (Only highlight doc search results via mouseover if mouse has moved) - rust-lang#73034 (Export `#[inline]` fns with extern indicators) - rust-lang#73315 (Clean up some weird command strings) - rust-lang#73320 (Make new type param suggestion more targetted) - rust-lang#73361 (Tweak "non-primitive cast" error) - rust-lang#73425 (Mention functions pointers in the documentation) - rust-lang#73428 (Fix typo in librustc_ast docs) - rust-lang#73447 (Improve document for `Result::as_deref(_mut)` methods) - rust-lang#73476 (Added tooltip for should_panic code examples) Failed merges: r? @ghost
Since Rust 1.51.0, support for macro addr_of!() has been stabilized[1], and this provides a way to get a raw pointer without potential UB in some cases. Memoffset alreadly uses the feature at the pre-stablilized stage (the macro was named as raw_const then). Therefore, switch to use the stablilized version (and name) and remove the out-dated version, also remove the related feature gate. [1]: rust-lang/rust#72279 Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Since Rust 1.51.0, support for macro addr_of! has been stabilized[1], and this provides a way to get a raw pointer without potential UB in some cases. Memoffset alreadly uses the feature at the pre-stablilized stage (the macro was named as raw_const! then). Therefore, switch to use the stablilized version (and name) if Rust 1.51.0 and above is used, otherwise use the original fallback version, which works in a less technically correct way. [1]: rust-lang/rust#72279 Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Since Rust 1.51.0, support for macro addr_of! has been stabilized[1], and this provides a way to get a raw pointer without potential UB in some cases. Memoffset alreadly uses the feature at the pre-stablilized stage (the macro was named as raw_const! then). Therefore, switch to use the stablilized version (and name) if Rust 1.51.0 and above is used, otherwise use the original fallback version, which works in a less technically correct way. [1]: rust-lang/rust#72279 Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Since Rust 1.51.0, support for macro addr_of! has been stabilized[1], and this provides a way to get a raw pointer without potential UB in some cases. Memoffset alreadly uses the feature at the pre-stablilized stage (the macro was named as raw_const! then). Therefore, switch to use the stablilized version (and name) if Rust 1.51.0 and above is used, otherwise use the original fallback version, which works in a less technically correct way. [1]: rust-lang/rust#72279 Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
In #64490, various people were in favor of exposing
&raw
as a macro first before making the actual syntax stable. So this PR (unstably) introduces those macros.I'll create the tracking issue if we're okay moving forward with this.