Skip to content

Commit 5044c3b

Browse files
committed
thanks clippy
For v1.72.0
1 parent 524000a commit 5044c3b

File tree

19 files changed

+53
-55
lines changed

19 files changed

+53
-55
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ rustflags = [
55

66
# Clippy lints
77
"-W", "clippy::cloned_instead_of_copied",
8-
"-W", "clippy::explicit_iter_loop",
98
"-W", "clippy::map_unwrap_or",
109
"-W", "clippy::redundant_closure_for_method_calls",
1110
"-W", "clippy::unnested_or_patterns",
@@ -14,6 +13,7 @@ rustflags = [
1413
# Rejected for now, and why
1514
# "-W" "clippy::default_trait_access" - sometimes makes imports necessary, just for a default value. It's good for more explicit typing though.
1615
# "-W" "clippy::range_plus_one" - useful, but caused too many false positives as we use range types directly quite a lot
16+
# "-W", "clippy::explicit_iter_loop", - the cases I saw turned `foo.iter_mut()` into `&mut *foo`
1717

1818

1919
# Rustdoc lints

gitoxide-core/src/corpus/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn create(path: impl AsRef<std::path::Path>) -> anyhow::Result<rusqlite::Con
9292
"#,
9393
)?;
9494
con.execute_batch(
95-
r#"
95+
r"
9696
CREATE TABLE if not exists repository(
9797
id integer PRIMARY KEY,
9898
rela_path text, -- the path to the repository on disk, relative to the corpus root path, without leading `./` or `.\`
@@ -103,7 +103,7 @@ pub fn create(path: impl AsRef<std::path::Path>) -> anyhow::Result<rusqlite::Con
103103
FOREIGN KEY (corpus) REFERENCES corpus (id)
104104
UNIQUE (rela_path, corpus)
105105
)
106-
"#,
106+
",
107107
)?;
108108
con.execute_batch(
109109
r#"

gitoxide-core/src/repository/submodule.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ pub fn list(repo: Repository, mut out: impl std::io::Write, format: OutputFormat
99
bail!("Only human output is supported for now")
1010
}
1111

12-
let Some(submodules) = repo.submodules()? else { return Ok(()) };
12+
let Some(submodules) = repo.submodules()? else {
13+
return Ok(());
14+
};
1315
for sm in submodules {
1416
print_sm(sm, &mut out)?;
1517
}

gix-config/src/parse/nom/tests.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ mod section_headers {
6262
fn backslashes_in_subsections_do_not_escape_newlines_or_tabs() {
6363
assert_eq!(
6464
section_header.parse_peek(br#"[hello "single \ \\ \t \n \0"]"#).unwrap(),
65-
fully_consumed(parsed_section_header("hello", (" ", r#"single \ t n 0"#)))
65+
fully_consumed(parsed_section_header("hello", (" ", r"single \ t n 0")))
6666
);
6767
}
6868

@@ -756,6 +756,7 @@ mod value_no_continuation {
756756
}
757757

758758
#[test]
759+
#[allow(clippy::needless_raw_string_hashes)]
759760
fn trans_escaped_comment_marker_not_consumed() {
760761
let mut events = section::Events::default();
761762
assert_eq!(value_impl(br##"hello"#"world; a"##, &mut events).unwrap().0, b"; a");
@@ -776,7 +777,7 @@ mod value_no_continuation {
776777

777778
#[test]
778779
fn invalid_escape() {
779-
assert!(value_impl(br#"\x"#, &mut Default::default()).is_err());
780+
assert!(value_impl(br"\x", &mut Default::default()).is_err());
780781
}
781782

782783
#[test]
@@ -786,7 +787,7 @@ mod value_no_continuation {
786787

787788
#[test]
788789
fn incomplete_escape() {
789-
assert!(value_impl(br#"hello world\"#, &mut Default::default()).is_err());
790+
assert!(value_impl(br"hello world\", &mut Default::default()).is_err());
790791
}
791792
}
792793

gix-config/src/parse/section/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn escape_subsection(name: &BStr) -> Cow<'_, BStr> {
147147
let mut buf = Vec::with_capacity(name.len());
148148
for b in name.iter().copied() {
149149
match b {
150-
b'\\' => buf.push_str(br#"\\"#),
150+
b'\\' => buf.push_str(br"\\"),
151151
b'"' => buf.push_str(br#"\""#),
152152
_ => buf.push(b),
153153
}

gix-config/tests/file/init/from_paths/includes/conditional/gitdir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ fn case_insensitive_matches_any_case() -> crate::Result {
189189
#[test]
190190
fn pattern_with_escaped_backslash() -> crate::Result {
191191
assert_section_value(
192-
original_value_on_windows(Condition::new(r#"gitdir:\\work\\tree\\/"#)),
192+
original_value_on_windows(Condition::new(r"gitdir:\\work\\tree\\/")),
193193
GitEnv::repo_name("worktree")?,
194194
)
195195
}
196196

197197
#[test]
198198
fn pattern_with_backslash() -> crate::Result {
199-
assert_section_value(Condition::new(r#"gitdir:work\tree/"#), GitEnv::repo_name("worktree")?)
199+
assert_section_value(Condition::new(r"gitdir:work\tree/"), GitEnv::repo_name("worktree")?)
200200
}
201201

202202
#[test]

gix-config/tests/file/mutable/section.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,15 @@ mod set_leading_whitespace {
260260
}
261261

262262
fn multi_value_section() -> gix_config::File<'static> {
263-
r#"
263+
r"
264264
[a]
265265
a = v
266266
b =
267267
c=
268268
d
269269
e =a \
270270
b \
271-
c"#
271+
c"
272272
.parse()
273273
.unwrap()
274274
}

gix-config/tests/parse/section.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod header {
2222
#[test]
2323
fn subsection_backslashes_and_quotes_are_escaped() -> crate::Result {
2424
assert_eq!(
25-
section::Header::new("core", cow_section(r#"a\b"#))?.to_bstring(),
25+
section::Header::new("core", cow_section(r"a\b"))?.to_bstring(),
2626
r#"[core "a\\b"]"#
2727
);
2828
assert_eq!(

gix-config/tests/value/normalize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn inner_quotes_are_removed() {
6969

7070
#[test]
7171
fn newline_tab_backspace_are_escapable() {
72-
assert_eq!(normalize_bstr(r#"\n\ta\b"#), cow_str("\n\t"));
72+
assert_eq!(normalize_bstr(r"\n\ta\b"), cow_str("\n\t"));
7373
}
7474

7575
#[test]
@@ -80,7 +80,7 @@ fn tabs_are_not_resolved_to_spaces_unlike_what_git_does() {
8080
#[test]
8181
fn other_escapes_are_ignored_entirely() {
8282
assert_eq!(
83-
normalize_bstr(r#"\x"#),
83+
normalize_bstr(r"\x"),
8484
cow_str("x"),
8585
"however, these would cause failure on parsing level so we ignore it similar to subsections"
8686
);

gix-date/tests/time/parse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ mod relative {
148148

149149
#[test]
150150
fn various() {
151-
let now = Some(SystemTime::now());
152-
let two_weeks_ago = gix_date::parse("2 weeks ago", now).unwrap();
151+
let now = SystemTime::now();
152+
let two_weeks_ago = gix_date::parse("2 weeks ago", Some(now)).unwrap();
153153
assert_eq!(Sign::Plus, two_weeks_ago.sign);
154154
assert_eq!(0, two_weeks_ago.offset);
155-
let expected = OffsetDateTime::from(now.unwrap()).saturating_sub(Duration::weeks(2));
155+
let expected = OffsetDateTime::from(now).saturating_sub(Duration::weeks(2));
156156
// account for the loss of precision when creating `Time` with seconds
157157
let expected = expected.replace_nanosecond(0).unwrap();
158158
assert_eq!(

0 commit comments

Comments
 (0)