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

src: fix clippy warnings #234

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/trace/server_timing/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod test {
use std::time::Duration;

#[test]
#[allow(clippy::redundant_clone)]
Copy link
Member

Choose a reason for hiding this comment

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

why allow instead of resolve? is this more complex than removing the last .clone()?

Copy link
Member Author

@Fishrock123 Fishrock123 Aug 24, 2020

Choose a reason for hiding this comment

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

I found it made it more consistent to read...

Copy link
Contributor

Choose a reason for hiding this comment

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

This one was probably catched by your editor but not by the CI which does not clippy the tests.
Maybe you could consider using clippy --test instead of clippy in the the CI to catch those issues earlier ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh? I run the same command as CI runs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Strange indeed, On my side I only get the redundant closure error when running cargo clippy --tests. Running rust stable 1.45.2 and nightly 1.47.0-nightly (f44c6e4e2 2020-08-24).

Copy link
Contributor

Choose a reason for hiding this comment

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

Forgot to say I am running Windows 10, I will try on Linux tonight

Copy link
Contributor

Choose a reason for hiding this comment

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

Investigating this further I see that cargo clippy --all-targets also activate the --tests flag. This is maybe the command you are running ? When running only cargo clippy -- -D warnings (used by CI) I do not get the errors from #[cfg(test)] guarded code.

Copy link
Member Author

Choose a reason for hiding this comment

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

nightly-x86_64-pc-windows-msvc (overridden by +toolchain on the command line)
rustc 1.47.0-nightly (5180f3da5 2020-08-23)
cargo +nightly clippy --tests --examples -- -D warnings

Huh, turns out that's what Tide runs but not this. Adding a commit...

fn encode() -> crate::Result<()> {
let name = String::from("Server");
let dur = Duration::from_secs(1);
Expand Down
2 changes: 1 addition & 1 deletion src/trace/server_timing/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod test {
fn assert_entry(s: &str, n: &str, du: Option<u64>, de: Option<&str>) -> crate::Result<()> {
let e = parse_entry(s)?;
assert_eq!(e.name(), n);
assert_eq!(e.duration(), du.map(|du| Duration::from_millis(du)));
assert_eq!(e.duration(), du.map(Duration::from_millis));
assert_eq!(e.description(), de);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const SECONDS_IN_HOUR: u64 = 3600;
/// Format using the `Display` trait.
/// Convert timestamp into/from `SytemTime` to use.
/// Supports comparison and sorting.
#[derive(Copy, Clone, Debug, Eq, Ord)]
#[derive(Copy, Clone, Debug, Eq)]
pub(crate) struct HttpDate {
/// 0...59
second: u8,
Expand Down