1 #![warn(clippy::default_numeric_fallback)]
3 #![allow(clippy::never_loop)]
4 #![allow(clippy::no_effect)]
5 #![allow(clippy::unnecessary_operation)]
9 // Should lint unsuffixed literals typed `i32`.
12 let x = if true { (1, 2) } else { (3, 4) };
18 // Should lint unsuffixed literals typed `f64`.
21 // Should NOT lint suffixed literals.
25 // Should NOT lint literals in init expr if `Local` has a type annotation.
27 let x: [i32; 3] = [1, 2, 3];
28 let x: (i32, i32) = if true { (1, 2) } else { (3, 4) };
36 // Should lint this because this literal is not bound to any types.
39 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
44 // Should lint this because this literal is not bound to any types.
47 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
50 // Should lint this because this literal is not bound to any types.
53 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
61 // Even though the output type is specified,
62 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
67 // Should lint this because return type is inferred to `i32` and NOT bound to a concrete
69 let f = || -> _ { 1 };
71 // Even though the output type is specified,
72 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
73 let f = || -> i32 { 1 };
78 fn concrete_arg(x: i32) {}
80 fn generic_arg<T>(t: T) {}
83 // Should NOT lint this because the argument type is bound to a concrete type.
86 // Should lint this because the argument type is inferred to `i32` and NOT bound to a concrete type.
89 // Should lint this because the argument type is inferred to `i32` and NOT bound to a concrete type.
90 let x: _ = generic_arg(1);
95 struct ConcreteStruct {
99 struct GenericStruct<T> {
104 // Should NOT lint this because the field type is bound to a concrete type.
105 ConcreteStruct { x: 1 };
107 // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type.
108 GenericStruct { x: 1 };
110 // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type.
111 let _ = GenericStruct { x: 1 };
116 struct StructForMethodCallTest {}
118 impl StructForMethodCallTest {
119 fn concrete_arg(&self, x: i32) {}
121 fn generic_arg<T>(&self, t: T) {}
125 let s = StructForMethodCallTest {};
127 // Should NOT lint this because the argument type is bound to a concrete type.
130 // Should lint this because the argument type is bound to a concrete type.