Skip to content

Commit 6166fa5

Browse files
committed
make clippy happy
1 parent 2f6d9b3 commit 6166fa5

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

clippy.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
disallowed-methods = [
22
{ path = "std::path::Path::display", reason = "incorrect handling of non-Unicode paths, use path.to_utf8() or debug (`{path:?}`) instead" },
33
]
4-
# needs clippy 1.61
5-
# allow-unwrap-in-tests = true
4+
allow-unwrap-in-tests = true

src/docker/remote.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
7777
if msg_info.cross_debug
7878
&& src.is_dir()
7979
&& !src.to_string_lossy().ends_with("/.")
80-
&& rel == src.file_name().unwrap()
80+
&& rel
81+
== src
82+
.file_name()
83+
.expect("filename should be defined as we are a directory")
8184
{
8285
msg_info.warn(format_args!(
8386
"source is pointing to a directory instead of its contents: {} -> {}\nThis might be a bug. {}",

src/docker/shared.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,10 @@ impl ChildContainer {
612612
// relax the no-timeout and lack of output
613613
// ensure we have atomic ordering
614614
if self.exists() {
615-
let info = self.info.as_mut().unwrap();
615+
let info = self
616+
.info
617+
.as_mut()
618+
.expect("since we're loaded and exist, child should not be terminated");
616619
if is_tty {
617620
info.timeout = DEFAULT_TIMEOUT;
618621
}
@@ -635,7 +638,9 @@ impl ChildContainer {
635638
// be stopped again.
636639
pub fn terminate(&mut self) {
637640
if self.exists.swap(false, Ordering::SeqCst) {
638-
let info = self.info.as_mut().unwrap();
641+
let info = self.info.as_mut().expect(
642+
"since we're loaded and exist, child should not have been terminated already",
643+
);
639644
let mut msg_info = MessageInfo::new(info.color_choice, info.verbosity);
640645
let container = DockerContainer::new(&info.engine, &info.name);
641646
container.stop(info.timeout, &mut msg_info).ok();

src/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn fmt_unc(server: &std::ffi::OsStr, volume: &std::ffi::OsStr) -> Result<String>
6969
if server == "localhost"
7070
&& bytes.len() == 2
7171
&& bytes[1] == b'$'
72-
&& matches!(bytes[0], b'A'..=b'Z' | b'a'..=b'z')
72+
&& bytes[0].is_ascii_alphabetic()
7373
{
7474
Ok(fmt_disk(bytes[0]))
7575
} else {
@@ -188,7 +188,7 @@ fn _canonicalize(path: &Path) -> Result<PathBuf> {
188188
#[cfg(target_os = "windows")]
189189
{
190190
// Docker does not support UNC paths, this will try to not use UNC paths
191-
dunce::canonicalize(&path).map_err(Into::into)
191+
dunce::canonicalize(path).map_err(Into::into)
192192
}
193193
#[cfg(not(target_os = "windows"))]
194194
{

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
clippy::semicolon_if_nothing_returned,
2525
clippy::str_to_string,
2626
clippy::string_to_string,
27-
// needs clippy 1.61 clippy::unwrap_used
27+
clippy::unwrap_used
2828
)]
2929

3030
#[cfg(test)]

src/rustup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ cross will not attempt to configure the toolchain further so that it can run you
9999
}
100100
return Err(cmd
101101
.status_result(msg_info, output.status, Some(&output))
102-
.unwrap_err()
102+
.expect_err("we know the command failed")
103103
.to_section_report());
104104
}
105105
let out = output.stdout()?;

src/shell.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ macro_rules! status {
7070
}
7171

7272
/// the requested verbosity of output.
73-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
73+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
7474
pub enum Verbosity {
7575
Quiet,
76+
#[default]
7677
Normal,
7778
Verbose(u8),
7879
}
@@ -105,12 +106,6 @@ impl Verbosity {
105106
}
106107
}
107108

108-
impl Default for Verbosity {
109-
fn default() -> Verbosity {
110-
Verbosity::Normal
111-
}
112-
}
113-
114109
/// Whether messages should use color output
115110
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
116111
pub enum ColorChoice {

0 commit comments

Comments
 (0)