Skip to content

Resolve clippy lints#658

Merged
msrd0 merged 14 commits intogotham-rs:mainfrom
dtolnay-contrib:clippy
Mar 2, 2026
Merged

Resolve clippy lints#658
msrd0 merged 14 commits intogotham-rs:mainfrom
dtolnay-contrib:clippy

Conversation

@dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Mar 2, 2026

I noticed that there are several pre-existing failures in the clippy CI job on #657. This cleans them up.

dtolnay added 14 commits March 1, 2026 21:00
    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
    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
    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)> {
       |                   ++
    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),
         |
    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
    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 | ///
        |
    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
    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
    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>,
       |
    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
    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
    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(()),
       |
    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);
        |
Copy link
Member

@msrd0 msrd0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@msrd0 msrd0 merged commit 0cb4906 into gotham-rs:main Mar 2, 2026
9 checks passed
@msrd0 msrd0 mentioned this pull request Mar 2, 2026
@msrd0 msrd0 added this to the 0.8.0 milestone Mar 2, 2026
@dtolnay dtolnay deleted the clippy branch March 2, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants