From e54bdeb95d932bd5f81870f34999de37b615a69d Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 9 Apr 2020 19:22:37 -0700 Subject: [PATCH] Remove use of unreachable in favor of internal errors type: reform pr: https://github.com/casey/intermodal/pull/351 fixes: - https://github.com/casey/intermodal/issues/188 --- CHANGELOG.md | 3 ++- justfile | 7 +++---- src/error.rs | 2 +- src/file_error.rs | 7 ++++++- src/main.rs | 1 - src/subcommand/torrent/piece_length.rs | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33cd865..a1e0bb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ Changelog UNRELEASED - 2020-04-10 ----------------------- -- :books: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Improve badges - _Casey Rodarmor _ +- :art: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Remove use of unreachable in favor of internal errors ([#351](https://github.com/casey/intermodal/pull/351)) - Fixes [#188](https://github.com/casey/intermodal/issues/188) - _Casey Rodarmor _ +- :books: [`52b78b90f675`](https://github.com/casey/intermodal/commit/52b78b90f6751a72a64074619fbf19df2988ac14) Improve badges ([#350](https://github.com/casey/intermodal/pull/350)) - _Casey Rodarmor _ [v0.1.3](https://github.com/casey/intermodal/releases/tag/v0.1.3) - 2020-04-10 diff --git a/justfile b/justfile index f1981c3..97d94ca 100644 --- a/justfile +++ b/justfile @@ -19,7 +19,7 @@ stats PATH: cargo build --release time ./target/release/imdl --unstable torrent stats --input {{PATH}} -push: check +push: ! git branch | grep '* master' git push github @@ -36,7 +36,7 @@ test: cargo test --all clippy: - RUSTFLAGS="-D warnings" cargo clippy --all + cargo clippy --all fmt: cargo +nightly fmt --all @@ -98,7 +98,7 @@ check: test clippy lint check-minimal-versions changelog-update draft: push hub pull-request -o --draft -pr: push +pr: check push hub pull-request -o merge: @@ -110,7 +110,6 @@ merge: just done update: man changelog-update update-toc - cargo update publish-check: check check-man cargo outdated --exit-code 1 diff --git a/src/error.rs b/src/error.rs index ec112d7..f53aa62 100644 --- a/src/error.rs +++ b/src/error.rs @@ -176,7 +176,7 @@ impl From for Error { if let Some(source) = walkdir_error.into_io_error() { Self::Filesystem { source, path } } else { - unreachable!("Encountered unexpected walkdir error") + Self::internal("Encountered walkdir error without source") } } } diff --git a/src/file_error.rs b/src/file_error.rs index 32116fb..0403f97 100644 --- a/src/file_error.rs +++ b/src/file_error.rs @@ -88,7 +88,12 @@ impl Print for FileError { Self::Directory => write!(stream, "Expected file but found directory")?, Self::Surfeit(difference) => write!(stream, "{} too long", difference)?, Self::Dearth(difference) => write!(stream, "{} too short", difference)?, - Self::Md5 { .. } => unreachable!(), + Self::Md5 { .. } => { + return Err(io::Error::new( + io::ErrorKind::Other, + Error::internal("Reached unreachable branch").to_string(), + )) + } } Ok(()) diff --git a/src/main.rs b/src/main.rs index 239c99d..356ac8b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,6 @@ clippy::result_unwrap_used, clippy::shadow_reuse, clippy::too_many_lines, - clippy::unreachable, clippy::unseparated_literal_suffix, clippy::wildcard_enum_match_arm )] diff --git a/src/subcommand/torrent/piece_length.rs b/src/subcommand/torrent/piece_length.rs index e122e6a..073af49 100644 --- a/src/subcommand/torrent/piece_length.rs +++ b/src/subcommand/torrent/piece_length.rs @@ -17,7 +17,7 @@ impl PieceLength { "Content".into(), "Piece Length".into(), "Count".into(), - "Metainfo Size".into(), + "Piece List Size".into(), )); for i in 14..51 {