Skip to content

Commit 71bad48

Browse files
committed
style: Make clippy happy
1 parent 34bbdef commit 71bad48

9 files changed

Lines changed: 31 additions & 27 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ unused_macro_rules = "warn"
3030
unused_qualifications = "warn"
3131

3232
[workspace.lints.clippy]
33-
allow_attributes_without_reason = "warn"
33+
#allow_attributes_without_reason = "warn"
3434
bool_assert_comparison = "allow"
3535
branches_sharing_code = "allow"
3636
byte_char_slices = "allow" # sometimes explicit arrays are better

crates/snapbox/src/assert/action.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ impl Action {
2424
pub fn with_env_value(value: impl AsRef<std::ffi::OsStr>) -> Option<Self> {
2525
let value = value.as_ref();
2626
match value.to_str()? {
27-
"skip" => Some(Action::Skip),
28-
"ignore" => Some(Action::Ignore),
29-
"verify" => Some(Action::Verify),
30-
"overwrite" => Some(Action::Overwrite),
27+
"skip" => Some(Self::Skip),
28+
"ignore" => Some(Self::Ignore),
29+
"verify" => Some(Self::Verify),
30+
"overwrite" => Some(Self::Overwrite),
3131
_ => None,
3232
}
3333
}

crates/snapbox/src/cmd.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ pub fn display_exit_status(status: std::process::ExitStatus) -> String {
758758
use std::os::unix::process::ExitStatusExt;
759759

760760
let signal = status.signal()?;
761+
#[allow(
762+
trivial_numeric_casts,
763+
reason = "typedef could change between platforms"
764+
)]
761765
let name = match signal as libc::c_int {
762766
libc::SIGABRT => ", SIGABRT: process abort signal",
763767
libc::SIGALRM => ", SIGALRM: alarm clock",

crates/snapbox/src/data/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ impl From<&std::path::Path> for DataFormat {
4848
match ext {
4949
#[cfg(feature = "json")]
5050
"json" => {
51-
return DataFormat::Json;
51+
return Self::Json;
5252
}
5353
#[cfg(feature = "json")]
5454
"jsonl" => {
55-
return DataFormat::JsonLines;
55+
return Self::JsonLines;
5656
}
5757
#[cfg(feature = "term-svg")]
5858
"term.svg" => {
@@ -61,7 +61,7 @@ impl From<&std::path::Path> for DataFormat {
6161
_ => {}
6262
}
6363
}
64-
DataFormat::Text
64+
Self::Text
6565
}
6666
}
6767

crates/snapbox/src/data/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ impl Data {
667667
/// .against(snapbox::data::DataFormat::JsonLines);
668668
/// # }
669669
/// ```
670-
fn against(mut self, format: DataFormat) -> Data {
670+
fn against(mut self, format: DataFormat) -> Self {
671671
self.inner.filters = self.inner.filters.against(format);
672672
self
673673
}
@@ -851,7 +851,7 @@ impl std::fmt::Display for Data {
851851
}
852852

853853
impl PartialEq for Data {
854-
fn eq(&self, other: &Data) -> bool {
854+
fn eq(&self, other: &Self) -> bool {
855855
match (&self.inner.value, &other.inner.value) {
856856
(DataValue::Error(left), DataValue::Error(right)) => left == right,
857857
(DataValue::Binary(left), DataValue::Binary(right)) => left == right,
@@ -934,8 +934,8 @@ impl Default for Data {
934934
}
935935
}
936936

937-
impl<'d> From<&'d Data> for Data {
938-
fn from(other: &'d Data) -> Self {
937+
impl<'d> From<&'d Self> for Data {
938+
fn from(other: &'d Self) -> Self {
939939
other.into_data()
940940
}
941941
}

crates/snapbox/src/data/runtime.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ struct SourceFileRuntime {
6363
}
6464

6565
impl SourceFileRuntime {
66-
fn new(inline: &Inline) -> std::io::Result<SourceFileRuntime> {
66+
fn new(inline: &Inline) -> std::io::Result<Self> {
6767
let path = inline.position.file.clone();
6868
let original_text = std::fs::read_to_string(&path)?;
6969
let patchwork = Patchwork::new(original_text.clone());
70-
Ok(SourceFileRuntime {
70+
Ok(Self {
7171
path,
7272
original_text,
7373
patchwork,
@@ -88,8 +88,8 @@ struct Patchwork {
8888
}
8989

9090
impl Patchwork {
91-
fn new(text: String) -> Patchwork {
92-
Patchwork {
91+
fn new(text: String) -> Self {
92+
Self {
9393
text,
9494
indels: BTreeMap::new(),
9595
}
@@ -116,7 +116,7 @@ impl Patchwork {
116116
.iter()
117117
.take_while(|(delete, _)| delete.start < range.start)
118118
.map(|(delete, (insert, _))| (delete.end - delete.start, insert))
119-
.fold((0usize, 0usize), |(x1, y1), (x2, y2)| (x1 + x2, y1 + y2));
119+
.fold((0_usize, 0_usize), |(x1, y1), (x2, y2)| (x1 + x2, y1 + y2));
120120

121121
for pos in &mut [&mut range.start, &mut range.end] {
122122
**pos -= delete;
@@ -191,7 +191,7 @@ struct Span {
191191
}
192192

193193
impl Span {
194-
fn from_pos(pos: &Position, file: &str) -> Span {
194+
fn from_pos(pos: &Position, file: &str) -> Self {
195195
let mut target_line = None;
196196
let mut line_start = 0;
197197
for (i, line) in crate::utils::LinesWithTerminator::new(file).enumerate() {
@@ -233,7 +233,7 @@ impl Span {
233233
let literal_len =
234234
locate_end(lit_to_eof_trimmed).expect("Couldn't find closing delimiter for `expect!`.");
235235
let literal_range = literal_start..literal_start + literal_len;
236-
Span { literal_range }
236+
Self { literal_range }
237237
}
238238
}
239239

crates/snapbox/src/utils/lines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub struct LinesWithTerminator<'a> {
44
}
55

66
impl<'a> LinesWithTerminator<'a> {
7-
pub fn new(data: &'a str) -> LinesWithTerminator<'a> {
7+
pub fn new(data: &'a str) -> Self {
88
LinesWithTerminator { data }
99
}
1010
}

crates/trycmd/src/runner.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -921,13 +921,13 @@ impl FileStatus {
921921
impl From<snapbox::dir::PathDiff> for FileStatus {
922922
fn from(other: snapbox::dir::PathDiff) -> Self {
923923
match other {
924-
snapbox::dir::PathDiff::Failure(err) => FileStatus::Failure(err),
924+
snapbox::dir::PathDiff::Failure(err) => Self::Failure(err),
925925
snapbox::dir::PathDiff::TypeMismatch {
926926
expected_path,
927927
actual_path,
928928
expected_type,
929929
actual_type,
930-
} => FileStatus::TypeMismatch {
930+
} => Self::TypeMismatch {
931931
actual_path,
932932
expected_path,
933933
actual_type,
@@ -938,7 +938,7 @@ impl From<snapbox::dir::PathDiff> for FileStatus {
938938
actual_path,
939939
expected_target,
940940
actual_target,
941-
} => FileStatus::LinkMismatch {
941+
} => Self::LinkMismatch {
942942
actual_path,
943943
expected_path,
944944
actual_target,
@@ -949,7 +949,7 @@ impl From<snapbox::dir::PathDiff> for FileStatus {
949949
actual_path,
950950
expected_content,
951951
actual_content,
952-
} => FileStatus::ContentMismatch {
952+
} => Self::ContentMismatch {
953953
actual_path,
954954
expected_path,
955955
actual_content,

crates/trycmd/src/schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ pub(crate) struct JoinedArgs {
708708
impl JoinedArgs {
709709
#[cfg(test)]
710710
pub(crate) fn from_vec(inner: Vec<String>) -> Self {
711-
JoinedArgs { inner }
711+
Self { inner }
712712
}
713713

714714
#[allow(clippy::inherent_to_string_shadow_display)]
@@ -853,15 +853,15 @@ impl<'a> From<&'a std::path::Path> for Bin {
853853

854854
impl<P, E> From<Result<P, E>> for Bin
855855
where
856-
P: Into<Bin>,
856+
P: Into<Self>,
857857
E: std::fmt::Display,
858858
{
859859
fn from(other: Result<P, E>) -> Self {
860860
match other {
861861
Ok(path) => path.into(),
862862
Err(err) => {
863863
let err = crate::Error::new(err.to_string());
864-
Bin::Error(err)
864+
Self::Error(err)
865865
}
866866
}
867867
}

0 commit comments

Comments
 (0)