Open dtolnay opened 1 week ago
One might expect that this can be worked around by using another cfg
to only include the ..
when it is nonempty:
Struct { a: true, #[cfg(feature = "b")] ..self }
(in the first case)Struct { #[cfg(feature = "a")] a: true, #[cfg(not(feature = "a"))] ..self }
(in the second case)but that is not valid Rust syntax.
Summary
There are cases where a struct expression using functional update syntax is the best way to express what I want, but some of the fields in the struct are conditionally compiled, and under some feature combinations it can be possible that the
..
part of the struct expression contains no fields.Example: some of the method implementations in https://github.com/dtolnay/syn/blob/2.0.70/src/fixup.rs.
Lint Name
needless_update
Reproducer
Struct definition uses conditional compilation:
Struct expression uses conditional compilation:
Version
Additional Labels
No response