Skip to content

Commit

Permalink
Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31
Browse files Browse the repository at this point in the history
Make offset_of field parsing use metavariable which handles any spacing

As discussed at and around comments rust-lang/rust#106655 (comment) and rust-lang/rust#106655 (comment), the current arguments to offset_of do not accept all the whitespace combinations: `0. 1.1.1` and `0.1.1. 1` are currently treated specially in `tests/ui/offset-of/offset-of-tuple-nested.rs`.

They also do not allow [forwarding individual fields as in](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=444cdf0ec02b99e8fd5fd8d8ecb312ca)
```rust
macro_rules! off {
    ($a:expr) => {
        offset_of!(m::S, 0. $a)
    }
}
```

This PR replaces the macro arguments with `($Container:ty, $($fields:expr)+ $(,)?)` which does allow any arrangement of whitespace that I could come up with and the forwarding of fields example above.

This also allows for array indexing in the future, which I think is the last future extension to the syntax suggested in the offset_of RFC.

Tracking issue for offset_of: #106655
``@rustbot`` label F-offset_of

``@est31``
  • Loading branch information
matthiaskrgr authored Jan 4, 2024
2 parents 8612fd4 + e22f10f commit f185ca5
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit f185ca5

Please sign in to comment.