Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilgardis committed Mar 24, 2023
1 parent 2f6d9b3 commit 6166fa5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
3 changes: 1 addition & 2 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
disallowed-methods = [
{ path = "std::path::Path::display", reason = "incorrect handling of non-Unicode paths, use path.to_utf8() or debug (`{path:?}`) instead" },
]
# needs clippy 1.61
# allow-unwrap-in-tests = true
allow-unwrap-in-tests = true
5 changes: 4 additions & 1 deletion src/docker/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
if msg_info.cross_debug
&& src.is_dir()
&& !src.to_string_lossy().ends_with("/.")
&& rel == src.file_name().unwrap()
&& rel
== src
.file_name()
.expect("filename should be defined as we are a directory")
{
msg_info.warn(format_args!(
"source is pointing to a directory instead of its contents: {} -> {}\nThis might be a bug. {}",
Expand Down
9 changes: 7 additions & 2 deletions src/docker/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,10 @@ impl ChildContainer {
// relax the no-timeout and lack of output
// ensure we have atomic ordering
if self.exists() {
let info = self.info.as_mut().unwrap();
let info = self
.info
.as_mut()
.expect("since we're loaded and exist, child should not be terminated");
if is_tty {
info.timeout = DEFAULT_TIMEOUT;
}
Expand All @@ -635,7 +638,9 @@ impl ChildContainer {
// be stopped again.
pub fn terminate(&mut self) {
if self.exists.swap(false, Ordering::SeqCst) {
let info = self.info.as_mut().unwrap();
let info = self.info.as_mut().expect(
"since we're loaded and exist, child should not have been terminated already",
);
let mut msg_info = MessageInfo::new(info.color_choice, info.verbosity);
let container = DockerContainer::new(&info.engine, &info.name);
container.stop(info.timeout, &mut msg_info).ok();
Expand Down
4 changes: 2 additions & 2 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn fmt_unc(server: &std::ffi::OsStr, volume: &std::ffi::OsStr) -> Result<String>
if server == "localhost"
&& bytes.len() == 2
&& bytes[1] == b'$'
&& matches!(bytes[0], b'A'..=b'Z' | b'a'..=b'z')
&& bytes[0].is_ascii_alphabetic()
{
Ok(fmt_disk(bytes[0]))
} else {
Expand Down Expand Up @@ -188,7 +188,7 @@ fn _canonicalize(path: &Path) -> Result<PathBuf> {
#[cfg(target_os = "windows")]
{
// Docker does not support UNC paths, this will try to not use UNC paths
dunce::canonicalize(&path).map_err(Into::into)
dunce::canonicalize(path).map_err(Into::into)
}
#[cfg(not(target_os = "windows"))]
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
clippy::semicolon_if_nothing_returned,
clippy::str_to_string,
clippy::string_to_string,
// needs clippy 1.61 clippy::unwrap_used
clippy::unwrap_used
)]

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cross will not attempt to configure the toolchain further so that it can run you
}
return Err(cmd
.status_result(msg_info, output.status, Some(&output))
.unwrap_err()
.expect_err("we know the command failed")
.to_section_report());
}
let out = output.stdout()?;
Expand Down
9 changes: 2 additions & 7 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ macro_rules! status {
}

/// the requested verbosity of output.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Verbosity {
Quiet,
#[default]
Normal,
Verbose(u8),
}
Expand Down Expand Up @@ -105,12 +106,6 @@ impl Verbosity {
}
}

impl Default for Verbosity {
fn default() -> Verbosity {
Verbosity::Normal
}
}

/// Whether messages should use color output
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ColorChoice {
Expand Down

0 comments on commit 6166fa5

Please sign in to comment.