From be7f161554eb168becb09f2ac75756c817bb3670 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 16 Oct 2023 23:07:09 -0400 Subject: [PATCH] Misc fixes (#1700) --- justfile | 2 +- src/config.rs | 6 +++--- src/evaluator.rs | 6 +++--- src/function.rs | 4 ++-- src/interrupt_handler.rs | 4 ++-- src/lexer.rs | 2 +- src/lib.rs | 2 +- src/output.rs | 2 +- src/output_error.rs | 4 ++-- src/platform.rs | 2 +- src/platform_interface.rs | 2 +- src/recipe.rs | 2 +- src/subcommand.rs | 2 +- src/testing.rs | 2 +- src/thunk.rs | 2 +- src/verbosity.rs | 2 +- tests/choose.rs | 4 ++-- tests/edit.rs | 2 +- tests/search.rs | 2 +- tests/shell.rs | 2 +- tests/tempdir.rs | 2 +- www/index.css | 5 +---- 22 files changed, 30 insertions(+), 33 deletions(-) diff --git a/justfile b/justfile index f25e719..2518a92 100755 --- a/justfile +++ b/justfile @@ -15,7 +15,7 @@ test: ci: build-book cargo test --all - cargo clippy --all --all-targets + cargo clippy --all --all-targets -- --deny warnings cargo fmt --all -- --check ./bin/forbid cargo update --locked --package just diff --git a/src/config.rs b/src/config.rs index 1e6e86d..682229b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -616,7 +616,7 @@ impl Config { }; let unstable = matches.is_present(arg::UNSTABLE) - || std::env::var_os("JUST_UNSTABLE") + || env::var_os("JUST_UNSTABLE") .map(|val| !(val == "false" || val == "0" || val.is_empty())) .unwrap_or_default(); @@ -662,7 +662,7 @@ impl Config { pub(crate) fn run(self, loader: &Loader) -> Result<(), Error> { if let Err(error) = InterruptHandler::install(self.verbosity) { - warn!("Failed to set CTRL-C handler: {}", error); + warn!("Failed to set CTRL-C handler: {error}"); } self.subcommand.execute(&self, loader) @@ -761,7 +761,7 @@ mod tests { match Config::from_matches(&matches).expect_err("config parsing succeeded") { $error => { $($check)? } - other => panic!("Unexpected config error: {}", other), + other => panic!("Unexpected config error: {other}"), } } } diff --git a/src/evaluator.rs b/src/evaluator.rs index 40db30f..ac70f6b 100644 --- a/src/evaluator.rs +++ b/src/evaluator.rs @@ -210,12 +210,12 @@ impl<'src, 'run> Evaluator<'src, 'run> { cmd.export(self.settings, self.dotenv, &self.scope); - cmd.stdin(process::Stdio::inherit()); + cmd.stdin(Stdio::inherit()); cmd.stderr(if self.config.verbosity.quiet() { - process::Stdio::null() + Stdio::null() } else { - process::Stdio::inherit() + Stdio::inherit() }); InterruptHandler::guard(|| { diff --git a/src/function.rs b/src/function.rs index 81481a9..84c21c0 100644 --- a/src/function.rs +++ b/src/function.rs @@ -337,9 +337,9 @@ fn sha256_file(context: &FunctionContext, path: &str) -> Result let justpath = context.search.working_directory.join(path); let mut hasher = Sha256::new(); let mut file = fs::File::open(&justpath) - .map_err(|err| format!("Failed to open file at `{:?}`: {err}", &justpath.to_str()))?; + .map_err(|err| format!("Failed to open file at `{:?}`: {err}", justpath.to_str()))?; std::io::copy(&mut file, &mut hasher) - .map_err(|err| format!("Failed to read file at `{:?}`: {err}", &justpath.to_str()))?; + .map_err(|err| format!("Failed to read file at `{:?}`: {err}", justpath.to_str()))?; let hash = hasher.finalize(); Ok(format!("{hash:x}")) } diff --git a/src/interrupt_handler.rs b/src/interrupt_handler.rs index 40e31be..1105954 100644 --- a/src/interrupt_handler.rs +++ b/src/interrupt_handler.rs @@ -26,7 +26,7 @@ impl InterruptHandler { } .color_display(Color::auto().stderr()) ); - std::process::exit(EXIT_FAILURE); + process::exit(EXIT_FAILURE); } } } @@ -69,7 +69,7 @@ impl InterruptHandler { .color_display(Color::auto().stderr()) ); } - std::process::exit(EXIT_FAILURE); + process::exit(EXIT_FAILURE); } self.blocks -= 1; diff --git a/src/lexer.rs b/src/lexer.rs index aaa3bbd..b175a97 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -729,7 +729,7 @@ impl<'src> Lexer<'src> { } self.token(Whitespace); } else if let Some(character) = self.next { - return Err(self.error(CompileErrorKind::InvalidEscapeSequence { character })); + return Err(self.error(InvalidEscapeSequence { character })); } Ok(()) diff --git a/src/lib.rs b/src/lib.rs index db8f554..fa4b4e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,7 +48,7 @@ pub(crate) use { rc::Rc, str::{self, Chars}, sync::{Mutex, MutexGuard}, - usize, vec, + vec, }, { camino::Utf8Path, diff --git a/src/output.rs b/src/output.rs index f447ccc..af8ec6a 100644 --- a/src/output.rs +++ b/src/output.rs @@ -15,7 +15,7 @@ pub(crate) fn output(mut command: Command) -> Result { None => OutputError::Unknown, }); } - match std::str::from_utf8(&output.stdout) { + match str::from_utf8(&output.stdout) { Err(error) => Err(OutputError::Utf8(error)), Ok(utf8) => Ok( if utf8.ends_with('\n') { diff --git a/src/output_error.rs b/src/output_error.rs index 1b92ed4..797d3a1 100644 --- a/src/output_error.rs +++ b/src/output_error.rs @@ -11,11 +11,11 @@ pub(crate) enum OutputError { /// Unknown failure Unknown, /// Stdout not UTF-8 - Utf8(std::str::Utf8Error), + Utf8(str::Utf8Error), } impl Display for OutputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { match *self { Self::Code(code) => write!(f, "Process exited with status code {code}"), Self::Io(ref io_error) => write!(f, "Error executing process: {io_error}"), diff --git a/src/platform.rs b/src/platform.rs index 9fd9b16..36be7fc 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -33,7 +33,7 @@ impl PlatformInterface for Platform { fs::set_permissions(path, permissions) } - fn signal_from_exit_status(exit_status: process::ExitStatus) -> Option { + fn signal_from_exit_status(exit_status: ExitStatus) -> Option { use std::os::unix::process::ExitStatusExt; exit_status.signal() } diff --git a/src/platform_interface.rs b/src/platform_interface.rs index 0028e09..4a984ff 100644 --- a/src/platform_interface.rs +++ b/src/platform_interface.rs @@ -14,7 +14,7 @@ pub(crate) trait PlatformInterface { /// Extract the signal from a process exit status, if it was terminated by a /// signal - fn signal_from_exit_status(exit_status: process::ExitStatus) -> Option; + fn signal_from_exit_status(exit_status: ExitStatus) -> Option; /// Translate a path from a "native" path to a path the interpreter expects fn convert_native_path(working_directory: &Path, path: &Path) -> Result; diff --git a/src/recipe.rs b/src/recipe.rs index c1fa22f..407115d 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -49,7 +49,7 @@ impl<'src, D> Recipe<'src, D> { pub(crate) fn max_arguments(&self) -> usize { if self.parameters.iter().any(|p| p.kind.is_variadic()) { - usize::max_value() - 1 + usize::MAX - 1 } else { self.parameters.len() } diff --git a/src/subcommand.rs b/src/subcommand.rs index 2d8c465..b58cc9a 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -99,7 +99,7 @@ impl Subcommand { let starting_path = match &config.search_config { SearchConfig::FromInvocationDirectory => config.invocation_directory.clone(), SearchConfig::FromSearchDirectory { search_directory } => { - std::env::current_dir().unwrap().join(search_directory) + env::current_dir().unwrap().join(search_directory) } _ => unreachable!(), }; diff --git a/src/testing.rs b/src/testing.rs index 4f3a913..4085721 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -108,7 +108,7 @@ macro_rules! run_error { ).expect_err("Expected runtime error") { $error => $check other => { - panic!("Unexpected run error: {:?}", other); + panic!("Unexpected run error: {other:?}"); } } } else { diff --git a/src/thunk.rs b/src/thunk.rs index 353e3c9..8792973 100644 --- a/src/thunk.rs +++ b/src/thunk.rs @@ -56,7 +56,7 @@ impl<'src> Thunk<'src> { name: Name<'src>, mut arguments: Vec>, ) -> CompileResult<'src, Thunk<'src>> { - crate::function::get(name.lexeme()).map_or( + function::get(name.lexeme()).map_or( Err(name.error(CompileErrorKind::UnknownFunction { function: name.lexeme(), })), diff --git a/src/verbosity.rs b/src/verbosity.rs index 562ae9d..0461a50 100644 --- a/src/verbosity.rs +++ b/src/verbosity.rs @@ -40,6 +40,6 @@ impl Verbosity { } pub const fn default() -> Self { - Self::Taciturn + Taciturn } } diff --git a/tests/choose.rs b/tests/choose.rs index 153a704..ff22425 100644 --- a/tests/choose.rs +++ b/tests/choose.rs @@ -101,7 +101,7 @@ fn skip_recipes_that_require_arguments() { #[test] fn no_choosable_recipes() { - crate::test::Test::new() + Test::new() .arg("--choose") .justfile( " @@ -200,7 +200,7 @@ fn default() { }; let cat = which("cat").unwrap(); - let fzf = tmp.path().join(format!("fzf{}", env::consts::EXE_SUFFIX)); + let fzf = tmp.path().join(format!("fzf{EXE_SUFFIX}")); #[cfg(unix)] std::os::unix::fs::symlink(cat, fzf).unwrap(); diff --git a/tests/edit.rs b/tests/edit.rs index 75010d3..38f59db 100644 --- a/tests/edit.rs +++ b/tests/edit.rs @@ -116,7 +116,7 @@ fn editor_precedence() { assert_stdout(&output, JUSTFILE); let cat = which("cat").unwrap(); - let vim = tmp.path().join(format!("vim{}", EXE_SUFFIX)); + let vim = tmp.path().join(format!("vim{EXE_SUFFIX}")); #[cfg(unix)] std::os::unix::fs::symlink(cat, vim).unwrap(); diff --git a/tests/search.rs b/tests/search.rs index 67fa7f2..daac5bf 100644 --- a/tests/search.rs +++ b/tests/search.rs @@ -120,7 +120,7 @@ fn test_downwards_multiple_path_argument() { } #[test] -fn single_downards() { +fn single_downwards() { let tmp = temptree! { justfile: "default:\n\techo ok", child: {}, diff --git a/tests/shell.rs b/tests/shell.rs index 30396e4..a55fb10 100644 --- a/tests/shell.rs +++ b/tests/shell.rs @@ -23,7 +23,7 @@ fn flag() { #[cfg(not(windows))] { let permissions = std::os::unix::fs::PermissionsExt::from_mode(0o700); - std::fs::set_permissions(&shell, permissions).unwrap(); + fs::set_permissions(&shell, permissions).unwrap(); } let output = Command::new(executable_path("just")) diff --git a/tests/tempdir.rs b/tests/tempdir.rs index 72e5021..2e48c9c 100644 --- a/tests/tempdir.rs +++ b/tests/tempdir.rs @@ -1,6 +1,6 @@ use super::*; -pub(crate) fn tempdir() -> tempfile::TempDir { +pub(crate) fn tempdir() -> TempDir { tempfile::Builder::new() .prefix("just-test-tempdir") .tempdir() diff --git a/www/index.css b/www/index.css index a14147e..161afa3 100644 --- a/www/index.css +++ b/www/index.css @@ -33,10 +33,7 @@ a:hover { body { display: grid; grid-template-columns: repeat(4, 1fr); - margin-bottom: var(--margin-vertical); - margin-left: var(--margin-horizontal); - margin-right: var(--margin-horizontal); - margin-top: var(--margin-vertical); + margin: var(--margin-vertical) var(--margin-horizontal); } body > * {