Not using the result of offset_of should lint #111669
Labels
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
F-offset_of
`#![feature(offset_of)]`
The offset_of macro (#106655) is side effect free. For standard library functions that are side effect free, or that have side effects but there is versions of them that don't return anything, it is policy to add a
must_use
attribute to them so that users are warned if they invoke the function without doing anything with the result (#89692).Ideally, the same should hold for the
offset_of
macro as well. One of the lints in theunused
lint group should fire if you don't use the result of theoffset_of!()
macro:Ideally it would be integrated into the
must_use
system, say via supporting#[must_use]
attributes on macros. Currently you are getting:for
It could e.g. expand to some AST node that is just the identity.
Alternatively, one could also just solve it for the offset_of macro via sending the result through a function:
Sadly this pollutes the context with a function however. If one surrounds the entire expansion with
{}
s, the lint is silent again.I don't think it's worth its own lint in itself.
The text was updated successfully, but these errors were encountered: