Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings and errors from beta Rust #2904

Merged
merged 4 commits into from
Sep 9, 2024

Conversation

bengsparks
Copy link
Contributor

@bengsparks bengsparks commented Sep 9, 2024

Motivation

The CI cannot pass due to the marking of two new warnings / errors, namely pattern exhaustiveness (by rustc) and long doc comments (by clippy).

Solution

  1. Pattern exhaustiveness
error: unreachable pattern
   --> axum/src/middleware/map_response.rs:281:25
    |
281 |                         Err(err) => match err {}
    |                         ^^^^^^^^ matches no values because `std::convert::Infallible` is uninhabited

Because unreachable pattern is a useful compiler warning, and within all of axum, there are only 4 occurrences, it is simplest to just mark the match arms with #[allow].
Because the examples are separate from the axum lib, it's simplest to just use the same #[allow] in each example's main.rs at a module level.

An alternative would be to add the directive to axum's lib.rs, but that would suppress other instances of this error.
Additionally, there does not seem to be a way to disable more specific instances of unreachable patterns, or to configure this warning's impact from Cargo.toml.

NOTE: It seems that this warning has irked enough people for an exception for empty match arms to be made and nominated for backporting to beta, so hopefully these commits can be reverted soon.

  1. clippy::too-long-first-doc-paragraph
error: first doc comment paragraph is too long
   --> axum/src/extract/ws.rs:785:5
    |
785 | /     /// Indicates that an endpoint is terminating the connection because it has received a type of
786 | |     /// data it cannot accept (e.g., an endpoint that understands only text data MAY send this if
787 | |     /// it receives a binary message).
    | |____^

This lint is likely here to stay, so this requires actual changes, which were made in accordance with the fix recommended by the lint's author(s).

Benjamin Sparks added 3 commits September 9, 2024 16:41
`unreachable_patterns` is otherwise a very helpful warning, so it should
not be disabled crate-wide IMHO
This time the warning is disabled globally due to being isolated in the
example, and not being part of the axum library
The fixes all required slight rewordings and formatting changes, so
these should be checked for accuracy.
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Thanks!

axum/src/extract/ws.rs Outdated Show resolved Hide resolved
@jplatte jplatte enabled auto-merge (squash) September 9, 2024 18:51
@jplatte jplatte merged commit 6efcb75 into tokio-rs:main Sep 9, 2024
18 checks passed
@bengsparks bengsparks deleted the ci/upstream-clippy-lints branch September 9, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants