#![warn(clippy)]
#![allow(blacklisted_name)]
#![warn(used_underscore_binding)]
macro_rules! test_macro {
() => {{
let _foo = 42;
_foo + 1
}}
}
fn prefix_underscore(_foo: u32) -> u32 {
_foo + 1
}
fn in_macro(_foo: u32) {
println!("{}", _foo);
assert_eq!(_foo, _foo);
test_macro!() + 1;
}
struct StructFieldTest {
_underscore_field: u32,
}
fn in_struct_field() {
let mut s = StructFieldTest { _underscore_field: 0 };
s._underscore_field += 1;
}
fn non_prefix_underscore(some_foo: u32) -> u32 {
some_foo + 1
}
fn unused_underscore_simple(_foo: u32) -> u32 {
1
}
fn unused_underscore_complex(mut _foo: u32) -> u32 {
_foo += 1;
_foo = 2;
1
}
fn multiple_underscores(__foo: u32) -> u32 {
__foo + 1
}
fn _fn_test() {}
struct _StructTest;
enum _EnumTest {
_Empty,
_Value(_StructTest)
}
fn non_variables() {
_fn_test();
let _s = _StructTest;
let _e = match _EnumTest::_Value(_StructTest) {
_EnumTest::_Empty => 0,
_EnumTest::_Value(_st) => 1,
};
let f = _fn_test;
f();
}
fn main() {
let foo = 0u32;
let _ = prefix_underscore(foo);
in_macro(foo);
in_struct_field();
let _ = non_prefix_underscore(foo);
let _ = unused_underscore_simple(foo);
let _ = unused_underscore_complex(foo);
let _ = multiple_underscores(foo);
non_variables();
}