From 47f7bed677a6b72e873712de8f3988ea891710e4 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 8 May 2024 22:45:06 -0400 Subject: chore: enable clippy::print_stdout and clippy::print_stderr (#23732) 1. Generally we should prefer to use the `log` crate. 2. I very often accidentally commit `eprintln`s. When we should use `println` or `eprintln`, it's not too bad to be a bit more verbose and ignore the lint rule. --- cli/tools/repl/editor.rs | 2 +- cli/tools/repl/mod.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'cli/tools/repl') diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index 9cb3cd1c2..dbc9bce70 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -490,7 +490,7 @@ impl ReplEditor { } self.errored_on_history_save.store(true, Relaxed); - eprintln!("Unable to save history file: {e}"); + log::warn!("Unable to save history file: {}", e); } } } diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs index 8847bee52..c29e29e71 100644 --- a/cli/tools/repl/mod.rs +++ b/cli/tools/repl/mod.rs @@ -40,6 +40,7 @@ struct Repl { message_handler: RustylineSyncMessageHandler, } +#[allow(clippy::print_stdout)] impl Repl { async fn run(&mut self) -> Result<(), AnyError> { loop { @@ -61,7 +62,7 @@ impl Repl { break; } - println!("{output}"); + println!("{}", output); } Err(ReadlineError::Interrupted) => { if self.editor.should_exit_on_interrupt() { @@ -75,7 +76,7 @@ impl Repl { break; } Err(err) => { - println!("Error: {err:?}"); + println!("Error: {:?}", err); break; } } @@ -85,6 +86,7 @@ impl Repl { } } +#[allow(clippy::print_stdout)] async fn read_line_and_poll( repl_session: &mut ReplSession, message_handler: &mut RustylineSyncMessageHandler, @@ -152,6 +154,7 @@ async fn read_eval_file( Ok(file.into_text_decoded()?.source) } +#[allow(clippy::print_stdout)] pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result { let factory = CliFactory::from_flags(flags)?; let cli_options = factory.cli_options(); -- cgit v1.2.3