Commit 0cb4906
authored
Resolve clippy lints (#658)
* Disable type_complexity clippy lint
warning: very complex type used. Consider factoring parts into `type` definitions
--> examples/websocket/src/ws.rs:28:6
|
28 | ) -> Result<
| ______^
29 | | (
30 | | Response<Body>,
31 | | impl Future<Output = Result<WebSocketStream<Upgraded>, hyper::Error>>,
32 | | ),
33 | | (),
34 | | > {
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#type_complexity
= note: `#[warn(clippy::type_complexity)]` on by default
* Resolve needless_as_bytes clippy lint
warning: needless call to `as_bytes`
--> gotham/src/test/mod.rs:532:55
|
532 | assert_eq!(content_length, &format!("{}", data.as_bytes().len()));
| ^^^^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `data.len()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#needless_as_bytes
= note: `#[warn(clippy::needless_as_bytes)]` on by default
* Resolve mismatched_lifetime_syntaxes lint
warning: eliding a lifetime that's named elsewhere is confusing
--> gotham/src/router/tree/mod.rs:59:18
|
57 | &'a self,
| -- the lifetime is named here
58 | req_path_segments: &'a [PercentDecoded],
| -- the lifetime is named here
59 | ) -> Option<(&Node, SegmentMapping<'a>, usize)> {
| ^^^^^ -- the same lifetime is named here
| |
| the same lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
= note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: consistently use `'a`
|
59 | ) -> Option<(&'a Node, SegmentMapping<'a>, usize)> {
| ++
* Resolve io_other_error clippy lint
warning: this can be `std::io::Error::other(_)`
--> gotham/src/lib.rs:101:9
|
101 | io::Error::new(io::ErrorKind::Other, "unable to resolve listener address")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#io_other_error
help: use `std::io::Error::other`
|
101 - io::Error::new(io::ErrorKind::Other, "unable to resolve listener address")
101 + io::Error::other("unable to resolve listener address")
|
warning: this can be `std::io::Error::other(_)`
--> gotham/src/handler/assets/mod.rs:267:57
|
267 | HeaderValue::from_str(&val).map_err(|e| io::Error::new(ErrorKind::Other, e))?,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#io_other_error
= note: `#[warn(clippy::io_other_error)]` on by default
help: use `std::io::Error::other`
|
267 - HeaderValue::from_str(&val).map_err(|e| io::Error::new(ErrorKind::Other, e))?,
267 + HeaderValue::from_str(&val).map_err(|e| io::Error::other(e))?,
|
warning: this can be `std::io::Error::other(_)`
--> gotham/src/middleware/session/mod.rs:1003:25
|
1003 | let e = io::Error::new(
| _________________________^
1004 | | io::ErrorKind::Other,
1005 | | format!("backend failed to return session: {:?}", e),
1006 | | );
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#io_other_error
help: use `std::io::Error::other`
|
1003 ~ let e = io::Error::other(
1004 ~ format!("backend failed to return session: {:?}", e),
|
* Resolve extra_unused_lifetimes clippy lint
warning: this lifetime isn't used in the function definition
--> gotham/src/lib.rs:112:26
|
112 | pub async fn bind_server<'a, NH, F, Wrapped, Wrap>(
| ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#extra_unused_lifetimes
= note: `#[warn(clippy::extra_unused_lifetimes)]` on by default
* Resolve empty_line_after_doc_comments clippy lint
warning: empty line after doc comment
--> gotham/src/router/route/matcher/accept.rs:88:1
|
88 | / /// assert!(matcher.is_match(&state).is_ok());
89 | |
| |_^
...
100 | pub struct AcceptHeaderRouteMatcher {
| ----------------------------------- the comment documents this struct
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#empty_line_after_doc_comments
= note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default
= help: if the empty line is unintentional, remove it
help: if the documentation should include the empty line include it in the comment
|
89 | ///
|
* Disable readonly_write_lock clippy lint
warning: this write lock is used only for reading
--> gotham/src/test/mod.rs:111:23
|
111 | let runtime = self.runtime.write().unwrap();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using a read lock instead: `self.runtime.read()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#readonly_write_lock
= note: `#[warn(clippy::readonly_write_lock)]` on by default
* Resolve unnecessary_get_then_check clippy lint
warning: unnecessary use of `get(&type_id).is_some()`
--> gotham/src/state/mod.rs:221:19
|
221 | self.data.get(&type_id).is_some()
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(&type_id)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_get_then_check
= note: `#[warn(clippy::unnecessary_get_then_check)]` on by default
* Resovle needless_maybe_sized clippy lint
warning: `?Sized` bound is ignored because of a `Sized` requirement
--> gotham/src/router/route/matcher/lookup_table.rs:15:23
|
15 | T: Into<String> + ?Sized,
| ^^^^^^
|
note: `T` cannot be unsized because of the bound
--> gotham/src/router/route/matcher/lookup_table.rs:15:8
|
15 | T: Into<String> + ?Sized,
| ^^^^^^^^^^^^
= note: ...because `Into` has the bound `Sized`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#needless_maybe_sized
= note: `#[warn(clippy::needless_maybe_sized)]` on by default
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
15 - T: Into<String> + ?Sized,
15 + T: Into<String>,
|
* Resolve non_canonical_partial_ord_impl clippy lint
warning: non-canonical implementation of `partial_cmp` on an `Ord` type
--> gotham/src/router/tree/regex.rs:51:1
|
51 | / impl PartialOrd for ConstrainedSegmentRegex {
52 | | fn partial_cmp(&self, other: &ConstrainedSegmentRegex) -> Option<Ordering> {
| | ________________________________________________________________________________-
53 | || Some(self.as_str().cmp(other.as_str()))
54 | || }
| ||_____- help: change this to: `{ Some(self.cmp(other)) }`
55 | | }
| |__^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#non_canonical_partial_ord_impl
= note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default
* Resolve redundant_closure clippy lint
warning: redundant closure
--> gotham/src/handler/assets/mod.rs:267:53
|
267 | HeaderValue::from_str(&val).map_err(|e| io::Error::other(e))?,
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the associated function itself: `io::Error::other`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#redundant_closure
= note: `#[warn(clippy::redundant_closure)]` on by default
* Ignore unused fields of ExtractorError
warning: field `0` is never read
--> gotham/src/extractor/internal.rs:27:26
|
27 | UnexpectedTargetType(&'static str),
| -------------------- ^^^^^^^^^^^^
| |
| field in this variant
|
= note: `ExtractorError` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
27 - UnexpectedTargetType(&'static str),
27 + UnexpectedTargetType(()),
|
warning: field `0` is never read
--> gotham/src/extractor/internal.rs:41:25
|
41 | UnexpectedValueType(&'static str),
| ------------------- ^^^^^^^^^^^^
| |
| field in this variant
|
= note: `ExtractorError` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
41 - UnexpectedValueType(&'static str),
41 + UnexpectedValueType(()),
|
warning: field `0` is never read
--> gotham/src/extractor/internal.rs:62:31
|
62 | UnexpectedEnumVariantType(&'static str),
| ------------------------- ^^^^^^^^^^^^
| |
| field in this variant
|
= note: `ExtractorError` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
62 - UnexpectedEnumVariantType(&'static str),
62 + UnexpectedEnumVariantType(()),
|
warning: field `0` is never read
--> gotham/src/extractor/internal.rs:79:16
|
79 | ParseError(String),
| ---------- ^^^^^^
| |
| field in this variant
|
= note: `ExtractorError` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
79 - ParseError(String),
79 + ParseError(()),
|
warning: field `0` is never read
--> gotham/src/extractor/internal.rs:84:12
|
84 | Custom(String),
| ------ ^^^^^^
| |
| field in this variant
|
= note: `ExtractorError` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
84 - Custom(String),
84 + Custom(()),
|
* Resolve legacy_numeric_constants clippy lint
warning: usage of a legacy numeric constant
--> gotham/src/extractor/internal.rs:769:43
|
769 | assert!((p.f32_val - 1.4).abs() < std::f32::EPSILON);
| ^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#legacy_numeric_constants
= note: `#[warn(clippy::legacy_numeric_constants)]` on by default
help: use the associated constant instead
|
769 - assert!((p.f32_val - 1.4).abs() < std::f32::EPSILON);
769 + assert!((p.f32_val - 1.4).abs() < f32::EPSILON);
|
warning: usage of a legacy numeric constant
--> gotham/src/extractor/internal.rs:770:43
|
770 | assert!((p.f64_val - 2.6).abs() < std::f64::EPSILON);
| ^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#legacy_numeric_constants
help: use the associated constant instead
|
770 - assert!((p.f64_val - 2.6).abs() < std::f64::EPSILON);
770 + assert!((p.f64_val - 2.6).abs() < f64::EPSILON);
|
warning: usage of a legacy numeric constant
--> gotham/src/extractor/internal.rs:848:43
|
848 | assert!((p.f32_val - 1.4).abs() < std::f32::EPSILON);
| ^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#legacy_numeric_constants
help: use the associated constant instead
|
848 - assert!((p.f32_val - 1.4).abs() < std::f32::EPSILON);
848 + assert!((p.f32_val - 1.4).abs() < f32::EPSILON);
|
warning: usage of a legacy numeric constant
--> gotham/src/extractor/internal.rs:849:43
|
849 | assert!((p.f64_val - 2.6).abs() < std::f64::EPSILON);
| ^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#legacy_numeric_constants
help: use the associated constant instead
|
849 - assert!((p.f64_val - 2.6).abs() < std::f64::EPSILON);
849 + assert!((p.f64_val - 2.6).abs() < f64::EPSILON);
|
* Update CI's clippy toolchain from 1.77 to 1.931 parent 79cb135 commit 0cb4906
12 files changed
+27
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
766 | 766 | | |
767 | 767 | | |
768 | 768 | | |
769 | | - | |
770 | | - | |
| 769 | + | |
| 770 | + | |
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
| |||
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
848 | | - | |
849 | | - | |
| 848 | + | |
| 849 | + | |
850 | 850 | | |
851 | 851 | | |
852 | 852 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1000 | 1000 | | |
1001 | 1001 | | |
1002 | 1002 | | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
| 1003 | + | |
1007 | 1004 | | |
1008 | 1005 | | |
1009 | 1006 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
0 commit comments