diff --git a/crates/brioche-core/benches/input.rs b/crates/brioche-core/benches/input.rs index 121f6dd..3fa489f 100644 --- a/crates/brioche-core/benches/input.rs +++ b/crates/brioche-core/benches/input.rs @@ -197,7 +197,7 @@ fn bench_input_with_shared_ancestor_resources(bencher: divan::Bencher, removal: let mut file = std::fs::File::create(input_path.join(format!("file{i}.txt"))).unwrap(); - writeln!(&mut file, "{i}",).unwrap(); + writeln!(&mut file, "{i}").unwrap(); brioche_pack::inject_pack( &mut file, diff --git a/crates/brioche-core/src/process_events.rs b/crates/brioche-core/src/process_events.rs index 13f7c62..c5196af 100644 --- a/crates/brioche-core/src/process_events.rs +++ b/crates/brioche-core/src/process_events.rs @@ -32,7 +32,7 @@ pub fn create_process_output_events( elapsed: Duration, stream: ProcessStream, content: &[u8], -) -> impl Iterator + '_ { +) -> impl Iterator { content .chunks(ProcessOutputEvent::MAX_CONTENT_LENGTH) .map(move |chunk| ProcessOutputEvent { diff --git a/crates/brioche-core/src/project.rs b/crates/brioche-core/src/project.rs index a19a7dd..25a9351 100644 --- a/crates/brioche-core/src/project.rs +++ b/crates/brioche-core/src/project.rs @@ -481,7 +481,7 @@ impl ProjectsInner { Ok(workspace) } - fn local_paths(&self, project_hash: ProjectHash) -> Option + '_> { + fn local_paths(&self, project_hash: ProjectHash) -> Option> { let paths = self.projects_to_paths.get(&project_hash)?; Some(paths.iter().map(|path| &**path)) } @@ -551,7 +551,7 @@ impl ProjectsInner { pub fn project_module_paths( &self, project_hash: ProjectHash, - ) -> anyhow::Result + '_> { + ) -> anyhow::Result> { let project = self.project(project_hash)?; let project_root = self .projects_to_paths @@ -587,7 +587,7 @@ impl ProjectsInner { pub fn project_module_specifiers( &self, project_hash: ProjectHash, - ) -> anyhow::Result + '_> + ) -> anyhow::Result> { let module_paths = self.project_module_paths(project_hash)?; let module_specifiers = module_paths diff --git a/crates/brioche-core/src/recipe.rs b/crates/brioche-core/src/recipe.rs index fd0cf91..1981dc8 100644 --- a/crates/brioche-core/src/recipe.rs +++ b/crates/brioche-core/src/recipe.rs @@ -830,11 +830,9 @@ impl Directory { artifact: Option, ) -> Result, DirectoryError> { match path_components { - [] => { - return Err(DirectoryError::EmptyPath { - path: full_path.into(), - }); - } + [] => Err(DirectoryError::EmptyPath { + path: full_path.into(), + }), [filename] => { let replaced_hash = match artifact { Some(artifact) => { diff --git a/crates/brioche-core/src/utils.rs b/crates/brioche-core/src/utils.rs index b46c184..289303b 100644 --- a/crates/brioche-core/src/utils.rs +++ b/crates/brioche-core/src/utils.rs @@ -113,9 +113,9 @@ mod tests { #[test] fn test_display_duration_basic() { - assert_eq!(display_duration_ms(0).to_string(), "0.00s",); - assert_eq!(display_duration_ms(10).to_string(), "0.01s",); - assert_eq!(display_duration_ms(99).to_string(), "0.10s",); + assert_eq!(display_duration_ms(0).to_string(), "0.00s"); + assert_eq!(display_duration_ms(10).to_string(), "0.01s"); + assert_eq!(display_duration_ms(99).to_string(), "0.10s"); assert_eq!(display_duration_ms(1_010).to_string(), "1.01s"); assert_eq!(display_duration_ms(59_990).to_string(), "59.99s"); assert_eq!(display_duration_ms(59_999).to_string(), "60.00s"); diff --git a/crates/brioche-core/src/utils/output_buffer.rs b/crates/brioche-core/src/utils/output_buffer.rs index 161e41b..a9fe26d 100644 --- a/crates/brioche-core/src/utils/output_buffer.rs +++ b/crates/brioche-core/src/utils/output_buffer.rs @@ -380,7 +380,7 @@ mod tests { output.append(job_stream(1, Stdout), "a\nb\nc"); assert_eq!(output.total_bytes, 5); - assert_eq!(output.contents, [(job_stream(1, Stdout), "a\nb\n".into())],); + assert_eq!(output.contents, [(job_stream(1, Stdout), "a\nb\n".into())]); assert_eq!( output.partial_append, BTreeMap::from_iter([(job_stream(1, Stdout), "c".into())]) @@ -659,7 +659,7 @@ mod tests { output.append(job_stream(1, Stdout), "a\nb\nc"); assert_eq!(output.total_bytes, 5); - assert_eq!(output.contents, [(job_stream(1, Stdout), "a\nb\n".into())],); + assert_eq!(output.contents, [(job_stream(1, Stdout), "a\nb\n".into())]); assert_eq!( output.partial_append, BTreeMap::from_iter([(job_stream(1, Stdout), "c".into())]), diff --git a/crates/brioche-core/tests/bake_process.rs b/crates/brioche-core/tests/bake_process.rs index b030b16..99f7f9d 100644 --- a/crates/brioche-core/tests/bake_process.rs +++ b/crates/brioche-core/tests/bake_process.rs @@ -51,7 +51,7 @@ async fn get(brioche: &brioche_core::Brioche, dir: &Directory, path: impl AsRef< let path = bstr::BStr::new(path.as_ref()); try_get(brioche, dir, &path) .await - .with_context(|| format!("error getting context for path {path:?}",)) + .with_context(|| format!("error getting context for path {path:?}")) .unwrap() .with_context(|| format!("no artifact found for path {path:?}")) .unwrap() @@ -1421,7 +1421,7 @@ fn test_bake_process_output_with_shared_resources() -> anyhow::Result<()> { false ) ), - ("bar", brioche_test_support::symlink("bar_target"),), + ("bar", brioche_test_support::symlink("bar_target")), ( "bar_target", brioche_test_support::file( @@ -1465,7 +1465,7 @@ fn test_bake_process_output_with_shared_resources() -> anyhow::Result<()> { false ) ), - ("bar", brioche_test_support::symlink("bar_target"),), + ("bar", brioche_test_support::symlink("bar_target")), ( "bar_target", brioche_test_support::file( diff --git a/crates/brioche/src/check.rs b/crates/brioche/src/check.rs index 51c924b..f346be2 100644 --- a/crates/brioche/src/check.rs +++ b/crates/brioche/src/check.rs @@ -126,7 +126,7 @@ pub async fn check( } else { None }; - let project_name = project_name.as_ref().map(|name| name.as_str()); + let project_name = project_name.map(String::as_str); let result = run_check( &reporter, @@ -181,17 +181,15 @@ async fn run_check( match result { Ok(()) => { - if let Some(project_name) = project_name { - reporter.emit(superconsole::Lines::from_multiline_string( - &format!("No errors found in {project_name} 🎉",), - superconsole::style::ContentStyle::default(), - )); - } else { - reporter.emit(superconsole::Lines::from_multiline_string( - "No errors found in projects 🎉", - superconsole::style::ContentStyle::default(), - )); - } + let format_string = project_name.map_or_else( + || "No errors found in projects 🎉".to_string(), + |project_name| format!("No errors found in {project_name} 🎉"), + ); + + reporter.emit(superconsole::Lines::from_multiline_string( + &format_string, + superconsole::style::ContentStyle::default(), + )); Ok(true) } diff --git a/crates/brioche/src/format.rs b/crates/brioche/src/format.rs index fd98e5e..6f413cd 100644 --- a/crates/brioche/src/format.rs +++ b/crates/brioche/src/format.rs @@ -116,7 +116,7 @@ async fn run_format( Ok(true) } else if files.is_empty() { reporter.emit(superconsole::Lines::from_multiline_string( - &format!("All files of {project_name} are formatted",), + &format!("All files of {project_name} are formatted"), superconsole::style::ContentStyle::default(), )); diff --git a/crates/brioche/src/install.rs b/crates/brioche/src/install.rs index 25600db..e09ad06 100644 --- a/crates/brioche/src/install.rs +++ b/crates/brioche/src/install.rs @@ -231,7 +231,7 @@ async fn run_install( }; reporter.emit(superconsole::Lines::from_multiline_string( - &format!("Build finished, completed {jobs_message} in {elapsed}",), + &format!("Build finished, completed {jobs_message} in {elapsed}"), superconsole::style::ContentStyle::default(), )); diff --git a/crates/brioche/src/main.rs b/crates/brioche/src/main.rs index 220703e..eb280b3 100644 --- a/crates/brioche/src/main.rs +++ b/crates/brioche/src/main.rs @@ -339,23 +339,18 @@ fn consolidate_result( ) { match result { Err(err) => { - if let Some(project_name) = project_name { - reporter.emit(superconsole::Lines::from_multiline_string( - &format!("Error occurred with {project_name}: {err}"), - superconsole::style::ContentStyle { - foreground_color: Some(superconsole::style::Color::Red), - ..superconsole::style::ContentStyle::default() - }, - )); - } else { - reporter.emit(superconsole::Lines::from_multiline_string( - &format!("Error occurred in project: {err}"), - superconsole::style::ContentStyle { - foreground_color: Some(superconsole::style::Color::Red), - ..superconsole::style::ContentStyle::default() - }, - )); - } + let format_string = project_name.map_or_else( + || format!("Error occurred in project: {err}"), + |project_name| format!("Error occurred with {project_name}: {err}"), + ); + + reporter.emit(superconsole::Lines::from_multiline_string( + &format_string, + superconsole::style::ContentStyle { + foreground_color: Some(superconsole::style::Color::Red), + ..superconsole::style::ContentStyle::default() + }, + )); *error_result = Some(()); } diff --git a/crates/brioche/src/publish.rs b/crates/brioche/src/publish.rs index 2b5fd84..5a9bd30 100644 --- a/crates/brioche/src/publish.rs +++ b/crates/brioche/src/publish.rs @@ -111,7 +111,7 @@ async fn run_publish( match result { Ok(()) => { reporter.emit(superconsole::Lines::from_multiline_string( - &format!("No errors found in {project_name} 🎉",), + &format!("No errors found in {project_name} 🎉"), superconsole::style::ContentStyle::default(), )); }