diff --git a/build.rs b/build.rs index b5cc8149ffe..b8632bc4024 100644 --- a/build.rs +++ b/build.rs @@ -2,7 +2,7 @@ use std::process::Command; fn main() { let version = Command::new(if cfg!(windows) { "git.exe" } else { "git" }) - .args(["describe", "--match=v*\\.*\\.*"]) + .args(["describe", r"--match=v*\.*\.*"]) .output() .ok() .and_then(|out| parse_describe(&out.stdout)) diff --git a/gix-actor/src/signature/mod.rs b/gix-actor/src/signature/mod.rs index 64a48739493..9a9a0510a6c 100644 --- a/gix-actor/src/signature/mod.rs +++ b/gix-actor/src/signature/mod.rs @@ -82,7 +82,7 @@ pub(crate) mod write { #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub(crate) enum Error { - #[error("Signature name or email must not contain '<', '>' or \\n")] + #[error(r"Signature name or email must not contain '<', '>' or \n")] IllegalCharacter, } diff --git a/gix-actor/tests/identity/mod.rs b/gix-actor/tests/identity/mod.rs index fe77c9dc7c9..72d9421bd84 100644 --- a/gix-actor/tests/identity/mod.rs +++ b/gix-actor/tests/identity/mod.rs @@ -34,7 +34,7 @@ fn lenient_parsing() -> gix_testtools::Result { let err = signature.write_to(&mut output).unwrap_err(); assert_eq!( err.to_string(), - "Signature name or email must not contain '<', '>' or \\n", + r"Signature name or email must not contain '<', '>' or \n", "this isn't roundtrippable as the name is technically incorrect - must not contain brackets" ); } diff --git a/gix-attributes/src/parse.rs b/gix-attributes/src/parse.rs index 5b9048d3794..600c7c1191e 100644 --- a/gix-attributes/src/parse.rs +++ b/gix-attributes/src/parse.rs @@ -20,7 +20,7 @@ mod error { #[derive(thiserror::Error, Debug)] #[allow(missing_docs)] pub enum Error { - #[error("Line {line_number} has a negative pattern, for literal characters use \\!: {line}")] + #[error(r"Line {line_number} has a negative pattern, for literal characters use \!: {line}")] PatternNegation { line_number: usize, line: BString }, #[error("Attribute in line {line_number} has non-ascii characters or starts with '-': {attribute}")] AttributeName { line_number: usize, attribute: BString }, diff --git a/gix-attributes/tests/parse/mod.rs b/gix-attributes/tests/parse/mod.rs index fb40948e7ea..75000826327 100644 --- a/gix-attributes/tests/parse/mod.rs +++ b/gix-attributes/tests/parse/mod.rs @@ -117,7 +117,7 @@ fn exclamation_marks_must_be_escaped_or_error_unlike_gitignore() { #[test] fn invalid_escapes_in_quotes_are_an_error() { - assert!(matches!(try_line(r#""\!hello""#), Err(parse::Error::Unquote(_)),),); + assert!(matches!(try_line(r#""\!hello""#), Err(parse::Error::Unquote(_)))); assert!(lenient_lines(r#""\!hello""#).is_empty()); } diff --git a/gix-command/src/lib.rs b/gix-command/src/lib.rs index c8d47d93e32..8199d0c186a 100644 --- a/gix-command/src/lib.rs +++ b/gix-command/src/lib.rs @@ -290,10 +290,10 @@ mod prepare { prep.command = gix_path::from_bstring(gix_quote::single(command)).into(); } } - prep.command.push(" \"$@\""); + prep.command.push(r#" "$@""#); } else { gix_trace::debug!( - "Will not add '\"$@\"' to '{:?}' as it seems to contain '$@' already", + r#"Will not add '"$@"' to '{:?}' as it seems to contain '$@' already"#, prep.command ); } @@ -434,7 +434,7 @@ pub mod shebang { let mut line = buf.lines().next()?; line = line.strip_prefix(b"#!")?; - let slash_idx = line.rfind_byteset(b"/\\")?; + let slash_idx = line.rfind_byteset(br"/\")?; Some(match line[slash_idx..].find_byte(b' ') { Some(space_idx) => { let space = slash_idx + space_idx; diff --git a/gix-command/tests/command.rs b/gix-command/tests/command.rs index b73a4299632..30b29977563 100644 --- a/gix-command/tests/command.rs +++ b/gix-command/tests/command.rs @@ -52,13 +52,13 @@ mod shebang { "trimming works for tabs as well" ); assert_eq!( - parse("#!\\bin\\sh"), - exe("\\bin\\sh"), + parse(r"#!\bin\sh"), + exe(r"\bin\sh"), "backslashes are recognized as path separator" ); assert_eq!( parse("#!C:\\Program Files\\shell.exe\r\nsome stuff"), - exe("C:\\Program Files\\shell.exe"), + exe(r"C:\Program Files\shell.exe"), "absolute windows paths are fine" ); assert_eq!( @@ -192,8 +192,8 @@ mod context { #[test] fn glob_pathspecs_sets_env_only() { for (value, expected) in [ - (false, "GIT_NOGLOB_PATHSPECS=\"1\""), - (true, "GIT_GLOB_PATHSPECS=\"1\""), + (false, r#"GIT_NOGLOB_PATHSPECS="1""#), + (true, r#"GIT_GLOB_PATHSPECS="1""#), ] { let ctx = Context { glob_pathspecs: Some(value), @@ -305,7 +305,7 @@ mod prepare { #[test] fn single_and_complex_arguments_as_part_of_command_with_shell() { let cmd = std::process::Command::from( - gix_command::prepare("ls --foo \"a b\"") + gix_command::prepare(r#"ls --foo "a b""#) .arg("additional") .command_may_be_shell_script(), ); @@ -324,7 +324,7 @@ mod prepare { #[test] fn single_and_complex_arguments_with_auto_split() { let cmd = std::process::Command::from( - gix_command::prepare("ls --foo=\"a b\"").command_may_be_shell_script_allow_manual_argument_splitting(), + gix_command::prepare(r#"ls --foo="a b""#).command_may_be_shell_script_allow_manual_argument_splitting(), ); assert_eq!( format!("{cmd:?}"), @@ -336,7 +336,7 @@ mod prepare { #[test] fn single_and_complex_arguments_without_auto_split() { let cmd = std::process::Command::from( - gix_command::prepare("ls --foo=\"a b\"").command_may_be_shell_script_disallow_manual_argument_splitting(), + gix_command::prepare(r#"ls --foo="a b""#).command_may_be_shell_script_disallow_manual_argument_splitting(), ); assert_eq!(format!("{cmd:?}"), quoted(&[*SH, "-c", r#"ls --foo=\"a b\""#, "--"])); } @@ -351,7 +351,7 @@ mod prepare { ); assert_eq!( format!("{cmd:?}"), - quoted(&[*SH, "-c", "ls \\\"$@\\\"", "--", "--foo=a b"]) + quoted(&[*SH, "-c", r#"ls \"$@\""#, "--", "--foo=a b"]) ); } @@ -366,7 +366,7 @@ mod prepare { ); assert_eq!( format!("{cmd:?}"), - quoted(&[*SH, "-c", "\\'ls\\' \\\"$@\\\"", "--", "--foo=a b"]), + quoted(&[*SH, "-c", r#"\'ls\' \"$@\""#, "--", "--foo=a b"]), "looks strange thanks to debug printing, but is the right amount of quotes actually" ); } @@ -374,7 +374,7 @@ mod prepare { #[test] fn quoted_windows_command_without_argument_splitting() { let cmd = std::process::Command::from( - gix_command::prepare("C:\\Users\\O'Shaughnessy\\with space.exe") + gix_command::prepare(r"C:\Users\O'Shaughnessy\with space.exe") .arg("--foo='a b'") .command_may_be_shell_script_disallow_manual_argument_splitting() .with_shell() @@ -385,9 +385,9 @@ mod prepare { quoted(&[ *SH, "-c", - "\\'C:\\\\Users\\\\O\\'\\\\\\'\\'Shaughnessy\\\\with space.exe\\' \\\"$@\\\"", + r#"\'C:\\Users\\O\'\\\'\'Shaughnessy\\with space.exe\' \"$@\""#, "--", - "--foo=\\'a b\\'" + r"--foo=\'a b\'" ]), "again, a lot of extra backslashes, but it's correct outside of the debug formatting" ); @@ -409,7 +409,7 @@ mod prepare { #[test] fn tilde_path_and_multiple_arguments_as_part_of_command_with_shell() { let cmd = - std::process::Command::from(gix_command::prepare("~/bin/exe --foo \"a b\"").command_may_be_shell_script()); + std::process::Command::from(gix_command::prepare(r#"~/bin/exe --foo "a b""#).command_may_be_shell_script()); let sh = *SH; assert_eq!( format!("{cmd:?}"), @@ -421,7 +421,7 @@ mod prepare { #[test] fn script_with_dollar_at() { let cmd = std::process::Command::from( - gix_command::prepare("echo \"$@\" >&2") + gix_command::prepare(r#"echo "$@" >&2"#) .command_may_be_shell_script() .arg("store"), ); @@ -437,7 +437,7 @@ mod prepare { #[test] fn script_with_dollar_at_has_no_quoting() { let cmd = std::process::Command::from( - gix_command::prepare("echo \"$@\" >&2") + gix_command::prepare(r#"echo "$@" >&2"#) .command_may_be_shell_script() .with_quoted_command() .arg("store"), @@ -487,7 +487,7 @@ mod spawn { #[test] fn script_with_dollar_at() -> crate::Result { let out = std::process::Command::from( - gix_command::prepare("echo \"$@\"") + gix_command::prepare(r#"echo "$@""#) .command_may_be_shell_script() .arg("arg"), ) diff --git a/gix-config-value/tests/value/path.rs b/gix-config-value/tests/value/path.rs index 10970296dbf..94259d6355b 100644 --- a/gix-config-value/tests/value/path.rs +++ b/gix-config-value/tests/value/path.rs @@ -10,7 +10,7 @@ mod interpolate { #[test] fn backslash_is_not_special_and_they_are_not_escaping_anything() -> crate::Result { - for path in ["C:\\foo\\bar", "/foo/bar"] { + for path in [r"C:\foo\bar", "/foo/bar"] { let actual = gix_config_value::Path::from(Cow::Borrowed(b(path))).interpolate(Default::default())?; assert_eq!(actual, Path::new(path)); assert!( @@ -31,8 +31,8 @@ mod interpolate { #[test] fn prefix_substitutes_git_install_dir() { - for git_install_dir in &["/tmp/git", "C:\\git"] { - for (val, expected) in &[("%(prefix)/foo/bar", "foo/bar"), ("%(prefix)/foo\\bar", "foo\\bar")] { + for git_install_dir in &["/tmp/git", r"C:\git"] { + for (val, expected) in &[("%(prefix)/foo/bar", "foo/bar"), (r"%(prefix)/foo\bar", r"foo\bar")] { let expected = std::path::PathBuf::from(format!("{}{}{}", git_install_dir, std::path::MAIN_SEPARATOR, expected)); assert_eq!( @@ -103,7 +103,7 @@ mod interpolate { fn tilde_with_given_user() -> crate::Result { let home = std::env::current_dir()?; - for path_suffix in &["foo/bar", "foo\\bar", ""] { + for path_suffix in &["foo/bar", r"foo\bar", ""] { let path = format!("~user{}{}", std::path::MAIN_SEPARATOR, path_suffix); let expected = home.join("user").join(path_suffix); diff --git a/gix-config/src/file/mutable/mod.rs b/gix-config/src/file/mutable/mod.rs index 42da328bdb3..0ff284cb2f8 100644 --- a/gix-config/src/file/mutable/mod.rs +++ b/gix-config/src/file/mutable/mod.rs @@ -23,10 +23,10 @@ fn escape_value(value: &BStr) -> BString { for b in value.iter().copied() { match b { - b'\n' => buf.push_str("\\n"), - b'\t' => buf.push_str("\\t"), - b'"' => buf.push_str("\\\""), - b'\\' => buf.push_str("\\\\"), + b'\n' => buf.push_str(r"\n"), + b'\t' => buf.push_str(r"\t"), + b'"' => buf.push_str(r#"\""#), + b'\\' => buf.push_str(r"\\"), _ => buf.push(b), } } diff --git a/gix-config/src/parse/event.rs b/gix-config/src/parse/event.rs index 2ed855422fd..b6cb38994ba 100644 --- a/gix-config/src/parse/event.rs +++ b/gix-config/src/parse/event.rs @@ -37,7 +37,7 @@ impl Event<'_> { match self { Self::ValueNotDone(e) => { out.write_all(e.as_ref())?; - out.write_all(b"\\") + out.write_all(br"\") } Self::Whitespace(e) | Self::Newline(e) | Self::Value(e) | Self::ValueDone(e) => out.write_all(e.as_ref()), Self::KeyValueSeparator => out.write_all(b"="), diff --git a/gix-config/src/parse/nom/tests.rs b/gix-config/src/parse/nom/tests.rs index 5b254eec756..fbf735a18fc 100644 --- a/gix-config/src/parse/nom/tests.rs +++ b/gix-config/src/parse/nom/tests.rs @@ -88,7 +88,7 @@ mod section_headers { #[test] fn eof_after_escape_in_sub_section() { - assert!(section_header.parse_peek(b"[hello \"hello\\").is_err()); + assert!(section_header.parse_peek(br#"[hello "hello\"#).is_err()); } #[test] @@ -124,7 +124,7 @@ mod sub_section { #[test] fn zero_copy_simple() { - let actual = sub_section.parse_peek(b"name\"").unwrap().1; + let actual = sub_section.parse_peek(br#"name""#).unwrap().1; assert_eq!(actual.as_ref(), "name"); assert!(matches!(actual, Cow::Borrowed(_))); } @@ -301,7 +301,7 @@ mod section { whitespace_event(" "), Event::KeyValueSeparator, whitespace_event(" "), - value_event("\"lol\"") + value_event(r#""lol""#) ] }) ); @@ -370,7 +370,7 @@ mod section { whitespace_event(" "), Event::KeyValueSeparator, whitespace_event(" "), - value_event("\"lol\"") + value_event(r#""lol""#) ] }) ); @@ -567,7 +567,7 @@ mod value_continuation { let mut events = Vec::new(); assert!( value_impl(b"hello\\\r\r\n world", &mut events).is_err(), - "\\r must be followed by \\n" + r"\r must be followed by \n" ); } @@ -634,9 +634,9 @@ mod value_continuation { vec![ value_not_done_event("1"), newline_event(), - value_not_done_event("\"2\" a"), + value_not_done_event(r#""2" a"#), newline_event(), - value_not_done_event("\\\"3 b\\\""), + value_not_done_event(r#"\"3 b\""#), newline_event(), value_done_event("4") ] @@ -664,9 +664,9 @@ mod value_continuation { vec![ value_not_done_event("\"1"), newline_event(), - value_not_done_event("\"2\" a"), + value_not_done_event(r#""2" a"#), newline_event(), - value_not_done_event("\\\"3 b\\\""), + value_not_done_event(r#"\"3 b\""#), newline_event(), value_done_event("4 \"") ] @@ -761,7 +761,7 @@ mod value_no_continuation { #[test] fn garbage_after_continuation_is_err() { - assert!(value_impl(b"hello \\afwjdls", &mut Default::default()).is_err()); + assert!(value_impl(br"hello \afwjdls", &mut Default::default()).is_err()); } #[test] diff --git a/gix-config/src/parse/tests.rs b/gix-config/src/parse/tests.rs index 862488286d0..75c53fb677e 100644 --- a/gix-config/src/parse/tests.rs +++ b/gix-config/src/parse/tests.rs @@ -83,10 +83,10 @@ mod section { #[test] fn legacy_subsection_format_does_not_use_escapes() { - let invalid = header("invalid", Some((".", "\\ \""))); + let invalid = header("invalid", Some((".", r#"\ ""#))); assert_eq!( invalid.to_bstring(), - "[invalid.\\ \"]", + r#"[invalid.\ "]"#, "no escaping happens for legacy subsections" ); assert!(invalid.is_legacy()); diff --git a/gix-config/tests/config/file/access/read_only.rs b/gix-config/tests/config/file/access/read_only.rs index af73a30117b..aeadc24377e 100644 --- a/gix-config/tests/config/file/access/read_only.rs +++ b/gix-config/tests/config/file/access/read_only.rs @@ -87,7 +87,7 @@ fn get_value_for_all_provided_values() -> crate::Result { &[cow_str("")], "unset values show up as empty within a string array" ); - assert_eq!(config.strings("core.bool-implicit").expect("present"), &[cow_str("")],); + assert_eq!(config.strings("core.bool-implicit").expect("present"), &[cow_str("")]); assert_eq!(config.string("doesn't.exist"), None); diff --git a/gix-config/tests/config/file/init/comfort.rs b/gix-config/tests/config/file/init/comfort.rs index da1d67a0353..c84c10d02ca 100644 --- a/gix-config/tests/config/file/init/comfort.rs +++ b/gix-config/tests/config/file/init/comfort.rs @@ -44,7 +44,7 @@ fn from_git_dir() -> crate::Result { "value", "a value from the local repo configuration" ); - assert_eq!(config.string("a.local").expect("present").as_ref(), "value",); + assert_eq!(config.string("a.local").expect("present").as_ref(), "value"); assert_eq!( config.string_by("a", None, "local-include").expect("present").as_ref(), "from-a.config", diff --git a/gix-config/tests/config/key/mod.rs b/gix-config/tests/config/key/mod.rs index fe99b9fb5a8..8977756bb5b 100644 --- a/gix-config/tests/config/key/mod.rs +++ b/gix-config/tests/config/key/mod.rs @@ -20,8 +20,8 @@ fn valid_and_invalid() { assert_eq!(key.subsection_name.unwrap(), "quux.bar"); assert_eq!(key.value_name, "baz"); - let key = "includeIf.gitdir/i:C:\\bare.git.path".as_key(); - assert_eq!(key.subsection_name, Some("gitdir/i:C:\\bare.git".into()),); + let key = r"includeIf.gitdir/i:C:\bare.git.path".as_key(); + assert_eq!(key.subsection_name, Some(r"gitdir/i:C:\bare.git".into())); } mod _ref { @@ -56,10 +56,10 @@ mod _ref { ); assert_eq!( - KeyRef::parse_unvalidated("includeIf.gitdir/i:C:\\bare.git.path".into()), + KeyRef::parse_unvalidated(r"includeIf.gitdir/i:C:\bare.git.path".into()), Some(KeyRef { section_name: "includeIf", - subsection_name: Some("gitdir/i:C:\\bare.git".into()), + subsection_name: Some(r"gitdir/i:C:\bare.git".into()), value_name: "path" }) ); diff --git a/gix-config/tests/config/source/mod.rs b/gix-config/tests/config/source/mod.rs index 6050f283b83..26dc4e093bc 100644 --- a/gix-config/tests/config/source/mod.rs +++ b/gix-config/tests/config/source/mod.rs @@ -43,7 +43,7 @@ fn git_config_no_system() { _ => unreachable!("known set"), } }) - .is_some(),); + .is_some()); } #[test] diff --git a/gix-config/tests/config/value/normalize.rs b/gix-config/tests/config/value/normalize.rs index 0179e408412..fcaaee4b15c 100644 --- a/gix-config/tests/config/value/normalize.rs +++ b/gix-config/tests/config/value/normalize.rs @@ -49,7 +49,7 @@ fn quotes_right_next_to_each_other() { #[test] fn escaped_quotes_are_kept() { let cow = normalize_bstr(r#""hello \"\" world""#); - assert_eq!(cow, cow_str("hello \"\" world").clone(),); + assert_eq!(cow, cow_str("hello \"\" world").clone()); assert!(matches!(cow, Cow::Owned(_))); } diff --git a/gix-diff/tests/diff/blob/pipeline.rs b/gix-diff/tests/diff/blob/pipeline.rs index f4cfeba5d1b..7bd3e7f567b 100644 --- a/gix-diff/tests/diff/blob/pipeline.rs +++ b/gix-diff/tests/diff/blob/pipeline.rs @@ -459,7 +459,7 @@ pub(crate) mod convert_to_diffable { gix_filter::Pipeline::default(), vec![gix_diff::blob::Driver { name: "c".into(), - binary_to_text_command: Some("printf '\\0'; cat <".into()), + binary_to_text_command: Some(r"printf '\0'; cat <".into()), ..Default::default() }], default_options(), diff --git a/gix-diff/tests/diff/index.rs b/gix-diff/tests/diff/index.rs index 9b6810698e7..746aa04bf7a 100644 --- a/gix-diff/tests/diff/index.rs +++ b/gix-diff/tests/diff/index.rs @@ -312,7 +312,7 @@ fn renames_by_similarity_with_limit() -> crate::Result { "fuzzy tracking is effectively disabled due to limit" ); let actual: Vec<_> = changes.iter().map(|c| c.fields().0).collect(); - assert_eq!(actual, ["f1", "f1-renamed", "f2", "f2-renamed"],); + assert_eq!(actual, ["f1", "f1-renamed", "f2", "f2-renamed"]); let out = out.expect("tracking enabled"); assert_eq!(out.num_similarity_checks, 0); diff --git a/gix-diff/tests/diff/tree_with_rewrites.rs b/gix-diff/tests/diff/tree_with_rewrites.rs index b13e7f028e3..34186ec543f 100644 --- a/gix-diff/tests/diff/tree_with_rewrites.rs +++ b/gix-diff/tests/diff/tree_with_rewrites.rs @@ -422,7 +422,7 @@ fn renames_by_similarity_with_limit() -> crate::Result { "fuzzy tracking is effectively disabled due to limit" ); let actual: Vec<_> = changes.iter().map(Change::location).collect(); - assert_eq!(actual, ["f1", "f1-renamed", "f2", "f2-renamed"],); + assert_eq!(actual, ["f1", "f1-renamed", "f2", "f2-renamed"]); let out = out.expect("tracking enabled"); assert_eq!(out.num_similarity_checks, 0); diff --git a/gix-dir/tests/dir/walk.rs b/gix-dir/tests/dir/walk.rs index a6e34b257af..f27e58bfe2d 100644 --- a/gix-dir/tests/dir/walk.rs +++ b/gix-dir/tests/dir/walk.rs @@ -2166,8 +2166,8 @@ fn untracked_and_ignored_collapse_handling_for_deletion_with_wildcards() -> crat entryps("c.o", Ignored(Expendable), File, WildcardMatch), entryps("d/a.o", Ignored(Expendable), File, WildcardMatch), entryps("d/b.o", Ignored(Expendable), File, WildcardMatch), - entryps("d/d/a.o", Ignored(Expendable), File, WildcardMatch,), - entryps("d/d/b.o", Ignored(Expendable), File, WildcardMatch,), + entryps("d/d/a.o", Ignored(Expendable), File, WildcardMatch), + entryps("d/d/b.o", Ignored(Expendable), File, WildcardMatch), entryps("generated/a.o", Ignored(Expendable), File, WildcardMatch), entryps("objs", Ignored(Expendable), Directory, WildcardMatch), ], @@ -2213,7 +2213,7 @@ fn untracked_and_ignored_collapse_handling_for_deletion_with_wildcards() -> crat entryps("c.o", Ignored(Expendable), File, WildcardMatch), entryps("d/a.o", Ignored(Expendable), File, WildcardMatch), entryps("d/b.o", Ignored(Expendable), File, WildcardMatch), - entryps("d/d", Untracked, Directory, WildcardMatch,), + entryps("d/d", Untracked, Directory, WildcardMatch), entryps_dirstat("d/d/a.o", Ignored(Expendable), File, WildcardMatch, Untracked), entryps_dirstat("d/d/b.o", Ignored(Expendable), File, WildcardMatch, Untracked), entryps_dirstat( diff --git a/gix-discover/tests/discover/path/mod.rs b/gix-discover/tests/discover/path/mod.rs index b0bac5468fa..442d2b32e6d 100644 --- a/gix-discover/tests/discover/path/mod.rs +++ b/gix-discover/tests/discover/path/mod.rs @@ -20,8 +20,8 @@ mod from_git_dir_file { let (path, _) = write_and_read(b"gitdir: C:/absolute/path/.git")?; assert_eq!(path, Path::new("C:/absolute/path/.git")); - let (path, _) = write_and_read(b"gitdir: C:\\absolute\\path\\.git")?; - assert_eq!(path, Path::new("C:\\absolute\\path\\.git")); + let (path, _) = write_and_read(br"gitdir: C:\absolute\path\.git")?; + assert_eq!(path, Path::new(r"C:\absolute\path\.git")); Ok(()) } diff --git a/gix-discover/tests/discover/upwards/mod.rs b/gix-discover/tests/discover/upwards/mod.rs index 9d75e047d3b..f5583d2cfe3 100644 --- a/gix-discover/tests/discover/upwards/mod.rs +++ b/gix-discover/tests/discover/upwards/mod.rs @@ -98,7 +98,7 @@ fn from_working_dir_no_config() -> crate::Result { for name in ["worktree-no-config-after-init", "worktree-no-config"] { let dir = repo_path()?.join(name); let (path, trust) = gix_discover::upwards(&dir)?; - assert_eq!(path.kind(), Kind::WorkTree { linked_git_dir: None },); + assert_eq!(path.kind(), Kind::WorkTree { linked_git_dir: None }); assert_eq!(path.as_ref(), dir, "a working tree dir yields the git dir"); assert_eq!(trust, expected_trust()); } diff --git a/gix-fs/tests/fs/stack.rs b/gix-fs/tests/fs/stack.rs index 105e6b85d30..11fadd8fe68 100644 --- a/gix-fs/tests/fs/stack.rs +++ b/gix-fs/tests/fs/stack.rs @@ -218,7 +218,7 @@ fn relative_components_are_invalid() { ); assert_eq!( s.current().to_string_lossy(), - if cfg!(windows) { ".\\a\\b" } else { "./a/b" }, + if cfg!(windows) { r".\a\b" } else { "./a/b" }, "dot is silently ignored" ); s.make_relative_path_current("a//b/".as_ref(), &mut r) @@ -243,7 +243,7 @@ fn absolute_paths_are_invalid() -> crate::Result { let err = s.make_relative_path_current("/".as_ref(), &mut r).unwrap_err(); assert_eq!( err.to_string(), - "Input path \"/\" contains relative or absolute components", + r#"Input path "/" contains relative or absolute components"#, "a leading slash is always considered absolute" ); s.make_relative_path_current("a/".as_ref(), &mut r)?; @@ -252,19 +252,19 @@ fn absolute_paths_are_invalid() -> crate::Result { p("./a/"), "trailing slashes aren't a problem at this stage, as they cannot cause a 'breakout'" ); - s.make_relative_path_current("b\\".as_ref(), &mut r)?; + s.make_relative_path_current(r"b\".as_ref(), &mut r)?; assert_eq!( s.current(), - p("./b\\"), + p(r"./b\"), "trailing backslashes are fine both on Windows and Unix - on Unix it's part of the filename" ); #[cfg(windows)] { - let err = s.make_relative_path_current("\\".as_ref(), &mut r).unwrap_err(); + let err = s.make_relative_path_current(r"\".as_ref(), &mut r).unwrap_err(); assert_eq!( err.to_string(), - "Input path \"\\\" contains relative or absolute components", + r#"Input path "\" contains relative or absolute components"#, "on Windows, backslashes are considered absolute and replace the base if it is relative, \ hence they are forbidden." ); @@ -272,13 +272,13 @@ fn absolute_paths_are_invalid() -> crate::Result { let err = s.make_relative_path_current("c:".as_ref(), &mut r).unwrap_err(); assert_eq!( err.to_string(), - "Input path \"c:\" contains relative or absolute components", + r#"Input path "c:" contains relative or absolute components"#, "on Windows, drive-letters without trailing backslash or slash are also absolute (even though they ought to be relative)" ); - let err = s.make_relative_path_current("c:\\".as_ref(), &mut r).unwrap_err(); + let err = s.make_relative_path_current(r"c:\".as_ref(), &mut r).unwrap_err(); assert_eq!( err.to_string(), - "Input path \"c:\\\" contains relative or absolute components", + r#"Input path "c:\" contains relative or absolute components"#, "on Windows, drive-letters are absolute, which is expected" ); @@ -290,7 +290,7 @@ fn absolute_paths_are_invalid() -> crate::Result { but we just turn it into a presumably invalid path which is fine, i.e. we get a joined path" ); let err = s - .make_relative_path_current(r#"\\localhost\hello"#.as_ref(), &mut r) + .make_relative_path_current(r"\\localhost\hello".as_ref(), &mut r) .unwrap_err(); assert_eq!( err.to_string(), @@ -466,9 +466,9 @@ fn delegate_calls_are_consistent() -> crate::Result { #[cfg(not(windows))] { - s.make_relative_path_current("\\/b".as_ref(), &mut r)?; + s.make_relative_path_current(r"\/b".as_ref(), &mut r)?; dirs.pop(); - dirs.push(root.join("\\")); + dirs.push(root.join(r"\")); assert_eq!( r, Record { @@ -479,7 +479,7 @@ fn delegate_calls_are_consistent() -> crate::Result { "a backslash is a normal character outside of Windows, so it's fine to have it as component" ); - s.make_relative_path_current("\\".as_ref(), &mut r)?; + s.make_relative_path_current(r"\".as_ref(), &mut r)?; assert_eq!( r, Record { @@ -490,11 +490,11 @@ fn delegate_calls_are_consistent() -> crate::Result { ); assert_eq!( s.current().to_string_lossy(), - "./\\", - "a backslash can also be a valid leaf component - here we only popped the 'b', leaving the \\ 'directory'" + r"./\", + r"a backslash can also be a valid leaf component - here we only popped the 'b', leaving the \ 'directory'" ); - s.make_relative_path_current("\\\\".as_ref(), &mut r)?; + s.make_relative_path_current(r"\\".as_ref(), &mut r)?; dirs.pop(); assert_eq!( r, @@ -506,14 +506,14 @@ fn delegate_calls_are_consistent() -> crate::Result { ); assert_eq!( s.current().to_string_lossy(), - "./\\\\", + r"./\\", "the backslash can also be an ordinary leaf, without the need for it to be a directory" ); } #[cfg(windows)] { - s.make_relative_path_current("c\\/d".as_ref(), &mut r)?; + s.make_relative_path_current(r"c\/d".as_ref(), &mut r)?; dirs.pop(); dirs.push(root.join("c")); assert_eq!( @@ -526,7 +526,7 @@ fn delegate_calls_are_consistent() -> crate::Result { ); assert_eq!( s.current().to_string_lossy(), - ".\\c\\d", + r".\c\d", "the backslash is a path-separator, and so is the `/`, which is turned into backslash" ); } diff --git a/gix-glob/tests/parse/mod.rs b/gix-glob/tests/parse/mod.rs index 8377a44f24e..6b80dc53db9 100644 --- a/gix-glob/tests/parse/mod.rs +++ b/gix-glob/tests/parse/mod.rs @@ -78,7 +78,7 @@ fn leading_exclamation_marks_can_be_escaped_with_backslash() { assert_eq!(gix_glob::parse(br"\!hello"), pat("!hello", Mode::NO_SUB_DIR, None)); assert_eq!( gix_glob::Pattern::from_bytes_without_negation(br"\!hello"), - pat("\\!hello", Mode::NO_SUB_DIR, Some(0)), + pat(r"\!hello", Mode::NO_SUB_DIR, Some(0)), "negation can be disabled entirely, leaving escapes in place" ); } @@ -129,7 +129,7 @@ fn trailing_spaces_are_taken_literally() { fn trailing_spaces_can_be_escaped_to_be_literal() { assert_eq!( gix_glob::parse(br"a \ "), - pat("a \\ ", Mode::NO_SUB_DIR, Some(3)), + pat(r"a \ ", Mode::NO_SUB_DIR, Some(3)), "there is no escaping" ); assert_eq!( diff --git a/gix-index/tests/index/entry/stat.rs b/gix-index/tests/index/entry/stat.rs index d9f85f1986a..31089a93d47 100644 --- a/gix-index/tests/index/entry/stat.rs +++ b/gix-index/tests/index/entry/stat.rs @@ -95,7 +95,7 @@ mod matches { ); stat2.ctime.secs = 1; assert!( - stat1.matches(&stat2, Options::default(),), + stat1.matches(&stat2, Options::default()), "ctime seconds are the same so stat matches (trust_ctime=true,use_nsec=false)" ); assert!( diff --git a/gix-index/tests/index/file/init.rs b/gix-index/tests/index/file/init.rs index 063640497e1..828561d6e10 100644 --- a/gix-index/tests/index/file/init.rs +++ b/gix-index/tests/index/file/init.rs @@ -56,7 +56,7 @@ mod from_state { index.write(gix_index::write::Options::default())?; assert!(index.checksum().is_some(), "checksum is adjusted after writing"); assert!(index.path().is_file()); - assert_eq!(index.version(), expected_version,); + assert_eq!(index.version(), expected_version); index.verify_integrity()?; } diff --git a/gix-index/tests/index/file/write.rs b/gix-index/tests/index/file/write.rs index 10d924b4e21..efffa850eff 100644 --- a/gix-index/tests/index/file/write.rs +++ b/gix-index/tests/index/file/write.rs @@ -261,7 +261,7 @@ fn compare_states(actual: &State, actual_version: Version, expected: &State, opt expected.entries().len(), "entry count mismatch in {fixture:?}", ); - assert_eq!(actual.entries(), expected.entries(), "entries mismatch in {fixture:?}",); + assert_eq!(actual.entries(), expected.entries(), "entries mismatch in {fixture:?}"); assert_eq!( actual.path_backing(), expected.path_backing(), diff --git a/gix-index/tests/index/init.rs b/gix-index/tests/index/init.rs index 57dd46d2d94..46da447393b 100644 --- a/gix-index/tests/index/init.rs +++ b/gix-index/tests/index/init.rs @@ -45,8 +45,8 @@ fn from_tree_validation() -> crate::Result { let err = State::from_tree(&tree_id, &odb, Default::default()).unwrap_err(); assert_eq!( err.source().expect("inner").to_string(), - "Path separators like / or \\ are not allowed", - "Note that this effectively tests what would happen on Windows, where \\ also isn't allowed" + r"Path separators like / or \ are not allowed", + r"Note that this effectively tests what would happen on Windows, where \ also isn't allowed" ); } Ok(()) diff --git a/gix-merge/src/tree/utils.rs b/gix-merge/src/tree/utils.rs index db624605c49..49c8efe20b2 100644 --- a/gix-merge/src/tree/utils.rs +++ b/gix-merge/src/tree/utils.rs @@ -78,7 +78,7 @@ pub fn unique_path_in_tree( let mut suffix = 0; while editor.get(to_components_bstring_ref(&buf)).is_some() || tree.check_conflict(buf.as_bstr()).is_some() { buf.truncate(base_len); - buf.push_str(format!("_{suffix}",)); + buf.push_str(format!("_{suffix}")); suffix += 1; } Ok(buf) diff --git a/gix-merge/tests/merge/blob/builtin_driver.rs b/gix-merge/tests/merge/blob/builtin_driver.rs index 21b29bdcbbb..0ddb94da67d 100644 --- a/gix-merge/tests/merge/blob/builtin_driver.rs +++ b/gix-merge/tests/merge/blob/builtin_driver.rs @@ -161,7 +161,7 @@ mod text { num_diverging += 1; } else { if case.expected.contains_str("<<<<<<<") { - assert_eq!(actual, Resolution::Conflict, "{}: resolution mismatch", case.name,); + assert_eq!(actual, Resolution::Conflict, "{}: resolution mismatch", case.name); } else { assert!( matches!( diff --git a/gix-merge/tests/merge/blob/platform.rs b/gix-merge/tests/merge/blob/platform.rs index 6230377b821..75aa716e83c 100644 --- a/gix-merge/tests/merge/blob/platform.rs +++ b/gix-merge/tests/merge/blob/platform.rs @@ -463,7 +463,7 @@ theirs let mut input = imara_diff::intern::InternedInput::new(&[][..], &[]); assert_eq!( - platform_ref.builtin_merge(BuiltinDriver::Text, &mut out, &mut input, Default::default(),), + platform_ref.builtin_merge(BuiltinDriver::Text, &mut out, &mut input, Default::default()), res, "we can't enforce it, it will just default to using binary" ); @@ -689,7 +689,7 @@ mod prepare_merge { }, )?; let expected_idx = 1; - assert_eq!(prepared.driver, DriverChoice::Index(expected_idx),); + assert_eq!(prepared.driver, DriverChoice::Index(expected_idx)); assert_eq!( prepared.options.resolve_binary_with, Some(builtin_driver::binary::ResolveWith::Ours), diff --git a/gix-object/tests/object/encode/mod.rs b/gix-object/tests/object/encode/mod.rs index 0752eaeba8b..d7a028b0c7a 100644 --- a/gix-object/tests/object/encode/mod.rs +++ b/gix-object/tests/object/encode/mod.rs @@ -133,7 +133,7 @@ mod tree { let err = tree.write_to(&mut std::io::sink()).unwrap_err(); assert_eq!( err.to_string(), - "Nullbytes are invalid in file paths as they are separators: \"hi\\0ho\"" + r#"Nullbytes are invalid in file paths as they are separators: "hi\0ho""# ); } diff --git a/gix-object/tests/object/tree/editor.rs b/gix-object/tests/object/tree/editor.rs index 09f76f62cea..bd9ca96fd80 100644 --- a/gix-object/tests/object/tree/editor.rs +++ b/gix-object/tests/object/tree/editor.rs @@ -387,7 +387,7 @@ fn from_empty_invalid_write() -> crate::Result { .unwrap_err(); assert_eq!( err.to_string(), - "Nullbytes are invalid in file paths as they are separators: \"with\\0null\"" + r#"Nullbytes are invalid in file paths as they are separators: "with\0null""# ); let err = edit.upsert(Some(""), EntryKind::Blob, any_blob()).unwrap_err(); diff --git a/gix-pack/src/data/input/entry.rs b/gix-pack/src/data/input/entry.rs index d36b1ec7539..ad970aa0376 100644 --- a/gix-pack/src/data/input/entry.rs +++ b/gix-pack/src/data/input/entry.rs @@ -56,7 +56,7 @@ fn compress_data(obj: &gix_object::Data<'_>) -> Result, input::Error> { match err.kind() { std::io::ErrorKind::Other => return Err(input::Error::Io(err)), err => { - unreachable!("Should never see other errors than zlib, but got {:?}", err,) + unreachable!("Should never see other errors than zlib, but got {:?}", err) } } } diff --git a/gix-pack/src/data/output/entry/mod.rs b/gix-pack/src/data/output/entry/mod.rs index 32cdcb91e5f..18d20dd2c01 100644 --- a/gix-pack/src/data/output/entry/mod.rs +++ b/gix-pack/src/data/output/entry/mod.rs @@ -142,7 +142,7 @@ impl output::Entry { if let Err(err) = std::io::copy(&mut &*obj.data, &mut out) { match err.kind() { std::io::ErrorKind::Other => return Err(Error::ZlibDeflate(err)), - err => unreachable!("Should never see other errors than zlib, but got {:?}", err,), + err => unreachable!("Should never see other errors than zlib, but got {:?}", err), } } out.flush()?; diff --git a/gix-path/src/env/git/tests.rs b/gix-path/src/env/git/tests.rs index 0b2bf195af9..0964be27d41 100644 --- a/gix-path/src/env/git/tests.rs +++ b/gix-path/src/env/git/tests.rs @@ -623,7 +623,7 @@ mod exe_info { Some("/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig"), ), (win_msys, Some("C:/git-sdk-64/etc/gitconfig")), - (win_msys_old, Some("C:\\ProgramData/Git/config")), + (win_msys_old, Some(r"C:\ProgramData/Git/config")), (win_cmd, Some("C:/Program Files/Git/etc/gitconfig")), (linux, Some("/home/parallels/.gitconfig")), (bogus, None), @@ -645,7 +645,7 @@ fn config_to_base_path() { "/Applications/Xcode.app/Contents/Developer/usr/share/git-core", ), ("C:/git-sdk-64/etc/gitconfig", "C:/git-sdk-64/etc"), - ("C:\\ProgramData/Git/config", "C:\\ProgramData/Git"), + (r"C:\ProgramData/Git/config", r"C:\ProgramData/Git"), ("C:/Program Files/Git/etc/gitconfig", "C:/Program Files/Git/etc"), ] { assert_eq!(super::config_to_base_path(Path::new(input)), Path::new(expected)); diff --git a/gix-path/tests/path/convert/mod.rs b/gix-path/tests/path/convert/mod.rs index 350c5d450b3..d1d7fed73e7 100644 --- a/gix-path/tests/path/convert/mod.rs +++ b/gix-path/tests/path/convert/mod.rs @@ -5,7 +5,7 @@ use gix_path::{to_unix_separators, to_windows_separators}; fn assure_unix_separators() { assert_eq!(to_unix_separators(b"no-backslash".as_bstr()).as_bstr(), "no-backslash"); - assert_eq!(to_unix_separators(b"\\a\\b\\\\".as_bstr()).as_bstr(), "/a/b//"); + assert_eq!(to_unix_separators(br"\a\b\\".as_bstr()).as_bstr(), "/a/b//"); } #[test] @@ -15,7 +15,7 @@ fn assure_windows_separators() { "no-backslash" ); - assert_eq!(to_windows_separators(b"/a/b//".as_bstr()).as_bstr(), "\\a\\b\\\\"); + assert_eq!(to_windows_separators(b"/a/b//".as_bstr()).as_bstr(), r"\a\b\\"); } mod normalize; diff --git a/gix-path/tests/path/convert/normalize.rs b/gix-path/tests/path/convert/normalize.rs index b50a7474798..d1f8b5e384c 100644 --- a/gix-path/tests/path/convert/normalize.rs +++ b/gix-path/tests/path/convert/normalize.rs @@ -8,7 +8,7 @@ fn p(input: &str) -> &Path { #[test] fn no_change_if_there_are_no_trailing_relative_components() { - for input in ["./a/b/c/d", "/absolute/path", "C:\\hello\\world"] { + for input in ["./a/b/c/d", "/absolute/path", r"C:\hello\world"] { let path = p(input); assert_eq!(normalize(path.into(), &std::env::current_dir().unwrap()).unwrap(), path); } diff --git a/gix-path/tests/path/env.rs b/gix-path/tests/path/env.rs index c3c7019cbce..86803db550a 100644 --- a/gix-path/tests/path/env.rs +++ b/gix-path/tests/path/env.rs @@ -85,7 +85,7 @@ mod xdg_config { #[cfg(unix)] assert_eq!(actual.to_str(), Some("marker/git/test")); #[cfg(windows)] - assert_eq!(actual.to_str(), Some("marker\\git\\test")); + assert_eq!(actual.to_str(), Some(r"marker\git\test")); } #[test] @@ -95,6 +95,6 @@ mod xdg_config { #[cfg(unix)] assert_eq!(actual.to_str(), Some("marker/.config/git/test")); #[cfg(windows)] - assert_eq!(actual.to_str(), Some("marker\\.config\\git\\test")); + assert_eq!(actual.to_str(), Some(r"marker\.config\git\test")); } } diff --git a/gix-path/tests/path/realpath.rs b/gix-path/tests/path/realpath.rs index 321ca67fcb7..92e14685c59 100644 --- a/gix-path/tests/path/realpath.rs +++ b/gix-path/tests/path/realpath.rs @@ -74,7 +74,7 @@ fn assorted() -> crate::Result { #[cfg(not(windows))] let absolute_path = Path::new("/c/d/.git"); #[cfg(windows)] - let absolute_path = Path::new("C:\\c\\d\\.git"); + let absolute_path = Path::new(r"C:\c\d\.git"); assert_eq!( realpath_opts(absolute_path, cwd, symlinks_disabled)?, absolute_path, diff --git a/gix-path/tests/path/util.rs b/gix-path/tests/path/util.rs index 7d78de7e70b..6ca5932d5e5 100644 --- a/gix-path/tests/path/util.rs +++ b/gix-path/tests/path/util.rs @@ -15,8 +15,8 @@ mod is_absolute { mod not_on_windows { #[test] fn drive_prefixes_are_false() { - assert!(!gix_path::is_absolute("c:\\abs/path")); - assert!(!gix_path::is_absolute("c:\\abs\\path")); + assert!(!gix_path::is_absolute(r"c:\abs/path")); + assert!(!gix_path::is_absolute(r"c:\abs\path")); } } @@ -24,19 +24,19 @@ mod is_absolute { mod on_windows { #[test] fn drive_prefixes_are_true() { - assert!(gix_path::is_absolute("c:\\abs/path")); - assert!(gix_path::is_absolute("c:\\abs\\path")); + assert!(gix_path::is_absolute(r"c:\abs/path")); + assert!(gix_path::is_absolute(r"c:\abs\path")); } #[test] fn relative_paths_with_backslashes_are_false() { - assert!(!gix_path::is_absolute(".\\rel/path")); - assert!(!gix_path::is_absolute("rel\\path")); + assert!(!gix_path::is_absolute(r".\rel/path")); + assert!(!gix_path::is_absolute(r"rel\path")); } #[test] fn path_starting_with_backslash_is_false() { - assert!(!gix_path::is_absolute("\\rel\\path")); + assert!(!gix_path::is_absolute(r"\rel\path")); } } } diff --git a/gix-pathspec/src/parse.rs b/gix-pathspec/src/parse.rs index bc7569ed76c..eedf68e19f3 100644 --- a/gix-pathspec/src/parse.rs +++ b/gix-pathspec/src/parse.rs @@ -20,7 +20,7 @@ pub enum Error { InvalidAttribute { attribute: BString }, #[error("Invalid character in attribute value: {character:?}")] InvalidAttributeValue { character: char }, - #[error("Escape character '\\' is not allowed as the last character in an attribute value")] + #[error(r"Escape character '\' is not allowed as the last character in an attribute value")] TrailingEscapeCharacter, #[error("Attribute specification cannot be empty")] EmptyAttribute, diff --git a/gix-pathspec/src/pattern.rs b/gix-pathspec/src/pattern.rs index 171e7759e5d..24fe55ab173 100644 --- a/gix-pathspec/src/pattern.rs +++ b/gix-pathspec/src/pattern.rs @@ -178,7 +178,7 @@ impl Pattern { } else { buf.push_str("attr:"); for attr in &self.attributes { - let attr = attr.as_ref().to_string().replace(',', "\\,"); + let attr = attr.as_ref().to_string().replace(',', r"\,"); buf.push_str(&attr); buf.push(b' '); } diff --git a/gix-pathspec/tests/normalize/mod.rs b/gix-pathspec/tests/normalize/mod.rs index df3a245d781..c8f88de992c 100644 --- a/gix-pathspec/tests/normalize/mod.rs +++ b/gix-pathspec/tests/normalize/mod.rs @@ -102,7 +102,7 @@ fn relative_path_breaks_out_of_working_tree() { err.to_string(), format!( "The path '{}' leaves the repository", - if cfg!(windows) { "a\\../../b" } else { "a/../../b" } + if cfg!(windows) { r"a\../../b" } else { "a/../../b" } ) ); } diff --git a/gix-pathspec/tests/parse/valid.rs b/gix-pathspec/tests/parse/valid.rs index fe9290ada3b..1705b060c01 100644 --- a/gix-pathspec/tests/parse/valid.rs +++ b/gix-pathspec/tests/parse/valid.rs @@ -19,7 +19,7 @@ fn repeated_matcher_keywords() { #[test] fn glob_negations_are_always_literal() { - check_valid_inputs([("!a", pat_with_path("!a")), ("\\!a", pat_with_path("\\!a"))]); + check_valid_inputs([("!a", pat_with_path("!a")), (r"\!a", pat_with_path(r"\!a"))]); } #[test] diff --git a/gix-quote/src/single.rs b/gix-quote/src/single.rs index 6c36fdf3962..d0de9d1ff81 100644 --- a/gix-quote/src/single.rs +++ b/gix-quote/src/single.rs @@ -9,7 +9,7 @@ pub fn single(mut value: &BStr) -> BString { while let Some(pos) = value.find_byteset(b"'!") { quoted.extend_from_slice(&value[..pos]); - quoted.push_str(b"'\\"); + quoted.push_str(br"'\"); quoted.push(value[pos]); quoted.push(b'\''); diff --git a/gix-ref/src/store/file/log/line.rs b/gix-ref/src/store/file/log/line.rs index 9ac0a74507e..255001ff6b4 100644 --- a/gix-ref/src/store/file/log/line.rs +++ b/gix-ref/src/store/file/log/line.rs @@ -20,7 +20,7 @@ mod write { #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] enum Error { - #[error("Messages must not contain newlines\\n")] + #[error(r"Messages must not contain newlines (\n)")] IllegalCharacter, } @@ -96,7 +96,7 @@ pub mod decode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, - "{:?} did not match ' <> \\t'", + r"{:?} did not match ' <> \t'", self.input ) } @@ -142,7 +142,7 @@ pub mod decode { gix_actor::signature::decode.context(StrContext::Expected(" <> ".into())), ) .context(StrContext::Expected( - " <> \\t".into(), + r" <> \t".into(), )) .parse_next(&mut first)?; @@ -163,7 +163,7 @@ pub mod decode { gix_actor::signature::decode.context(StrContext::Expected(" <> ".into())), ) .context(StrContext::Expected( - " <> \\t".into(), + r" <> \t".into(), )), alt(( preceded( diff --git a/gix-ref/src/store/packed/decode/tests.rs b/gix-ref/src/store/packed/decode/tests.rs index e864ee99917..d3378469055 100644 --- a/gix-ref/src/store/packed/decode/tests.rs +++ b/gix-ref/src/store/packed/decode/tests.rs @@ -17,11 +17,11 @@ mod reference { #[test] fn invalid() { assert!(decode::reference::<()> - .parse_peek(b"# what looks like a comment",) + .parse_peek(b"# what looks like a comment") .is_err()); assert!( decode::reference::<()> - .parse_peek(b"^e9cdc958e7ce2290e2d7958cdb5aa9323ef35d37\n",) + .parse_peek(b"^e9cdc958e7ce2290e2d7958cdb5aa9323ef35d37\n") .is_err(), "lonely peel" ); diff --git a/gix-ref/tests/refs/file/log.rs b/gix-ref/tests/refs/file/log.rs index b87b55fe5b9..2efcb263278 100644 --- a/gix-ref/tests/refs/file/log.rs +++ b/gix-ref/tests/refs/file/log.rs @@ -17,7 +17,7 @@ mod line { #[test] fn round_trips() -> crate::Result { - let lines = &["0000000000000000000000000000000000000000 134385f6d781b7e97062102c6a483440bfda2a03 committer 946771200 +0000 commit (initial): c1\n", + let lines = &["0000000000000000000000000000000000000000 134385f6d781b7e97062102c6a483440bfda2a03 committer 946771200 +0000 commit (initial): c1\n", "0000000000000000000000000000000000000000 134385f6d781b7e97062102c6a483440bfda2a03 committer 946771200 +0000 \n"]; for line in lines { let line = log::LineRef::from_bytes(line.as_bytes())?; @@ -98,7 +98,7 @@ mod iter { .source() .expect("source") .to_string(), - "buffer too small for line size, got until \"0000000000000000 134385f6d781b7e97062102c6a483440bfda2a03 committer 946771200 +0000\\tcommit (initial): c1\"" + r#"buffer too small for line size, got until "0000000000000000 134385f6d781b7e97062102c6a483440bfda2a03 committer 946771200 +0000\tcommit (initial): c1""# ); assert!(iter.next().is_none(), "iterator depleted"); } @@ -221,7 +221,10 @@ mod iter { let mut iter = gix_ref::file::log::iter::forward(log_first_broken.as_bytes()); let err = iter.next().expect("error is not none").expect_err("the line is broken"); - assert_eq!(err.to_string(), "In line 1: \"0000000000000000000000000000000000000000 134385fbroken7062102c6a483440bfda2a03 committer 946771200 +0000\\tcommit\" did not match ' <> \\t'"); + assert_eq!( + err.to_string(), + r#"In line 1: "0000000000000000000000000000000000000000 134385fbroken7062102c6a483440bfda2a03 committer 946771200 +0000\tcommit" did not match ' <> \t'"# + ); assert!(iter.next().expect("a second line").is_ok(), "line parses ok"); assert!(iter.next().is_none(), "iterator exhausted"); } diff --git a/gix-ref/tests/refs/file/store/iter.rs b/gix-ref/tests/refs/file/store/iter.rs index 046bdbc58b1..bcd80ded6cb 100644 --- a/gix-ref/tests/refs/file/store/iter.rs +++ b/gix-ref/tests/refs/file/store/iter.rs @@ -73,14 +73,14 @@ mod with_namespace { ); assert_eq!( store - .find(fullname.as_bstr().splitn_str(2, b"/").nth(1).expect("name").as_bstr(),)? + .find(fullname.as_bstr().splitn_str(2, b"/").nth(1).expect("name").as_bstr())? .name, fullname, "it will find namespaced items just by their shortened (but not shortest) name" ); assert!( store - .try_find(reference.name_without_namespace(&ns_two).expect("namespaced"),)? + .try_find(reference.name_without_namespace(&ns_two).expect("namespaced"))? .is_none(), "it won't find namespaced items by their full name without namespace" ); @@ -167,7 +167,7 @@ mod with_namespace { for fullname in ref_names { assert_eq!( - ns_store.find(fullname.as_bstr(),)?.name, + ns_store.find(fullname.as_bstr())?.name, fullname, "it finds namespaced items by fully qualified name, excluding namespace" ); @@ -179,7 +179,7 @@ mod with_namespace { ); assert_eq!( ns_store - .find(fullname.as_bstr().splitn_str(2, b"/").nth(1).expect("name").as_bstr(),)? + .find(fullname.as_bstr().splitn_str(2, b"/").nth(1).expect("name").as_bstr())? .name, fullname, "it finds partial names within the namespace" @@ -275,9 +275,9 @@ fn loose_iter_with_broken_refs() -> crate::Result { "there is exactly one invalid item, and it didn't abort the iterator most importantly" ); #[cfg(not(windows))] - let msg = "The reference at \"refs/broken\" could not be instantiated"; + let msg = r#"The reference at "refs/broken" could not be instantiated"#; #[cfg(windows)] - let msg = "The reference at \"refs\\broken\" could not be instantiated"; + let msg = r#"The reference at "refs\broken" could not be instantiated"#; assert_eq!( actual[first_error].as_ref().expect_err("unparsable ref").to_string(), msg @@ -320,7 +320,7 @@ fn loose_iter_with_prefix_wont_allow_absolute_paths() -> crate::Result { #[cfg(not(windows))] let abs_path = "/hello"; #[cfg(windows)] - let abs_path = "c:\\hello"; + let abs_path = r"c:\hello"; match store.loose_iter_prefixed(abs_path.as_ref()) { Ok(_) => unreachable!("absolute paths aren't allowed"), @@ -372,7 +372,7 @@ fn loose_iter_with_partial_prefix() -> crate::Result { assert_eq!( actual, - vec!["refs/heads/d1", "refs/heads/dt1",] + vec!["refs/heads/d1", "refs/heads/dt1"] .into_iter() .map(String::from) .collect::>(), @@ -419,7 +419,7 @@ fn overlay_iter_with_prefix_wont_allow_absolute_paths() -> crate::Result { #[cfg(not(windows))] let abs_path = "/hello"; #[cfg(windows)] - let abs_path = "c:\\hello"; + let abs_path = r"c:\hello"; match store.iter()?.prefixed(abs_path.as_ref()) { Ok(_) => unreachable!("absolute paths aren't allowed"), diff --git a/gix-ref/tests/refs/file/transaction/prepare_and_commit/create_or_update/mod.rs b/gix-ref/tests/refs/file/transaction/prepare_and_commit/create_or_update/mod.rs index 26a9ae93308..1ad9bf62199 100644 --- a/gix-ref/tests/refs/file/transaction/prepare_and_commit/create_or_update/mod.rs +++ b/gix-ref/tests/refs/file/transaction/prepare_and_commit/create_or_update/mod.rs @@ -683,7 +683,7 @@ fn write_reference_to_which_head_points_to_does_not_update_heads_reflog_even_tho }, expected: PreviousValue::MustExistAndMatch(Target::Object(hex_to_id( "02a7a22d90d7c02fb494ed25551850b868e634f0" - )),), + ))), new: Target::Object(new_id), }, name: referent.as_bstr().try_into()?, diff --git a/gix-ref/tests/refs/file/transaction/prepare_and_commit/delete.rs b/gix-ref/tests/refs/file/transaction/prepare_and_commit/delete.rs index 6b422e1e113..ed28d0333dd 100644 --- a/gix-ref/tests/refs/file/transaction/prepare_and_commit/delete.rs +++ b/gix-ref/tests/refs/file/transaction/prepare_and_commit/delete.rs @@ -414,7 +414,7 @@ fn a_loose_ref_with_old_value_check_and_outdated_packed_refs_value_deletes_both_ "only one edit even though technically two places were changed" ); assert!( - store.try_find("newer-as-loose",)?.is_none(), + store.try_find("newer-as-loose")?.is_none(), "reference is deleted everywhere" ); Ok(()) diff --git a/gix-ref/tests/refs/file/worktree.rs b/gix-ref/tests/refs/file/worktree.rs index 321b7d17159..6606af9cc72 100644 --- a/gix-ref/tests/refs/file/worktree.rs +++ b/gix-ref/tests/refs/file/worktree.rs @@ -598,7 +598,7 @@ mod writable { { let unprefixed_name = "refs/heads/new"; let reference = store.find(unprefixed_name)?; - assert_eq!(reference.target.id(), new_id_main,); + assert_eq!(reference.target.id(), new_id_main); assert_eq!( reflog_for_name(&store, reference.name.as_ref(), &mut buf), vec![new_id_main.to_string()] diff --git a/gix-ref/tests/refs/namespace.rs b/gix-ref/tests/refs/namespace.rs index 8996f36adac..baaa4dc95d4 100644 --- a/gix-ref/tests/refs/namespace.rs +++ b/gix-ref/tests/refs/namespace.rs @@ -30,10 +30,10 @@ mod expand { #[test] fn backslashes_are_no_component_separators_and_invalid() { assert!(matches!( - gix_ref::namespace::expand("foo\\bar").expect_err("empty invalid"), + gix_ref::namespace::expand(r"foo\bar").expect_err("empty invalid"), gix_validate::reference::name::Error::Tag( gix_validate::tag::name::Error::InvalidByte{byte} - ) if byte == "\\" + ) if byte == r"\" )); } diff --git a/gix-refspec/tests/refspec/matching.rs b/gix-refspec/tests/refspec/matching.rs index 9fedf92d986..5f5383c5855 100644 --- a/gix-refspec/tests/refspec/matching.rs +++ b/gix-refspec/tests/refspec/matching.rs @@ -168,7 +168,7 @@ pub mod baseline { fixes: expected_fixes, } => { let (actual, actual_fixes) = actual.unwrap(); - assert_eq!(&actual_fixes, expected_fixes,); + assert_eq!(&actual_fixes, expected_fixes); (actual.mappings, expected) } }; diff --git a/gix-revision/tests/revision/describe/mod.rs b/gix-revision/tests/revision/describe/mod.rs index 003c84cebf8..e541c2fde4e 100644 --- a/gix-revision/tests/revision/describe/mod.rs +++ b/gix-revision/tests/revision/describe/mod.rs @@ -187,7 +187,7 @@ fn typical_usecases() -> crate::Result { }, |res, id| { let res = res?.expect("candidate found"); - assert_eq!(res.name, Some(name.clone()),); + assert_eq!(res.name, Some(name.clone())); assert_eq!(res.id, id); assert_eq!(res.depth, 1); assert_eq!(res.commits_seen, 2); @@ -236,7 +236,7 @@ fn shallow_yields_result_if_refs_are_available() -> crate::Result { }, |res, id| { let res = res?.expect("found candidate"); - assert_eq!(res.name, Some(name.clone()),); + assert_eq!(res.name, Some(name.clone())); assert_eq!(res.id, id); assert_eq!(res.depth, 1); assert_eq!(res.commits_seen, 2); diff --git a/gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs b/gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs index 42ff94f6213..d3d76468d5b 100644 --- a/gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs +++ b/gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs @@ -23,7 +23,7 @@ fn reflog_by_entry_for_current_branch() { let rec = parse(spec); assert!(rec.kind.is_none()); - assert_eq!(rec.find_ref[0], None,); + assert_eq!(rec.find_ref[0], None); assert_eq!( rec.prefix[0], None, "neither ref nor prefixes are set, straight to navigation" @@ -38,7 +38,7 @@ fn reflog_by_date_for_current_branch() { let rec = parse("@{1979-02-26 18:30:00}"); assert!(rec.kind.is_none()); - assert_eq!(rec.find_ref[0], None,); + assert_eq!(rec.find_ref[0], None); assert_eq!( rec.prefix[0], None, "neither ref nor prefixes are set, straight to navigation" @@ -52,7 +52,7 @@ fn reflog_by_unix_timestamp_for_current_branch() { let rec = parse("@{100000000}"); assert!(rec.kind.is_none()); - assert_eq!(rec.find_ref[0], None,); + assert_eq!(rec.find_ref[0], None); assert_eq!( rec.prefix[0], None, "neither ref nor prefixes are set, straight to navigation" @@ -104,7 +104,7 @@ fn reflog_by_date_for_given_ref_name() { assert!(rec.kind.is_none()); assert_eq!(rec.get_ref(0), expected_ref); - assert_eq!(rec.prefix[0], None,); + assert_eq!(rec.prefix[0], None); assert_eq!(rec.current_branch_reflog_entry[0], Some("42 +0030".to_string())); assert_eq!(rec.calls, 2, "first the ref, then the reflog entry"); } @@ -121,7 +121,7 @@ fn reflog_by_entry_for_given_ref_name() { assert!(rec.kind.is_none()); assert_eq!(rec.get_ref(0), expected_ref); - assert_eq!(rec.prefix[0], None,); + assert_eq!(rec.prefix[0], None); assert_eq!(rec.current_branch_reflog_entry[0], Some(expected_entry.to_string())); assert_eq!(rec.calls, 2, "first the ref, then the reflog entry"); } @@ -162,7 +162,7 @@ fn sibling_branch_for_branch_name() { let rec = parse(spec); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), ref_name,); + assert_eq!(rec.get_ref(0), ref_name); assert_eq!(rec.prefix[0], None, "neither ref nor prefix are explicitly set"); assert_eq!( rec.sibling_branch[0].as_deref(), @@ -200,7 +200,7 @@ fn nth_checked_out_branch() { let rec = parse(spec); assert!(rec.kind.is_none()); - assert_eq!(rec.find_ref[0], None,); + assert_eq!(rec.find_ref[0], None); assert_eq!( rec.prefix[0], None, "neither ref nor prefixes are set, straight to navigation" diff --git a/gix-revision/tests/revision/spec/parse/anchor/describe.rs b/gix-revision/tests/revision/spec/parse/anchor/describe.rs index 130d1fc5c0a..7e3c2ed4f45 100644 --- a/gix-revision/tests/revision/spec/parse/anchor/describe.rs +++ b/gix-revision/tests/revision/spec/parse/anchor/describe.rs @@ -81,7 +81,7 @@ fn full_format_with_dirty_suffix_is_recognized() { let rec = parse("cargo-smart-release-679-g3bee7fb-dirty"); assert!(rec.kind.is_none()); assert_eq!(rec.find_ref[0], None, "git does not see this as prefix, we do"); - assert_eq!(rec.prefix[0], Some(gix_hash::Prefix::from_hex("3bee7fb").unwrap()),); + assert_eq!(rec.prefix[0], Some(gix_hash::Prefix::from_hex("3bee7fb").unwrap())); assert_eq!(rec.prefix_hint[0], anchor_hint()); assert_eq!(rec.calls, 1); } @@ -91,7 +91,7 @@ fn partial_format_with_dirty_suffix_is_recognized() { let spec = "abcdef1-dirty"; let rec = parse(spec); assert!(rec.kind.is_none()); - assert_eq!(rec.find_ref[0], None,); + assert_eq!(rec.find_ref[0], None); assert_eq!( rec.prefix[0], Some(gix_hash::Prefix::from_hex("abcdef1").unwrap()), @@ -110,7 +110,7 @@ fn partial_format_lookalikes_are_never_considered() { let rec = parse(spec); assert!(rec.kind.is_none()); assert_eq!(rec.get_ref(0), spec); - assert_eq!(rec.prefix[0], None,); + assert_eq!(rec.prefix[0], None); assert_eq!(rec.calls, 1, "we don't even try the prefix"); } @@ -127,6 +127,6 @@ fn partial_format_with_dirty_suffix_lookalikes_are_treated_as_refs() { .unwrap(); assert!(rec.kind.is_none()); assert_eq!(rec.get_ref(0), spec); - assert_eq!(rec.prefix[0], None,); + assert_eq!(rec.prefix[0], None); assert_eq!(rec.calls, 2); } diff --git a/gix-revision/tests/revision/spec/parse/navigate/caret_symbol.rs b/gix-revision/tests/revision/spec/parse/navigate/caret_symbol.rs index 3b338ba601d..f1cf5236dfe 100644 --- a/gix-revision/tests/revision/spec/parse/navigate/caret_symbol.rs +++ b/gix-revision/tests/revision/spec/parse/navigate/caret_symbol.rs @@ -7,7 +7,7 @@ fn single_is_first_parent() { let rec = parse("@^"); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), "HEAD",); + assert_eq!(rec.get_ref(0), "HEAD"); assert_eq!(rec.prefix[0], None); assert_eq!(rec.traversal[0], Traversal::NthParent(1)); assert_eq!(rec.calls, 2); @@ -18,7 +18,7 @@ fn multiple_calls_stack() { let rec = parse("@^^^10^0^{tag}^020"); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), "HEAD",); + assert_eq!(rec.get_ref(0), "HEAD"); assert_eq!(rec.prefix[0], None); assert_eq!( rec.traversal, @@ -44,7 +44,7 @@ fn followed_by_zero_is_peeling_to_commit() { let rec = parse("@^0"); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), "HEAD",); + assert_eq!(rec.get_ref(0), "HEAD"); assert_eq!(rec.prefix[0], None); assert_eq!(rec.traversal.len(), 0, "traversals by parent are never zero"); assert_eq!( diff --git a/gix-revision/tests/revision/spec/parse/navigate/tilde_symbol.rs b/gix-revision/tests/revision/spec/parse/navigate/tilde_symbol.rs index f465b2afa55..ae1ba826cdc 100644 --- a/gix-revision/tests/revision/spec/parse/navigate/tilde_symbol.rs +++ b/gix-revision/tests/revision/spec/parse/navigate/tilde_symbol.rs @@ -13,7 +13,7 @@ fn single_is_first_ancestor() { let rec = parse("@~"); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), "HEAD",); + assert_eq!(rec.get_ref(0), "HEAD"); assert_eq!(rec.prefix[0], None); assert_eq!(rec.traversal[0], Traversal::NthAncestor(1)); assert_eq!(rec.calls, 2); @@ -24,7 +24,7 @@ fn followed_by_zero_is_no_op() { let rec = parse("@~0"); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), "HEAD",); + assert_eq!(rec.get_ref(0), "HEAD"); assert_eq!(rec.prefix[0], None); assert_eq!(rec.calls, 1); } @@ -34,7 +34,7 @@ fn multiple_calls_stack() { let rec = parse("@~~~10~0~020"); assert!(rec.kind.is_none()); - assert_eq!(rec.get_ref(0), "HEAD",); + assert_eq!(rec.get_ref(0), "HEAD"); assert_eq!(rec.prefix[0], None); assert_eq!( rec.traversal, diff --git a/gix-status/tests/status/index_as_worktree.rs b/gix-status/tests/status/index_as_worktree.rs index 4537fc3c7ae..9d70cfefa87 100644 --- a/gix-status/tests/status/index_as_worktree.rs +++ b/gix-status/tests/status/index_as_worktree.rs @@ -579,7 +579,7 @@ fn unchanged_despite_filter() { symlink_metadata_calls: 5, ..Default::default() }; - assert_eq!(actual_outcome, expected_outcome,); + assert_eq!(actual_outcome, expected_outcome); } #[test] @@ -754,7 +754,7 @@ fn modified() { ), ], ); - assert_eq!(actual_outcome, expected_outcome,); + assert_eq!(actual_outcome, expected_outcome); } #[test] diff --git a/gix-submodule/tests/file/baseline.rs b/gix-submodule/tests/file/baseline.rs index e1828c71149..8d03b89804f 100644 --- a/gix-submodule/tests/file/baseline.rs +++ b/gix-submodule/tests/file/baseline.rs @@ -43,7 +43,7 @@ fn common_values_and_names_by_path() -> crate::Result { v.dedup(); v }, - [".a/..c", "a/b", "a/d\\", "a\\e", "submodule"] + [".a/..c", "a/b", r"a/d\", r"a\e", "submodule"] .into_iter() .map(|n| n.as_bytes().as_bstr()) .collect::>(), diff --git a/gix-submodule/tests/file/mod.rs b/gix-submodule/tests/file/mod.rs index cecb7b759cc..c2b3612ee75 100644 --- a/gix-submodule/tests/file/mod.rs +++ b/gix-submodule/tests/file/mod.rs @@ -76,8 +76,8 @@ mod is_active_platform { ("submodule", false), ("a/b", false), (".a/..c", false), - ("a/d\\", false), - ("a\\e", false) + (r"a/d\", false), + (r"a\e", false) ] ); Ok(()) @@ -98,8 +98,8 @@ mod is_active_platform { ("submodule", false), ("a/b", false), (".a/..c", true), - ("a/d\\", false), - ("a\\e", false) + (r"a/d\", false), + (r"a\e", false) ] ); Ok(()) @@ -120,8 +120,8 @@ mod is_active_platform { ("submodule", false), ("a/b", false), (".a/..c", true), - ("a/d\\", false), - ("a\\e", false) + (r"a/d\", false), + (r"a\e", false) ] ); Ok(()) @@ -140,8 +140,8 @@ mod is_active_platform { ("submodule", true), ("a/b", false), (".a/..c", false), - ("a/d\\", false), - ("a\\e", false) + (r"a/d\", false), + (r"a\e", false) ] ); assert_eq!( @@ -154,8 +154,8 @@ mod is_active_platform { ("submodule", false), ("a/b", true), (".a/..c", true), - ("a/d\\", true), - ("a\\e", true) + (r"a/d\", true), + (r"a\e", true) ] ); Ok(()) @@ -183,9 +183,9 @@ mod path { fn validate_upon_retrieval() { assert!(matches!( submodule_path(if cfg!(windows) { - "c:\\\\hello" + r"c:\\hello" } else { - "/definitely/absolute\\\\" + r"/definitely/absolute\\" }), Error::Absolute { .. } )); diff --git a/gix-transport/src/client/blocking_io/ssh/tests.rs b/gix-transport/src/client/blocking_io/ssh/tests.rs index bb229a600c7..f1956e157a0 100644 --- a/gix-transport/src/client/blocking_io/ssh/tests.rs +++ b/gix-transport/src/client/blocking_io/ssh/tests.rs @@ -58,7 +58,7 @@ mod program_kind { "/bin/ssh", "/bin/SSH", #[cfg(windows)] - "c:\\bin\\ssh.exe", + r"c:\bin\ssh.exe", ] { assert_eq!( ProgramKind::from(OsStr::new(name_or_path)), diff --git a/gix-transport/src/client/git/mod.rs b/gix-transport/src/client/git/mod.rs index c62fc7c7ef4..c05ff6ba4eb 100644 --- a/gix-transport/src/client/git/mod.rs +++ b/gix-transport/src/client/git/mod.rs @@ -109,7 +109,7 @@ mod message { #[test] fn version_2_without_host_and_version() { assert_eq!( - git::message::connect(Service::UploadPack, Protocol::V2, b"hello\\world", None, &[]), + git::message::connect(Service::UploadPack, Protocol::V2, br"hello\world", None, &[]), "git-upload-pack hello\\world\0\0version=2\0" ); } @@ -132,7 +132,7 @@ mod message { git::message::connect( Service::UploadPack, Protocol::V1, - b"hello\\world", + br"hello\world", Some(&("host".into(), None)), &[] ), @@ -145,7 +145,7 @@ mod message { git::message::connect( Service::UploadPack, Protocol::V1, - b"hello\\world", + br"hello\world", Some(&("host".into(), None)), &[("key", Some("value")), ("value-only", None)] ), @@ -158,7 +158,7 @@ mod message { git::message::connect( Service::UploadPack, Protocol::V1, - b"hello\\world", + br"hello\world", Some(&("host".into(), Some(404))), &[] ), diff --git a/gix-transport/tests/client/blocking_io/http/mod.rs b/gix-transport/tests/client/blocking_io/http/mod.rs index e47cf980e4b..b5e0bc7fd90 100644 --- a/gix-transport/tests/client/blocking_io/http/mod.rs +++ b/gix-transport/tests/client/blocking_io/http/mod.rs @@ -123,7 +123,7 @@ fn http_will_use_pipelining() { } }); - let url = format!("http://{}:{}/reponame", &addr.ip().to_string(), &addr.port(),); + let url = format!("http://{}:{}/reponame", &addr.ip().to_string(), &addr.port()); let mut client = gix_transport::client::http::connect(url.try_into().expect("valid url"), gix_transport::Protocol::V2, false); match client.handshake(gix_transport::Service::UploadPack, &[]) { diff --git a/gix-url/tests/url/access.rs b/gix-url/tests/url/access.rs index de18a138ea8..70909918559 100644 --- a/gix-url/tests/url/access.rs +++ b/gix-url/tests/url/access.rs @@ -13,7 +13,7 @@ mod canonicalized { #[cfg(not(windows))] let url = gix_url::parse("/this/path/does/not/exist".into())?; #[cfg(windows)] - let url = gix_url::parse("C:\\non\\existing".into())?; + let url = gix_url::parse(r"C:\non\existing".into())?; assert_eq!(url.canonicalized(&std::env::current_dir()?)?, url); Ok(()) } diff --git a/gix-url/tests/url/expand_path.rs b/gix-url/tests/url/expand_path.rs index 32dcc0286c4..88ae4cbed35 100644 --- a/gix-url/tests/url/expand_path.rs +++ b/gix-url/tests/url/expand_path.rs @@ -5,7 +5,7 @@ use gix_url::{expand_path, expand_path::ForUser}; #[cfg(windows)] fn expected_path() -> std::path::PathBuf { - Path::new("C:\\UserProfiles\\byron\\hello\\git").into() + Path::new(r"C:\UserProfiles\byron\hello\git").into() } #[cfg(not(windows))] @@ -15,7 +15,7 @@ fn expected_path() -> std::path::PathBuf { #[cfg(windows)] fn user_home(name: &str) -> std::path::PathBuf { - Path::new("C:\\").join("UserProfiles").join(name) + Path::new(r"C:\").join("UserProfiles").join(name) } #[cfg(not(windows))] diff --git a/gix-url/tests/url/parse/file.rs b/gix-url/tests/url/parse/file.rs index b7d518cec02..60f436392b8 100644 --- a/gix-url/tests/url/parse/file.rs +++ b/gix-url/tests/url/parse/file.rs @@ -80,7 +80,7 @@ fn shortest_possible_absolute_path() -> crate::Result { fn shortest_possible_relative_path() -> crate::Result { assert_url_roundtrip("a", url_alternate(Scheme::File, None, None, None, b"a"))?; assert_url_roundtrip("../", url_alternate(Scheme::File, None, None, None, b"../"))?; - assert_url_roundtrip("..\\", url_alternate(Scheme::File, None, None, None, b"..\\"))?; + assert_url_roundtrip(r"..\", url_alternate(Scheme::File, None, None, None, br"..\"))?; assert_url_roundtrip("./", url_alternate(Scheme::File, None, None, None, b"./"))?; assert_url_roundtrip(".", url_alternate(Scheme::File, None, None, None, b"."))?; assert_url_roundtrip("..", url_alternate(Scheme::File, None, None, None, b".."))?; @@ -94,13 +94,13 @@ fn no_relative_paths_if_protocol() -> crate::Result { assert_url_roundtrip("file://a/", url(Scheme::File, None, "a", None, b"/"))?; if cfg!(windows) { assert_eq!( - gix_url::parse("file://.\\".into())?, - url(Scheme::File, None, ".", None, b"\\"), + gix_url::parse(r"file://.\".into())?, + url(Scheme::File, None, ".", None, br"\"), "we are just as none-sensical as git here due to special handling." ); } else { assert_matches::assert_matches!( - gix_url::parse("file://.\\".into()), + gix_url::parse(r"file://.\".into()), Err(gix_url::parse::Error::MissingRepositoryPath { .. }), "DEVIATION: on windows, this parses with git into something nonsensical Diag: url=file://./ Diag: protocol=file Diag: hostandport=./ Diag: path=//./" ); @@ -132,8 +132,8 @@ mod windows { #[test] fn reproduce_1063() -> crate::Result { - let input = "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmp.vIa4tyjv17"; - let url_input = "file://C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmp.vIa4tyjv17"; + let input = r"C:\Users\RUNNER~1\AppData\Local\Temp\tmp.vIa4tyjv17"; + let url_input = r"file://C:\Users\RUNNER~1\AppData\Local\Temp\tmp.vIa4tyjv17"; assert_url(url_input, url(Scheme::File, None, None, None, input.as_bytes()))?; assert_url(input, url_alternate(Scheme::File, None, None, None, input.as_bytes()))?; Ok(()) @@ -142,13 +142,13 @@ mod windows { #[test] fn url_from_absolute_path() -> crate::Result { assert_url( - url::Url::from_directory_path("c:\\users\\1") + url::Url::from_directory_path(r"c:\users\1") .expect("valid") .to_file_path() .expect("valid path") .to_string_lossy() .as_ref(), - url_alternate(Scheme::File, None, None, None, b"C:\\users\\1\\"), + url_alternate(Scheme::File, None, None, None, br"C:\users\1\"), )?; // A special hack to support URLs on windows that are prefixed with `/` even though absolute. let url = assert_url("file:///c:/users/2", url(Scheme::File, None, None, None, b"c:/users/2"))?; @@ -167,8 +167,8 @@ mod windows { #[test] fn file_path_with_backslashes_without_protocol() -> crate::Result { assert_url_roundtrip( - "x:\\path\\to\\git", - url_alternate(Scheme::File, None, None, None, b"x:\\path\\to\\git"), + r"x:\path\to\git", + url_alternate(Scheme::File, None, None, None, br"x:\path\to\git"), ) } @@ -211,8 +211,8 @@ mod unix { #[test] fn file_path_with_backslashes_without_protocol() -> crate::Result { assert_url_roundtrip( - "x:\\path\\to\\git", - url_alternate(Scheme::Ssh, None, "x", None, b"\\path\\to\\git"), + r"x:\path\to\git", + url_alternate(Scheme::Ssh, None, "x", None, br"\path\to\git"), ) } diff --git a/gix-validate/src/path.rs b/gix-validate/src/path.rs index 6321e403b18..51997b9be1e 100644 --- a/gix-validate/src/path.rs +++ b/gix-validate/src/path.rs @@ -8,13 +8,13 @@ pub mod component { pub enum Error { #[error("A path component must not be empty")] Empty, - #[error("Path separators like / or \\ are not allowed")] + #[error(r"Path separators like / or \ are not allowed")] PathSeparator, #[error("Windows path prefixes are not allowed")] WindowsPathPrefix, #[error("Windows device-names may have side-effects and are not allowed")] WindowsReservedName, - #[error("Trailing spaces or dots, and the following characters anywhere, are forbidden in Windows paths, along with non-printable ones: <>:\"|?*")] + #[error(r#"Trailing spaces or dots, and the following characters anywhere, are forbidden in Windows paths, along with non-printable ones: <>:"|?*"#)] WindowsIllegalCharacter, #[error("The .git name may never be used")] DotGitDir, @@ -79,7 +79,7 @@ pub fn component( return Err(component::Error::Empty); } if protect_windows { - if input.find_byteset(b"/\\").is_some() { + if input.find_byteset(br"/\").is_some() { return Err(component::Error::PathSeparator); } if input.chars().nth(1) == Some(':') { diff --git a/gix-validate/tests/reference/mod.rs b/gix-validate/tests/reference/mod.rs index 4055f551a3b..29c6e32401c 100644 --- a/gix-validate/tests/reference/mod.rs +++ b/gix-validate/tests/reference/mod.rs @@ -165,12 +165,12 @@ mod name_partial { ); mktest!( path_with_backslashes, - b"refs\\heads/name with spaces", + br"refs\heads/name with spaces", RefError::Tag(TagError::InvalidByte { .. }) ); mktests!( path_with_backslashes_san, - b"refs\\heads/name with spaces", + br"refs\heads/name with spaces", "refs-heads/name-with-spaces" ); } diff --git a/gix-validate/tests/submodule/mod.rs b/gix-validate/tests/submodule/mod.rs index 1532f0458c4..375895a17cd 100644 --- a/gix-validate/tests/submodule/mod.rs +++ b/gix-validate/tests/submodule/mod.rs @@ -6,7 +6,7 @@ fn valid() { gix_validate::submodule::name(name.into()).map(|_| ()) } - for valid_name in ["a/./b/..[", "..a/./b/", "..a\\./b\\", "你好"] { + for valid_name in ["a/./b/..[", "..a/./b/", r"..a\./b\", "你好"] { validate(valid_name).unwrap_or_else(|err| panic!("{valid_name} should be valid: {err:?}")); } } @@ -31,7 +31,7 @@ mod invalid { mktest!(parent_component_in_middle, b"hi/../ho", ParentComponent); mktest!(ends_with_parent_component, b"hi/ho/..", ParentComponent); mktest!(only_parent_component, b"..", ParentComponent); - mktest!(starts_with_parent_component_backslash, b"..\\", ParentComponent); - mktest!(parent_component_in_middle_backslash, b"hi\\..\\ho", ParentComponent); - mktest!(ends_with_parent_component_backslash, b"hi\\ho\\..", ParentComponent); + mktest!(starts_with_parent_component_backslash, br"..\", ParentComponent); + mktest!(parent_component_in_middle_backslash, br"hi\..\ho", ParentComponent); + mktest!(ends_with_parent_component_backslash, br"hi\ho\..", ParentComponent); } diff --git a/gix-validate/tests/tag/mod.rs b/gix-validate/tests/tag/mod.rs index 2d9608e438e..1654ada266a 100644 --- a/gix-validate/tests/tag/mod.rs +++ b/gix-validate/tests/tag/mod.rs @@ -140,8 +140,8 @@ mod name { mktests!(contains_questionmark_san, b"prefix?suffix", "prefix-suffix"); mktestb!(contains_open_bracket, b"prefix[suffix"); mktests!(contains_open_bracket_san, b"prefix[suffix", "prefix-suffix"); - mktestb!(contains_backslash, b"prefix\\suffix"); - mktests!(contains_backslash_san, b"prefix\\suffix", "prefix-suffix"); + mktestb!(contains_backslash, br"prefix\suffix"); + mktests!(contains_backslash_san, br"prefix\suffix", "prefix-suffix"); mktestb!(contains_circumflex, b"prefix^suffix"); mktests!(contains_circumflex_san, b"prefix^suffix", "prefix-suffix"); mktestb!(contains_tilde, b"prefix~suffix"); diff --git a/gix-worktree-state/tests/state/checkout.rs b/gix-worktree-state/tests/state/checkout.rs index f7fa8f2bb99..c45c19fb042 100644 --- a/gix-worktree-state/tests/state/checkout.rs +++ b/gix-worktree-state/tests/state/checkout.rs @@ -122,7 +122,7 @@ fn writes_through_symlinks_are_prevented_even_if_overwriting_is_allowed() { assert_eq!( stripped_prefix(&destination, &worktree_files), paths([ - if cfg!(windows) { "A-dir\\a" } else { "A-dir/a" }, + if cfg!(windows) { r"A-dir\a" } else { "A-dir/a" }, "A-file", "FAKE-DIR", "FAKE-FILE" @@ -407,7 +407,7 @@ fn keep_going_collects_results() { if cfg!(unix) { "dir/sub-dir/symlink" } else { - "dir\\sub-dir\\symlink" + r"dir\sub-dir\symlink" }, "empty", "executable", diff --git a/gix/src/remote/connection/fetch/update_refs/tests.rs b/gix/src/remote/connection/fetch/update_refs/tests.rs index b2fd25d0934..e0fa1034e56 100644 --- a/gix/src/remote/connection/fetch/update_refs/tests.rs +++ b/gix/src/remote/connection/fetch/update_refs/tests.rs @@ -778,7 +778,7 @@ mod update { } _ => unreachable!("only updates"), } - assert_eq!(edit.name.as_bstr(), "refs/remotes/origin/new-HEAD",); + assert_eq!(edit.name.as_bstr(), "refs/remotes/origin/new-HEAD"); } #[test] diff --git a/gix/tests/gix/config/tree.rs b/gix/tests/gix/config/tree.rs index 6605d1e4f08..c4fb8b8226c 100644 --- a/gix/tests/gix/config/tree.rs +++ b/gix/tests/gix/config/tree.rs @@ -463,12 +463,12 @@ mod core { #[test] fn log_all_ref_updates() -> crate::Result { assert_eq!( - Core::LOG_ALL_REF_UPDATES.try_into_ref_updates(Some(Ok(true)),)?, + Core::LOG_ALL_REF_UPDATES.try_into_ref_updates(Some(Ok(true)))?, Some(gix_ref::store::WriteReflog::Normal) ); assert!(Core::LOG_ALL_REF_UPDATES.validate("true".into()).is_ok()); assert_eq!( - Core::LOG_ALL_REF_UPDATES.try_into_ref_updates(Some(Ok(false)),)?, + Core::LOG_ALL_REF_UPDATES.try_into_ref_updates(Some(Ok(false)))?, Some(gix_ref::store::WriteReflog::Disable) ); assert!(Core::LOG_ALL_REF_UPDATES.validate("0".into()).is_ok()); diff --git a/gix/tests/gix/reference/mod.rs b/gix/tests/gix/reference/mod.rs index f5120f56ccf..1ef725bd511 100644 --- a/gix/tests/gix/reference/mod.rs +++ b/gix/tests/gix/reference/mod.rs @@ -131,7 +131,7 @@ mod find { let obj = tag_ref.peel_to_kind(gix::object::Kind::Tree)?; assert!(obj.kind.is_tree()); - assert_eq!(obj.id, hex_to_id("4b825dc642cb6eb9a060e54bf8d69288fbee4904"),); + assert_eq!(obj.id, hex_to_id("4b825dc642cb6eb9a060e54bf8d69288fbee4904")); assert_eq!(tag_ref.peel_to_tree()?.id, obj.id); assert_eq!( diff --git a/gix/tests/gix/repository/config/transport_options.rs b/gix/tests/gix/repository/config/transport_options.rs index 6d5328936f0..b411a19b776 100644 --- a/gix/tests/gix/repository/config/transport_options.rs +++ b/gix/tests/gix/repository/config/transport_options.rs @@ -67,7 +67,7 @@ mod http { assert_eq!(follow_redirects, FollowRedirects::All); assert_eq!(low_speed_limit_bytes_per_second, 5120); assert_eq!(low_speed_time_seconds, 10); - assert_eq!(proxy.as_deref(), Some("http://localhost:9090"),); + assert_eq!(proxy.as_deref(), Some("http://localhost:9090")); assert!( proxy_authenticate.is_none(), "no username means no authentication required" diff --git a/gix/tests/gix/repository/object.rs b/gix/tests/gix/repository/object.rs index ca21a20b425..54878ccf4f2 100644 --- a/gix/tests/gix/repository/object.rs +++ b/gix/tests/gix/repository/object.rs @@ -280,7 +280,7 @@ mod write_object { }; assert_eq!( repo.write_object(commit).unwrap_err().to_string(), - "Signature name or email must not contain '<', '>' or \\n", + r"Signature name or email must not contain '<', '>' or \n", "the actor is invalid so triggers an error when persisting it" ); Ok(()) diff --git a/gix/tests/gix/repository/remote.rs b/gix/tests/gix/repository/remote.rs index 84ae6723407..9c2923dd270 100644 --- a/gix/tests/gix/repository/remote.rs +++ b/gix/tests/gix/repository/remote.rs @@ -197,7 +197,7 @@ mod find_remote { let expected_push_url: BString = baseline.next().expect("push").into(); let remote = repo.find_remote("origin")?; - assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), expected_fetch_url,); + assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), expected_fetch_url); { let actual_push_url = remote.url(Direction::Push).unwrap().to_bstring(); assert_ne!( diff --git a/gix/tests/gix/revision/spec/from_bytes/traverse.rs b/gix/tests/gix/revision/spec/from_bytes/traverse.rs index ed3ebb71618..345a72bbb6e 100644 --- a/gix/tests/gix/revision/spec/from_bytes/traverse.rs +++ b/gix/tests/gix/revision/spec/from_bytes/traverse.rs @@ -39,7 +39,7 @@ fn freestanding_double_or_triple_dot_defaults_to_head_refs() -> crate::Result { parse_spec_no_baseline("..", &repo)?, // git can't communicate what it does here parse_spec("@..@", &repo)?, ); - assert_eq!(parse_spec("...", &repo)?, parse_spec("@...@", &repo)?,); + assert_eq!(parse_spec("...", &repo)?, parse_spec("@...@", &repo)?); Ok(()) } @@ -50,7 +50,7 @@ fn parent() { parse_spec("a^1", &repo).unwrap(), Spec::from_id(hex_to_id("5b3f9e24965d0b28780b7ce5daf2b5b7f7e0459f").attach(&repo)) ); - assert_eq!(parse_spec("a", &repo).unwrap(), parse_spec("a^0", &repo).unwrap(),); + assert_eq!(parse_spec("a", &repo).unwrap(), parse_spec("a^0", &repo).unwrap()); assert_eq!( parse_spec("a^42", &repo).unwrap_err().to_string(), "Commit 55e825e has 2 parents and parent number 42 is out of range" @@ -64,7 +64,7 @@ fn ancestors() { parse_spec("a~1", &repo).unwrap(), Spec::from_id(hex_to_id("5b3f9e24965d0b28780b7ce5daf2b5b7f7e0459f").attach(&repo)) ); - assert_eq!(parse_spec("a", &repo).unwrap(), parse_spec("a~0", &repo).unwrap(),); + assert_eq!(parse_spec("a", &repo).unwrap(), parse_spec("a~0", &repo).unwrap()); assert_eq!( parse_spec("a~3", &repo).unwrap(), Spec::from_id(hex_to_id("9f9eac6bd1cd4b4cc6a494f044b28c985a22972b").attach(&repo))