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.) };
42 // Should lint this because this literal is not bound to any types.
45 // 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`.
56 // Should lint this because this literal is not bound to any types.
59 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
67 // Even though the output type is specified,
68 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
73 // Should lint this because return type is inferred to `f64` and NOT bound to a concrete
75 let f = || -> _ { 1. };
77 // Even though the output type is specified,
78 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
79 let f = || -> f64 { 1. };
84 fn concrete_arg(f: f64) {}
86 fn generic_arg<T>(t: T) {}
89 // Should NOT lint this because the argument type is bound to a concrete type.
92 // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type.
95 // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type.
96 let x: _ = generic_arg(1.);
101 struct ConcreteStruct {
105 struct GenericStruct<T> {
110 // Should NOT lint this because the field type is bound to a concrete type.
111 ConcreteStruct { x: 1. };
113 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
114 GenericStruct { x: 1. };
116 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
117 let _ = GenericStruct { x: 1. };
126 enum GenericEnum<T> {
131 // Should NOT lint this because the field type is bound to a concrete type.
134 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
140 struct StructForMethodCallTest;
142 impl StructForMethodCallTest {
143 fn concrete_arg(&self, f: f64) {}
145 fn generic_arg<T>(&self, t: T) {}
149 let s = StructForMethodCallTest {};
151 // Should NOT lint this because the argument type is bound to a concrete type.
154 // Should lint this because the argument type is bound to a concrete type.
160 macro_rules! internal_macro {
166 // Should lint in internal macro.
171 // Should NOT lint in external macro.
173 default_numeric_fallback!();