1
1
mirror of https://github.com/casey/just.git synced 2024-11-22 10:26:26 +03:00

Misc fixes (#1700)

This commit is contained in:
Yuri Astrakhan 2023-10-16 23:07:09 -04:00 committed by GitHub
parent 55da31a8a5
commit be7f161554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 30 additions and 33 deletions

View File

@ -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

View File

@ -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}"),
}
}
}

View File

@ -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(|| {

View File

@ -337,9 +337,9 @@ fn sha256_file(context: &FunctionContext, path: &str) -> Result<String, String>
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}"))
}

View File

@ -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;

View File

@ -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(())

View File

@ -48,7 +48,7 @@ pub(crate) use {
rc::Rc,
str::{self, Chars},
sync::{Mutex, MutexGuard},
usize, vec,
vec,
},
{
camino::Utf8Path,

View File

@ -15,7 +15,7 @@ pub(crate) fn output(mut command: Command) -> Result<String, OutputError> {
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') {

View File

@ -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}"),

View File

@ -33,7 +33,7 @@ impl PlatformInterface for Platform {
fs::set_permissions(path, permissions)
}
fn signal_from_exit_status(exit_status: process::ExitStatus) -> Option<i32> {
fn signal_from_exit_status(exit_status: ExitStatus) -> Option<i32> {
use std::os::unix::process::ExitStatusExt;
exit_status.signal()
}

View File

@ -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<i32>;
fn signal_from_exit_status(exit_status: ExitStatus) -> Option<i32>;
/// Translate a path from a "native" path to a path the interpreter expects
fn convert_native_path(working_directory: &Path, path: &Path) -> Result<String, String>;

View File

@ -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()
}

View File

@ -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!(),
};

View File

@ -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 {

View File

@ -56,7 +56,7 @@ impl<'src> Thunk<'src> {
name: Name<'src>,
mut arguments: Vec<Expression<'src>>,
) -> 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(),
})),

View File

@ -40,6 +40,6 @@ impl Verbosity {
}
pub const fn default() -> Self {
Self::Taciturn
Taciturn
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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: {},

View File

@ -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"))

View File

@ -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()

View File

@ -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 > * {