2 // aux-build:macro_rules.rs
4 #![warn(clippy::default_numeric_fallback)]
9 clippy::unnecessary_operation,
10 clippy::branches_sharing_code,
11 clippy::match_single_binding,
12 clippy::let_unit_value
16 extern crate macro_rules;
20 // Should lint unsuffixed literals typed `f64`.
23 let x = if true { (1., 2.) } else { (3., 4.) };
28 // Should NOT lint suffixed literals.
31 // Should NOT lint literals in init expr if `Local` has a type annotation.
33 let x: [f64; 3] = [1., 2., 3.];
34 let x: (f64, f64) = if true { (1., 2.) } else { (3., 4.) };
43 // Should lint this because this literal is not bound to any types.
46 // 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`.
57 // Should lint this because this literal is not bound to any types.
60 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
65 // Should lint this because this literal is not bound to any types.
68 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
76 // Even though the output type is specified,
77 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
82 // Should lint this because return type is inferred to `f64` and NOT bound to a concrete
84 let f = || -> _ { 1. };
86 // Even though the output type is specified,
87 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
88 let f = || -> f64 { 1. };
93 fn concrete_arg(f: f64) {}
95 fn generic_arg<T>(t: T) {}
98 // Should NOT lint this because the argument type is bound to a concrete type.
101 // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type.
104 // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type.
105 let x: _ = generic_arg(1.);
110 struct ConcreteStruct {
114 struct GenericStruct<T> {
119 // Should NOT lint this because the field type is bound to a concrete type.
120 ConcreteStruct { x: 1. };
122 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
123 GenericStruct { x: 1. };
125 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
126 let _ = GenericStruct { x: 1. };
135 enum GenericEnum<T> {
140 // Should NOT lint this because the field type is bound to a concrete type.
143 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
149 struct StructForMethodCallTest;
151 impl StructForMethodCallTest {
152 fn concrete_arg(&self, f: f64) {}
154 fn generic_arg<T>(&self, t: T) {}
158 let s = StructForMethodCallTest {};
160 // Should NOT lint this because the argument type is bound to a concrete type.
163 // Should lint this because the argument type is bound to a concrete type.
169 macro_rules! internal_macro {
175 // Should lint in internal macro.
180 // Should NOT lint in external macro.
182 default_numeric_fallback!();