-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix used_underscore_binding
#947
Comments
How? Does a macro check work here? |
We could just have rustc emit |
using an underscored binding is useful in macros to avoid having the "unused variable" default rustc lint fire for the macro case where it's not needed, while still allowing it to be used for the > 0 argument cases. |
rustc uses double underscores for "maybe used idk" bindings in macros, clippy doesn't warn on those |
clippy doesn't warn on used underscore bindings in macros if the binding was declared inside the macro |
I'm currently evaluating if it's possible to insert the hir-lowerings into the expansion-database, so we can treat them just as we treat macros. |
@oli-obk That must be a recent change |
no, you're right, it isn't checked. I wonder why... |
cc @ThibsG this is the lint we were talking about, but I'm not sure at all whether we do now know that the |
I came across this today, which is a valid reason to use an underscore variable IMHO: let _unused = get_option();
debug_assert!(_unused.is_some()); |
In the above case I triggered it with features flag (pseudo-code): pub fn foo(x: usize) -> usize { internal_foo(x, None) }
#[cfg(feature = "cached")]
pub fn foo_cached(x: usize, cache_key: u64) -> usize { internal_foo(x, Some(cache_key)) }
fn internal_foo(x: usize, cache_key: Option<u64>) -> usize { ... } This can probably be avoided if I used |
In #944,
used_underscore_binding
was made allow and to ignore_result
as a ugly hack. This should be fixed.The text was updated successfully, but these errors were encountered: