Re: [PATCH 1/4] rust: add projection infrastructure
From: Benno Lossin
Date: Sat Feb 21 2026 - 19:58:23 EST
On Sat Feb 14, 2026 at 6:33 AM CET, Gary Guo wrote:
> +#[macro_export]
> +macro_rules! project_pointer {
> + (@gen $ptr:ident, ) => {};
> + // Field projection. `$field` needs to be `tt` to support tuple index like `.0`.
> + (@gen $ptr:ident, .$field:tt $($rest:tt)*) => {
> + // SAFETY: the provided closure always return in bounds pointer.
> + let $ptr = unsafe {
> + $crate::projection::ProjectField::proj($ptr, #[inline(always)] |ptr| {
By the way, how does this avoid `#![feature(stmt_expr_attributes)]`?
Cheers,
Benno
> + // SAFETY: `$field` is in bounds, and no implicit `Deref` is possible (if the
> + // type implements `Deref`, Rust cannot infer the generic parameter `DEREF`).
> + &raw mut (*ptr).$field
> + })
> + };
> + $crate::project_pointer!(@gen $ptr, $($rest)*)
> + };