diff options
| author | Benno Lossin <benno.lossin@proton.me> | 2024-04-03 22:43:37 +0300 | 
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2024-05-05 19:05:00 +0300 | 
| commit | 9218cf826f1dbacbb857e6eabfae164d8ba05dea (patch) | |
| tree | 907d661b0600f5fa83e91d97daaddb2e13f146f5 /net/unix/af_unix.c | |
| parent | a0a4e17013f68739733028bba89673cdbb9caabd (diff) | |
| download | linux-9218cf826f1dbacbb857e6eabfae164d8ba05dea.tar.xz | |
rust: init: change the generated name of guard variables
The initializers created by the `[try_][pin_]init!` macros utilize the
guard pattern to drop already initialized fields, when initialization
fails mid-way. These guards are generated to have the same name as the
field that they handle. To prevent namespacing issues [1] when the
field name is the same as e.g. a constant name, add `__` as a prefix
and `_guard` as the suffix.
[ Gary says:
   "Here's the simplified example:
    ```
    macro_rules! f {
        () => {
            let a = 1;
            let _: u32 = a;
        }
    }
    const a: u64 = 1;
    fn main() {
        f!();
    }
    ```
    The `a` in `f` have a different hygiene so normally it is scoped to the
    macro expansion and wouldn't escape. Interestingly a constant is still
    preferred despite the hygiene so constants escaped into the macro,
    leading to the error."
  - Miguel ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/rust-for-linux/1e8a2a1f-abbf-44ba-8344-705a9cbb1627@proton.me/ [1]
Link: https://lore.kernel.org/r/20240403194321.88716-1-benno.lossin@proton.me
[ Added Benno's link and Gary's simplified example. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'net/unix/af_unix.c')
0 files changed, 0 insertions, 0 deletions
