Skip to content

Raw handle macros for field projection experiments - #164627

Draft
dingxiangfei2009 wants to merge 2 commits into
rust-lang:mainfrom
dingxiangfei2009:raw-handle-macros
Draft

dingxiangfei2009 wants to merge 2 commits into
rust-lang:mainfrom
dingxiangfei2009:raw-handle-macros

Conversation

@dingxiangfei2009

@dingxiangfei2009 dingxiangfei2009 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🐉 Highly experimental field projection primitive raw_handle!

r? @oli-obk

cc @ShaddyDC
cc @ojeda
cc @BennoLossin

We would like to submit this patch to start the experiment with the LocalHandle and PlaceHandle. We intend to continue polishing it in a patch series following this initial patch.

We know that the following items are not working.

  • Closure capture is still hanging in the air, this will be another major work.
  • Library trait wording. Field projection design in general is still shifting landscape, so many pieces as presented here would change. We will continue submitting patches to match the design.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Oct 20, 2026
@rust-log-analyzer

This comment has been minimized.

Comment on lines +1879 to +1881
/// A `raw_handle` expression (e.g. `builtin # raw_handle(expr)`).
RawHandle(Box<Expr>),

@BennoLossin BennoLossin Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(a bit of context for Oli)

we disussed this PR in a meeting yesterday and I suggested we use a more concrete PlaceExpr type in the hir. Ding then argued that it would already make sense to do that in the ast, which I agree with. since that would be a bigger refactor, we figured we would just create the PR and then Ding (or Rasmus) change the ast to already use PlaceExpr in a few days when they find the time.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Yea I think it should def have more precise types here so you can only represent actually legal syntax.

It does mean you'll have to extend the visitors a bit, but it may suffice to just handle it in the walk functions without adding new visitor functions

Co-authored-by: Xiangfei Ding <dingxiangfei2009protonmail.ch>
Signed-off-by: Rasmus Piorr <piorr@google.com>
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-22-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [mir-opt] tests/mir-opt/unusual_item_types.rs ... ok

failures:

---- [mir-opt] tests/mir-opt/issues/issue_163598.rs stdout ----
24         _3 = &((*_1).0: T);
25         StorageLive(_4);
26         _4 = &((*_2).0: T);
-         _0 = <T as PartialOrd>::__chaining_le(move _3, move _4) -> [return: bb1, unwind unreachable];
+         _0 = <T as PartialOrd>::__chaining_le(move _3, move _4) -> [return: bb1, unwind continue];
28     }
29 
30     bb1: {

45         _6 = &((*_1).1: U);
46         StorageLive(_7);
47         _7 = &((*_2).1: U);
-         _0 = <U as PartialOrd>::__chaining_le(move _6, move _7) -> [return: bb4, unwind unreachable];
+         _0 = <U as PartialOrd>::__chaining_le(move _6, move _7) -> [return: bb4, unwind continue];
49     }
50 
51     bb4: {


thread '[mir-opt] tests/mir-opt/issues/issue_163598.rs' panicked at src/tools/compiletest/src/runtest/mir_opt.rs:73:21:
Actual MIR output differs from expected MIR output /checkout/tests/mir-opt/issues/issue_163598.chain_generic.runtime-optimized.after.mir
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- [mir-opt] tests/mir-opt/issues/issue_163598.rs stdout end ----

failures:
    [mir-opt] tests/mir-opt/issues/issue_163598.rs

@rust-bors

rust-bors Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #164673) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants