1 #![warn(clippy::default_numeric_fallback)]
3 #![allow(clippy::never_loop)]
4 #![allow(clippy::no_effect)]
5 #![allow(clippy::unnecessary_operation)]
6 #![allow(clippy::branches_sharing_code)]
10 // Should lint unsuffixed literals typed `i32`.
13 let x = if true { (1, 2) } else { (3, 4) };
19 // Should lint unsuffixed literals typed `f64`.
22 // Should NOT lint suffixed literals.
26 // Should NOT lint literals in init expr if `Local` has a type annotation.
28 let x: [i32; 3] = [1, 2, 3];
29 let x: (i32, i32) = if true { (1, 2) } else { (3, 4) };
37 // Should lint this because this literal is not bound to any types.
40 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
45 // Should lint this because this literal is not bound to any types.
48 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
51 // Should lint this because this literal is not bound to any types.
54 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
62 // Even though the output type is specified,
63 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
68 // Should lint this because return type is inferred to `i32` and NOT bound to a concrete
70 let f = || -> _ { 1 };
72 // Even though the output type is specified,
73 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
74 let f = || -> i32 { 1 };
79 fn concrete_arg(x: i32) {}
81 fn generic_arg<T>(t: T) {}
84 // Should NOT lint this because the argument type is bound to a concrete type.
87 // Should lint this because the argument type is inferred to `i32` and NOT bound to a concrete type.
90 // Should lint this because the argument type is inferred to `i32` and NOT bound to a concrete type.
91 let x: _ = generic_arg(1);
96 struct ConcreteStruct {
100 struct GenericStruct<T> {
105 // Should NOT lint this because the field type is bound to a concrete type.
106 ConcreteStruct { x: 1 };
108 // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type.
109 GenericStruct { x: 1 };
111 // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type.
112 let _ = GenericStruct { x: 1 };
117 struct StructForMethodCallTest {}
119 impl StructForMethodCallTest {
120 fn concrete_arg(&self, x: i32) {}
122 fn generic_arg<T>(&self, t: T) {}
126 let s = StructForMethodCallTest {};
128 // Should NOT lint this because the argument type is bound to a concrete type.
131 // Should lint this because the argument type is bound to a concrete type.