_var: Definately unused or maybe_unused

I'm writing some code that accepts a bool parameter, but the parameter is only used when compiling on windows (specifically, it is whether or not the source of a symlink is a directory). It's currently listed as _dir in the parameter to suppress the unused_param warning on unix (which is where my primary development is) and on unsupported platforms which simply panic. However, to me, this communicates that _dir is definately not used by the function, and exists only as a placeholder for the signature. When it may be (and is, when compiling on windows). Is this a wrong interpretation, or should there be something akin to C++'s [[maybe_unused]], which communicates that it is used, but that the use may be excluded by conditional compilation. Alternatively, should rustc not consider parameters unused if they are used inside code excluded by cfg?

You can annotate it with #[allow(unused_param)]

1 Like

I completely forgot about putting lint attributes on the parameter itself.
Though small nitpick, after applying it, apparently that lint does not exist, and simply allow(unused_variables) is correct.
Thank you though.

1 Like