2 // aux-build:proc_macros.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,
13 clippy::let_with_type_underscore
16 extern crate proc_macros;
17 use proc_macros::{external, inline_macros};
21 // Should lint unsuffixed literals typed `f64`.
23 let x = [1.0_f64, 2.0_f64, 3.0_f64];
24 let x = if true { (1.0_f64, 2.0_f64) } else { (3.0_f64, 4.0_f64) };
25 let x = match 1.0_f64 {
29 // Should NOT lint suffixed literals.
32 // Should NOT lint literals in init expr if `Local` has a type annotation.
34 let x: [f64; 3] = [1., 2., 3.];
35 let x: (f64, f64) = if true { (1., 2.) } else { (3., 4.) };
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`.
52 // Should lint this because this literal is not bound to any types.
55 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
58 // Should lint this because this literal is not bound to any types.
61 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
66 // Should lint this because this literal is not bound to any types.
69 // Should NOT lint this because this literal is bound to `_` of outer `Local`.
77 // Even though the output type is specified,
78 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
83 // Should lint this because return type is inferred to `f64` and NOT bound to a concrete
85 let f = || -> _ { 1.0_f64 };
87 // Even though the output type is specified,
88 // this unsuffixed literal is linted to reduce heuristics and keep codebase simple.
89 let f = || -> f64 { 1.0_f64 };
94 fn concrete_arg(f: f64) {}
96 fn generic_arg<T>(t: T) {}
99 // Should NOT lint this because the argument type is bound to a concrete type.
102 // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type.
103 generic_arg(1.0_f64);
105 // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type.
106 let x: _ = generic_arg(1.0_f64);
111 struct ConcreteStruct {
115 struct GenericStruct<T> {
120 // Should NOT lint this because the field type is bound to a concrete type.
121 ConcreteStruct { x: 1. };
123 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
124 GenericStruct { x: 1.0_f64 };
126 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
127 let _ = GenericStruct { x: 1.0_f64 };
136 enum GenericEnum<T> {
141 // Should NOT lint this because the field type is bound to a concrete type.
144 // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type.
145 GenericEnum::X(1.0_f64);
150 struct StructForMethodCallTest;
152 impl StructForMethodCallTest {
153 fn concrete_arg(&self, f: f64) {}
155 fn generic_arg<T>(&self, t: T) {}
159 let s = StructForMethodCallTest {};
161 // Should NOT lint this because the argument type is bound to a concrete type.
164 // Should lint this because the argument type is bound to a concrete type.
165 s.generic_arg(1.0_f64);
172 // Should lint in internal macro.
175 inline!(let x = 22.0_f64;);
178 // Should NOT lint in external macro.
180 external!(let x = 22.;);