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 errors due to "unused code" when features are disabled #368

Merged
merged 6 commits into from
Apr 27, 2024

Conversation

palant
Copy link
Contributor

@palant palant commented Apr 25, 2024

Description

Unfortunately, my previous changes caused some compile errors when compiling with --no-default-features. That’s mostly due to unused code, one error is because of a variable being unnecessarily mutable.

Related Issue

#340, #342

How Has This Been Tested?

Tests pass.

Copy link

semanticdiff-com bot commented Apr 25, 2024

Review changes with SemanticDiff.

Analyzed 2 of 2 files.

Overall, the semantic diff is 10% smaller than the GitHub diff.

Filename Status
✔️ src/handler.rs 11.45% smaller
✔️ src/lib.rs Analyzed

@joseluisq joseluisq added v2 v2 release bugfix This is PR fixes a bug codebase Related to the project's source code labels Apr 25, 2024
src/handler.rs Outdated Show resolved Hide resolved
src/handler.rs Outdated Show resolved Hide resolved
src/handler.rs Outdated Show resolved Hide resolved
@palant
Copy link
Contributor Author

palant commented Apr 27, 2024

Because for stable compiles just fine.

As I said, this isn’t about compiling but about clippy. Using latest stable (1.77.2) I get when running cargo clippy --no-default-features:

error: used `unwrap_or()` on `None` value
   --> src/handler.rs:296:32
    |
296 |                       let resp = resp.unwrap_or(
    |  ________________________________^
297 | |                         // Otherwise return an error response
298 | |                         error_page::error_response(
299 | |                             req.uri(),
...   |
304 | |                         )?,
305 | |                     );
    | |_____________________^
    |
help: remove the `None` and `unwrap_or()`
   --> src/handler.rs:283:32
    |
283 |                     let resp = None;
    |                                ^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
note: the lint level is defined here
   --> src/lib.rs:99:9
    |
99  | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(clippy::unnecessary_literal_unwrap)]` implied by `#[deny(warnings)]`

@palant
Copy link
Contributor Author

palant commented Apr 27, 2024

Whatever, I’ve rearranged this code so that we don’t have any warnings here. The optimizer can figure it out.

@palant palant requested a review from joseluisq April 27, 2024 11:54
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

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

Thanks!

@joseluisq joseluisq merged commit c8e39aa into static-web-server:master Apr 27, 2024
34 checks passed
@palant palant deleted the fix-unused-code branch April 27, 2024 15:34
@joseluisq joseluisq added this to the v2.30.0 milestone Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This is PR fixes a bug codebase Related to the project's source code v2 v2 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants