diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index c066512b09ee3..ab23f69d17141 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -534,7 +534,6 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult< Ok(MacroInput { fmtstr, args, is_direct_literal }) } -fn make_format_args( - ecx: &mut ExtCtxt<'_>, - input: MacroInput, - append_newline: bool, -) -> Result { +fn make_format_args(ecx: &mut ExtCtxt<'_>, input: MacroInput) -> Result { let msg = "format argument must be a string literal"; let unexpanded_fmt_span = input.fmtstr.span; let MacroInput { fmtstr: efmt, mut args, is_direct_literal } = input; let (fmt_str, fmt_style, fmt_span) = match expr_to_spanned_string(ecx, efmt, msg) { - Ok(mut fmt) if append_newline => { - fmt.0 = Symbol::intern(&format!("{}\n", fmt.0)); - fmt - } Ok(fmt) => fmt, Err(err) => { if let Some((mut err, suggested)) = err { @@ -196,13 +188,7 @@ fn make_format_args( let fmt_str = fmt_str.as_str(); // for the suggestions below let fmt_snippet = ecx.source_map().span_to_snippet(unexpanded_fmt_span).ok(); - let mut parser = parse::Parser::new( - fmt_str, - str_style, - fmt_snippet, - append_newline, - parse::ParseMode::Format, - ); + let mut parser = parse::Parser::new(fmt_str, str_style, fmt_snippet, parse::ParseMode::Format); let mut pieces = Vec::new(); while let Some(piece) = parser.next() { @@ -831,16 +817,15 @@ fn report_invalid_references( e.emit(); } -fn expand_format_args_impl<'cx>( +pub fn expand_format_args<'cx>( ecx: &'cx mut ExtCtxt<'_>, mut sp: Span, tts: TokenStream, - nl: bool, ) -> Box { sp = ecx.with_def_site_ctxt(sp); match parse_args(ecx, sp, tts) { Ok(input) => { - if let Ok(format_args) = make_format_args(ecx, input, nl) { + if let Ok(format_args) = make_format_args(ecx, input) { MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(P(format_args)))) } else { MacEager::expr(DummyResult::raw_expr(sp, true)) @@ -852,19 +837,3 @@ fn expand_format_args_impl<'cx>( } } } - -pub fn expand_format_args<'cx>( - ecx: &'cx mut ExtCtxt<'_>, - sp: Span, - tts: TokenStream, -) -> Box { - expand_format_args_impl(ecx, sp, tts, false) -} - -pub fn expand_format_args_nl<'cx>( - ecx: &'cx mut ExtCtxt<'_>, - sp: Span, - tts: TokenStream, -) -> Box { - expand_format_args_impl(ecx, sp, tts, true) -} diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 8f86ef44aa3ab..a8df940498fed 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -83,7 +83,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { concat: concat::expand_concat, env: env::expand_env, file: source_util::expand_file, - format_args_nl: format::expand_format_args_nl, format_args: format::expand_format_args, const_format_args: format::expand_format_args, global_asm: asm::expand_global_asm, diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 5bb1abfd2ec97..bc45261976c57 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -244,7 +244,7 @@ fn check_panic_str<'tcx>( Err(_) => (None, None), }; - let mut fmt_parser = Parser::new(fmt, style, snippet.clone(), false, ParseMode::Format); + let mut fmt_parser = Parser::new(fmt, style, snippet.clone(), ParseMode::Format); let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count(); if n_arguments > 0 && fmt_parser.errors.is_empty() { diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 7de84db211ed8..ee6b00192971c 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -233,8 +233,6 @@ pub struct Parser<'a> { width_map: Vec, /// Span of the last opening brace seen, used for error reporting last_opening_brace: Option, - /// Whether the source string is comes from `println!` as opposed to `format!` or `print!` - append_newline: bool, /// Whether this formatting string was written directly in the source. This controls whether we /// can use spans to refer into it and give better error messages. /// N.B: This does _not_ control whether implicit argument captures can be used. @@ -322,7 +320,6 @@ impl<'a> Parser<'a> { s: &'a str, style: Option, snippet: Option, - append_newline: bool, mode: ParseMode, ) -> Parser<'a> { let input_string_kind = find_width_map_from_snippet(s, snippet, style); @@ -341,7 +338,6 @@ impl<'a> Parser<'a> { arg_places: vec![], width_map, last_opening_brace: None, - append_newline, is_source_literal, cur_line_start: 0, line_spans: vec![], @@ -485,8 +481,7 @@ impl<'a> Parser<'a> { } else { let description = format!("expected `{c:?}` but string was terminated"); // point at closing `"` - let pos = self.input.len() - if self.append_newline { 1 } else { 0 }; - let pos = self.to_span_index(pos); + let pos = self.to_span_index(self.input.len()); if c == '}' { let label = format!("expected `{c:?}`"); let (note, secondary_label) = if c == '}' { diff --git a/compiler/rustc_parse_format/src/tests.rs b/compiler/rustc_parse_format/src/tests.rs index 45314e2fb5500..93002fe59d5f4 100644 --- a/compiler/rustc_parse_format/src/tests.rs +++ b/compiler/rustc_parse_format/src/tests.rs @@ -2,7 +2,7 @@ use super::*; #[track_caller] fn same(fmt: &'static str, p: &[Piece<'static>]) { - let parser = Parser::new(fmt, None, None, false, ParseMode::Format); + let parser = Parser::new(fmt, None, None, ParseMode::Format); assert_eq!(parser.collect::>>(), p); } @@ -24,7 +24,7 @@ fn fmtdflt() -> FormatSpec<'static> { } fn musterr(s: &str) { - let mut p = Parser::new(s, None, None, false, ParseMode::Format); + let mut p = Parser::new(s, None, None, ParseMode::Format); p.next(); assert!(!p.errors.is_empty()); } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 5bfbff76b4ffc..3e16a9a39cfca 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -734,7 +734,6 @@ symbols! { format_args, format_args_capture, format_args_macro, - format_args_nl, format_argument, format_arguments, format_count, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 88525e1b720af..7fa98fa3baa3e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -576,7 +576,7 @@ impl<'tcx> OnUnimplementedFormatString { let trait_name = tcx.item_name(trait_def_id); let generics = tcx.generics_of(item_def_id); let s = self.0.as_str(); - let parser = Parser::new(s, None, None, false, ParseMode::Format); + let parser = Parser::new(s, None, None, ParseMode::Format); let mut result = Ok(()); for token in parser { match token { @@ -650,7 +650,7 @@ impl<'tcx> OnUnimplementedFormatString { let empty_string = String::new(); let s = self.0.as_str(); - let parser = Parser::new(s, None, None, false, ParseMode::Format); + let parser = Parser::new(s, None, None, ParseMode::Format); let item_context = (options.get(&sym::ItemContext)).unwrap_or(&empty_string); parser .map(|p| match p { diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 7c93c93b4a019..4ea7632ffa16b 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -549,13 +549,12 @@ macro_rules! write { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "writeln_macro")] -#[allow_internal_unstable(format_args_nl)] macro_rules! writeln { ($dst:expr $(,)?) => { $crate::write!($dst, "\n") }; ($dst:expr, $($arg:tt)*) => { - $dst.write_fmt($crate::format_args_nl!($($arg)*)) + $dst.write_fmt($crate::format_args!("{}\n", $crate::format_args!($($arg)*))) }; } @@ -893,21 +892,6 @@ pub(crate) mod builtin { ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }}; } - /// Same as [`format_args`], but adds a newline in the end. - #[unstable( - feature = "format_args_nl", - issue = "none", - reason = "`format_args_nl` is only for internal \ - language use and is subject to change" - )] - #[allow_internal_unstable(fmt_internals)] - #[rustc_builtin_macro] - #[macro_export] - macro_rules! format_args_nl { - ($fmt:expr) => {{ /* compiler built-in */ }}; - ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }}; - } - /// Inspects an environment variable at compile time. /// /// This macro will expand to the value of the named environment variable at diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 10525a16f3a66..b1968242692c7 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -55,9 +55,8 @@ pub use crate::hash::macros::Hash; #[allow(deprecated)] #[doc(no_inline)] pub use crate::{ - assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args, - format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env, - stringify, trace_macros, + assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args, include, + include_bytes, include_str, line, log_syntax, module_path, option_env, stringify, trace_macros, }; #[unstable( diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 318a46d1b637e..b7a7d138b4aed 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -343,7 +343,6 @@ #![feature(core_panic)] #![feature(custom_test_frameworks)] #![feature(edition_panic)] -#![feature(format_args_nl)] #![feature(get_many_mut)] #![feature(lazy_cell)] #![feature(log_syntax)] @@ -621,8 +620,8 @@ pub use core::{ #[allow(deprecated)] pub use core::{ assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, - env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, - module_path, option_env, stringify, trace_macros, + env, file, format_args, include, include_bytes, include_str, line, log_syntax, module_path, + option_env, stringify, trace_macros, }; #[unstable( diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs index fcc5cfafd808d..281faeb43e68d 100644 --- a/library/std/src/macros.rs +++ b/library/std/src/macros.rs @@ -128,13 +128,13 @@ macro_rules! print { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "println_macro")] -#[allow_internal_unstable(print_internals, format_args_nl)] +#[allow_internal_unstable(print_internals)] macro_rules! println { () => { $crate::print!("\n") }; ($($arg:tt)*) => {{ - $crate::io::_print($crate::format_args_nl!($($arg)*)); + $crate::io::_print($crate::format_args!("{}\n", $crate::format_args!($($arg)*))); }}; } @@ -200,13 +200,13 @@ macro_rules! eprint { #[macro_export] #[stable(feature = "eprint", since = "1.19.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "eprintln_macro")] -#[allow_internal_unstable(print_internals, format_args_nl)] +#[allow_internal_unstable(print_internals)] macro_rules! eprintln { () => { $crate::eprint!("\n") }; ($($arg:tt)*) => {{ - $crate::io::_eprint($crate::format_args_nl!($($arg)*)); + $crate::io::_eprint($crate::format_args!("{}\n", $crate::format_args!($($arg)*))); }}; } diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 7a7a773763559..598e8884c2fc0 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -39,9 +39,9 @@ pub use crate::result::Result::{self, Err, Ok}; #[allow(deprecated)] #[doc(no_inline)] pub use core::prelude::v1::{ - assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args, - format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env, - stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, + assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args, include, + include_bytes, include_str, line, log_syntax, module_path, option_env, stringify, trace_macros, + Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, }; #[unstable( diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 0ab72f7ea7a6d..57cf875030d5c 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2266,7 +2266,7 @@ impl Termination for Result { match self { Ok(val) => val.report(), Err(err) => { - io::attempt_print_to_stderr(format_args_nl!("Error: {err:?}")); + io::attempt_print_to_stderr(format_args!("Error: {err:?}\n")); ExitCode::FAILURE } } diff --git a/src/tools/clippy/clippy_utils/src/macros.rs b/src/tools/clippy/clippy_utils/src/macros.rs index 62d388a5ece8d..e3324364b82b5 100644 --- a/src/tools/clippy/clippy_utils/src/macros.rs +++ b/src/tools/clippy/clippy_utils/src/macros.rs @@ -391,7 +391,7 @@ pub fn find_format_args(cx: &LateContext<'_>, start: &Expr<'_>, expn_id: ExpnId, if ctxt.outer_expn().is_descendant_of(expn_id) { if macro_backtrace(expr.span) .map(|macro_call| cx.tcx.item_name(macro_call.def_id)) - .any(|name| matches!(name, sym::const_format_args | sym::format_args | sym::format_args_nl)) + .any(|name| matches!(name, sym::const_format_args | sym::format_args)) { ControlFlow::Break(expr) } else { diff --git a/src/tools/clippy/tests/ui/explicit_write.fixed b/src/tools/clippy/tests/ui/explicit_write.fixed index 213485bc221b8..b52ce86dd172d 100644 --- a/src/tools/clippy/tests/ui/explicit_write.fixed +++ b/src/tools/clippy/tests/ui/explicit_write.fixed @@ -23,22 +23,22 @@ fn main() { use std::io::Write; print!("test"); eprint!("test"); - println!("test"); - eprintln!("test"); + println!("{}\n", $crate::format_args!($($arg)*)); + eprintln!("{}\n", $crate::format_args!($($arg)*)); print!("test"); eprint!("test"); // including newlines - println!("test\ntest"); - eprintln!("test\ntest"); + println!("{}\n", $crate::format_args!($($arg)*)); + eprintln!("{}\n", $crate::format_args!($($arg)*)); let value = 1; - eprintln!("with {}", value); - eprintln!("with {} {}", 2, value); - eprintln!("with {value}"); - eprintln!("macro arg {}", one!()); + eprintln!("{}\n", $crate::format_args!($($arg)*)); + eprintln!("{}\n", $crate::format_args!($($arg)*)); + eprintln!("{}\n", $crate::format_args!($($arg)*)); + eprintln!("{}\n", $crate::format_args!($($arg)*)); let width = 2; - eprintln!("{:w$}", value, w = width); + eprintln!("{}\n", $crate::format_args!($($arg)*)); } // these should not warn, different destination { diff --git a/src/tools/clippy/tests/ui/explicit_write.stderr b/src/tools/clippy/tests/ui/explicit_write.stderr index 457e9c6271809..dced05e59033c 100644 --- a/src/tools/clippy/tests/ui/explicit_write.stderr +++ b/src/tools/clippy/tests/ui/explicit_write.stderr @@ -16,13 +16,13 @@ error: use of `writeln!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:26:9 | LL | writeln!(std::io::stdout(), "test").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test")` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:27:9 | LL | writeln!(std::io::stderr(), "test").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test")` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: use of `stdout().write_fmt(...).unwrap()` --> $DIR/explicit_write.rs:28:9 @@ -40,43 +40,43 @@ error: use of `writeln!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:32:9 | LL | writeln!(std::io::stdout(), "test/ntest").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test/ntest")` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:33:9 | LL | writeln!(std::io::stderr(), "test/ntest").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test/ntest")` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:36:9 | LL | writeln!(std::io::stderr(), "with {}", value).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {}", value)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:37:9 | LL | writeln!(std::io::stderr(), "with {} {}", 2, value).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {} {}", 2, value)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:38:9 | LL | writeln!(std::io::stderr(), "with {value}").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {value}")` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:39:9 | LL | writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:41:9 | LL | writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{:w$}", value, w = width)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{}/n", $crate::format_args!($($arg)*))` error: aborting due to 13 previous errors diff --git a/src/tools/clippy/tests/ui/format_args.fixed b/src/tools/clippy/tests/ui/format_args.fixed index ea38368613570..d9bf97016ef7c 100644 --- a/src/tools/clippy/tests/ui/format_args.fixed +++ b/src/tools/clippy/tests/ui/format_args.fixed @@ -83,27 +83,27 @@ fn main() { let _ = writeln!( stdout(), "error: something failed at {}", - Location::caller() + Location::caller().to_string() ); print!("error: something failed at {}", Location::caller()); - println!("error: something failed at {}", Location::caller()); + println!("error: something failed at {}", Location::caller().to_string()); eprint!("error: something failed at {}", Location::caller()); - eprintln!("error: something failed at {}", Location::caller()); + eprintln!("error: something failed at {}", Location::caller().to_string()); let _ = format_args!("error: something failed at {}", Location::caller()); assert!(true, "error: something failed at {}", Location::caller()); assert_eq!(0, 0, "error: something failed at {}", Location::caller()); assert_ne!(0, 0, "error: something failed at {}", Location::caller()); panic!("error: something failed at {}", Location::caller()); - println!("{}", *X(1)); - println!("{}", ***Y(&X(1))); - println!("{}", Z(1)); - println!("{}", **x); - println!("{}", ***x_ref); + println!("{}", X(1).to_string()); + println!("{}", Y(&X(1)).to_string()); + println!("{}", Z(1).to_string()); + println!("{}", x.to_string()); + println!("{}", x_ref.to_string()); // https://github.com/rust-lang/rust-clippy/issues/7903 - println!("{foo}{bar}", foo = "foo", bar = "bar"); - println!("{foo}{bar}", foo = "foo", bar = "bar"); - println!("{foo}{bar}", bar = "bar", foo = "foo"); - println!("{foo}{bar}", bar = "bar", foo = "foo"); + println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); + println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); + println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); + println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); // negative tests println!("error: something failed at {}", Somewhere.to_string()); @@ -158,7 +158,7 @@ mod issue_9256 { fn print_substring(original: &str) { assert!(original.len() > 10); - println!("{}", &original[..10]); + println!("{}", original[..10].to_string()); } fn main() { diff --git a/src/tools/clippy/tests/ui/format_args.stderr b/src/tools/clippy/tests/ui/format_args.stderr index f1832b970198a..0c90ae05e3482 100644 --- a/src/tools/clippy/tests/ui/format_args.stderr +++ b/src/tools/clippy/tests/ui/format_args.stderr @@ -12,36 +12,18 @@ error: `to_string` applied to a type that implements `Display` in `write!` args LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `writeln!` args - --> $DIR/format_args.rs:86:27 - | -LL | Location::caller().to_string() - | ^^^^^^^^^^^^ help: remove this - error: `to_string` applied to a type that implements `Display` in `print!` args --> $DIR/format_args.rs:88:63 | LL | print!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:89:65 - | -LL | println!("error: something failed at {}", Location::caller().to_string()); - | ^^^^^^^^^^^^ help: remove this - error: `to_string` applied to a type that implements `Display` in `eprint!` args --> $DIR/format_args.rs:90:64 | LL | eprint!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `eprintln!` args - --> $DIR/format_args.rs:91:66 - | -LL | eprintln!("error: something failed at {}", Location::caller().to_string()); - | ^^^^^^^^^^^^ help: remove this - error: `to_string` applied to a type that implements `Display` in `format_args!` args --> $DIR/format_args.rs:92:77 | @@ -72,60 +54,6 @@ error: `to_string` applied to a type that implements `Display` in `panic!` args LL | panic!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:97:20 - | -LL | println!("{}", X(1).to_string()); - | ^^^^^^^^^^^^^^^^ help: use this: `*X(1)` - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:98:20 - | -LL | println!("{}", Y(&X(1)).to_string()); - | ^^^^^^^^^^^^^^^^^^^^ help: use this: `***Y(&X(1))` - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:99:24 - | -LL | println!("{}", Z(1).to_string()); - | ^^^^^^^^^^^^ help: remove this - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:100:20 - | -LL | println!("{}", x.to_string()); - | ^^^^^^^^^^^^^ help: use this: `**x` - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:101:20 - | -LL | println!("{}", x_ref.to_string()); - | ^^^^^^^^^^^^^^^^^ help: use this: `***x_ref` - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:103:39 - | -LL | println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); - | ^^^^^^^^^^^^ help: remove this - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:104:52 - | -LL | println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); - | ^^^^^^^^^^^^ help: remove this - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:105:39 - | -LL | println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); - | ^^^^^^^^^^^^ help: remove this - -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:106:52 - | -LL | println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); - | ^^^^^^^^^^^^ help: remove this - error: `to_string` applied to a type that implements `Display` in `print!` args --> $DIR/format_args.rs:118:37 | @@ -144,11 +72,5 @@ error: `to_string` applied to a type that implements `Display` in `format!` args LL | let x = format!("{} {}", a, b.to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:161:24 - | -LL | println!("{}", original[..10].to_string()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use this: `&original[..10]` - -error: aborting due to 25 previous errors +error: aborting due to 12 previous errors diff --git a/src/tools/clippy/tests/ui/format_args_unfixable.stderr b/src/tools/clippy/tests/ui/format_args_unfixable.stderr index c1be48c3b7269..05c56d35b2845 100644 --- a/src/tools/clippy/tests/ui/format_args_unfixable.stderr +++ b/src/tools/clippy/tests/ui/format_args_unfixable.stderr @@ -1,67 +1,3 @@ -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:26:5 - | -LL | println!("error: {}", format!("something failed at {}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - = note: `-D clippy::format-in-format-args` implied by `-D warnings` - -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:27:5 - | -LL | println!("{}: {}", error, format!("something failed at {}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:28:5 - | -LL | println!("{:?}: {}", error, format!("something failed at {}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:29:5 - | -LL | println!("{{}}: {}", format!("something failed at {}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:30:5 - | -LL | println!(r#"error: "{}""#, format!("something failed at {}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:31:5 - | -LL | println!("error: {}", format!(r#"something failed at "{}""#, Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - -error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:32:5 - | -LL | println!("error: {}", format!("something failed at {} {0}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `println!(..)` call - = help: or consider changing `format!` to `format_args!` - error: `format!` in `format!` args --> $DIR/format_args_unfixable.rs:33:13 | @@ -70,6 +6,7 @@ LL | let _ = format!("error: {}", format!("something failed at {}", Location | = help: combine the `format!(..)` arguments with the outer `format!(..)` call = help: or consider changing `format!` to `format_args!` + = note: `-D clippy::format-in-format-args` implied by `-D warnings` error: `format!` in `write!` args --> $DIR/format_args_unfixable.rs:34:13 @@ -85,20 +22,6 @@ LL | | ); = help: combine the `format!(..)` arguments with the outer `write!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `writeln!` args - --> $DIR/format_args_unfixable.rs:39:13 - | -LL | let _ = writeln!( - | _____________^ -LL | | stdout(), -LL | | "error: {}", -LL | | format!("something failed at {}", Location::caller()) -LL | | ); - | |_____^ - | - = help: combine the `format!(..)` arguments with the outer `writeln!(..)` call - = help: or consider changing `format!` to `format_args!` - error: `format!` in `print!` args --> $DIR/format_args_unfixable.rs:44:5 | @@ -117,15 +40,6 @@ LL | eprint!("error: {}", format!("something failed at {}", Location::caller = help: combine the `format!(..)` arguments with the outer `eprint!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `eprintln!` args - --> $DIR/format_args_unfixable.rs:46:5 - | -LL | eprintln!("error: {}", format!("something failed at {}", Location::caller())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: combine the `format!(..)` arguments with the outer `eprintln!(..)` call - = help: or consider changing `format!` to `format_args!` - error: `format!` in `format_args!` args --> $DIR/format_args_unfixable.rs:47:13 | @@ -171,5 +85,5 @@ LL | panic!("error: {}", format!("something failed at {}", Location::caller( = help: combine the `format!(..)` arguments with the outer `panic!(..)` call = help: or consider changing `format!` to `format_args!` -error: aborting due to 18 previous errors +error: aborting due to 9 previous errors diff --git a/src/tools/clippy/tests/ui/print_literal.stderr b/src/tools/clippy/tests/ui/print_literal.stderr index 6404dacdafa56..bcb503a32d00b 100644 --- a/src/tools/clippy/tests/ui/print_literal.stderr +++ b/src/tools/clippy/tests/ui/print_literal.stderr @@ -11,137 +11,5 @@ LL - print!("Hello {}", "world"); LL + print!("Hello world"); | -error: literal with an empty format string - --> $DIR/print_literal.rs:28:36 - | -LL | println!("Hello {} {}", world, "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("Hello {} {}", world, "world"); -LL + println!("Hello {} world", world); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:29:26 - | -LL | println!("Hello {}", "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("Hello {}", "world"); -LL + println!("Hello world"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:30:26 - | -LL | println!("{} {:.4}", "a literal", 5); - | ^^^^^^^^^^^ - | -help: try this - | -LL - println!("{} {:.4}", "a literal", 5); -LL + println!("a literal {:.4}", 5); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:35:25 - | -LL | println!("{0} {1}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{0} {1}", "hello", "world"); -LL + println!("hello {1}", "world"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:35:34 - | -LL | println!("{0} {1}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{0} {1}", "hello", "world"); -LL + println!("{0} world", "hello"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:36:34 - | -LL | println!("{1} {0}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{1} {0}", "hello", "world"); -LL + println!("world {0}", "hello"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:36:25 - | -LL | println!("{1} {0}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{1} {0}", "hello", "world"); -LL + println!("{1} hello", "world"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:39:35 - | -LL | println!("{foo} {bar}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{foo} {bar}", foo = "hello", bar = "world"); -LL + println!("hello {bar}", bar = "world"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:39:50 - | -LL | println!("{foo} {bar}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{foo} {bar}", foo = "hello", bar = "world"); -LL + println!("{foo} world", foo = "hello"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:40:50 - | -LL | println!("{bar} {foo}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{bar} {foo}", foo = "hello", bar = "world"); -LL + println!("world {foo}", foo = "hello"); - | - -error: literal with an empty format string - --> $DIR/print_literal.rs:40:35 - | -LL | println!("{bar} {foo}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - println!("{bar} {foo}", foo = "hello", bar = "world"); -LL + println!("{bar} hello", bar = "world"); - | - -error: aborting due to 12 previous errors +error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/println_empty_string.fixed b/src/tools/clippy/tests/ui/println_empty_string.fixed index abf951ae22d64..fd86e2543cc1d 100644 --- a/src/tools/clippy/tests/ui/println_empty_string.fixed +++ b/src/tools/clippy/tests/ui/println_empty_string.fixed @@ -3,16 +3,16 @@ fn main() { println!(); - println!(); + println!(""); match "a" { - _ => println!(), + _ => println!(""), } eprintln!(); - eprintln!(); + eprintln!(""); match "a" { - _ => eprintln!(), + _ => eprintln!(""), } } diff --git a/src/tools/clippy/tests/ui/uninlined_format_args.fixed b/src/tools/clippy/tests/ui/uninlined_format_args.fixed index e25d123dd51f1..f733fe9b79830 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args.fixed +++ b/src/tools/clippy/tests/ui/uninlined_format_args.fixed @@ -37,77 +37,80 @@ fn tester(fn_arg: i32) { // let _ = ' '; // <- this is a single tab character let _: &[u8; 3] = b" "; // <- - println!("val='{local_i32}'"); - println!("val='{local_i32}'"); // 3 spaces - println!("val='{local_i32}'"); // tab - println!("val='{local_i32}'"); // space+tab - println!("val='{local_i32}'"); // tab+space + println!("val='{}'", local_i32); + println!("val='{ }'", local_i32); // 3 spaces + println!("val='{ }'", local_i32); // tab + println!("val='{ }'", local_i32); // space+tab + println!("val='{ }'", local_i32); // tab+space println!( - "val='{local_i32}'" + "val='{ + }'", + local_i32 ); - println!("{local_i32}"); - println!("{fn_arg}"); - println!("{local_i32:?}"); - println!("{local_i32:#?}"); - println!("{local_i32:4}"); - println!("{local_i32:04}"); - println!("{local_i32:<3}"); - println!("{local_i32:#010x}"); - println!("{local_f64:.1}"); + println!("{}", local_i32); + println!("{}", fn_arg); + println!("{:?}", local_i32); + println!("{:#?}", local_i32); + println!("{:4}", local_i32); + println!("{:04}", local_i32); + println!("{:<3}", local_i32); + println!("{:#010x}", local_i32); + println!("{:.1}", local_f64); println!("Hello {} is {:.*}", "x", local_i32, local_f64); println!("Hello {} is {:.*}", local_i32, 5, local_f64); println!("Hello {} is {2:.*}", local_i32, 5, local_f64); - println!("{local_i32} {local_f64}"); + println!("{} {}", local_i32, local_f64); println!("{}, {}", local_i32, local_opt.unwrap()); - println!("{val}"); - println!("{val}"); + println!("{}", val); + println!("{}", v = val); println!("{} {1}", local_i32, 42); - println!("val='{local_i32}'"); - println!("val='{local_i32}'"); - println!("val='{local_i32}'"); - println!("val='{fn_arg}'"); - println!("{local_i32}"); - println!("{local_i32:?}"); - println!("{local_i32:#?}"); - println!("{local_i32:04}"); - println!("{local_i32:<3}"); - println!("{local_i32:#010x}"); - println!("{local_f64:.1}"); - println!("{local_i32} {local_i32}"); - println!("{local_f64} {local_i32} {local_i32} {local_f64}"); - println!("{local_i32} {local_f64}"); - println!("{local_f64} {local_i32}"); - println!("{local_f64} {local_i32} {local_f64} {local_i32}"); + println!("val='{\t }'", local_i32); + println!("val='{\n }'", local_i32); + println!("val='{local_i32}'", local_i32 = local_i32); + println!("val='{local_i32}'", local_i32 = fn_arg); + println!("{0}", local_i32); + println!("{0:?}", local_i32); + println!("{0:#?}", local_i32); + println!("{0:04}", local_i32); + println!("{0:<3}", local_i32); + println!("{0:#010x}", local_i32); + println!("{0:.1}", local_f64); + println!("{0} {0}", local_i32); + println!("{1} {} {0} {}", local_i32, local_f64); + println!("{0} {1}", local_i32, local_f64); + println!("{1} {0}", local_i32, local_f64); + println!("{1} {0} {1} {0}", local_i32, local_f64); println!("{1} {0}", "str", local_i32); - println!("{local_i32}"); - println!("{local_i32:width$}"); - println!("{local_i32:width$}"); - println!("{local_i32:.prec$}"); - println!("{local_i32:.prec$}"); - println!("{val:val$}"); - println!("{val:val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{val:val$.val$}"); - println!("{width:width$}"); - println!("{local_i32:width$}"); - println!("{width:width$}"); - println!("{local_i32:width$}"); - println!("{prec:.prec$}"); - println!("{local_i32:.prec$}"); - println!("{prec:.prec$}"); - println!("{local_i32:.prec$}"); - println!("{width:width$.prec$}"); - println!("{width:width$.prec$}"); - println!("{local_f64:width$.prec$}"); - println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); + println!("{v}", v = local_i32); + println!("{local_i32:0$}", width); + println!("{local_i32:w$}", w = width); + println!("{local_i32:.0$}", prec); + println!("{local_i32:.p$}", p = prec); + println!("{:0$}", v = val); + println!("{0:0$}", v = val); + println!("{:0$.0$}", v = val); + println!("{0:0$.0$}", v = val); + println!("{0:0$.v$}", v = val); + println!("{0:v$.0$}", v = val); + println!("{v:0$.0$}", v = val); + println!("{v:v$.0$}", v = val); + println!("{v:0$.v$}", v = val); + println!("{v:v$.v$}", v = val); + println!("{:0$}", width); + println!("{:1$}", local_i32, width); + println!("{:w$}", w = width); + println!("{:w$}", local_i32, w = width); + println!("{:.0$}", prec); + println!("{:.1$}", local_i32, prec); + println!("{:.p$}", p = prec); + println!("{:.p$}", local_i32, p = prec); + println!("{:0$.1$}", width, prec); + println!("{:0$.w$}", width, w = prec); + println!("{:1$.2$}", local_f64, width, prec); + println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); println!( - "{local_i32:width$.prec$} {local_i32:prec$.width$} {width:local_i32$.prec$} {width:prec$.local_i32$} {prec:local_i32$.width$} {prec:width$.local_i32$}", + "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$}", + local_i32, width, prec, ); println!( "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$} {3}", @@ -116,9 +119,9 @@ fn tester(fn_arg: i32) { prec, 1 + 2 ); - println!("Width = {local_i32}, value with width = {local_f64:local_i32$}"); - println!("{local_i32:width$.prec$}"); - println!("{width:width$.prec$}"); + println!("Width = {}, value with width = {:0$}", local_i32, local_f64); + println!("{:w$.p$}", local_i32, w = width, p = prec); + println!("{:w$.p$}", w = width, p = prec); println!("{}", format!("{}", local_i32)); my_println!("{}", local_i32); my_println_args!("{}", local_i32); @@ -138,9 +141,11 @@ fn tester(fn_arg: i32) { println!(no_param_str!(), local_i32); println!( - "{val}", + "{}", + // comment with a comma , in it + val, ); - println!("{val}"); + println!("{}", /* comment with a comma , in it */ val); println!(with_span!("{0} {1}" "{1} {0}"), local_i32, local_f64); println!("{}", with_span!(span val)); @@ -172,7 +177,7 @@ fn _under_msrv() { #[clippy::msrv = "1.58"] fn _meets_msrv() { let local_i32 = 1; - println!("expand='{local_i32}'"); + println!("expand='{}'", local_i32); } fn _do_not_fire() { diff --git a/src/tools/clippy/tests/ui/uninlined_format_args.stderr b/src/tools/clippy/tests/ui/uninlined_format_args.stderr index dc4af6ef42ecd..ec4eb3b3a1e40 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args.stderr +++ b/src/tools/clippy/tests/ui/uninlined_format_args.stderr @@ -1,807 +1,10 @@ -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:40:5 - | -LL | println!("val='{}'", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::uninlined-format-args` implied by `-D warnings` -help: change this to - | -LL - println!("val='{}'", local_i32); -LL + println!("val='{local_i32}'"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:41:5 - | -LL | println!("val='{ }'", local_i32); // 3 spaces - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{ }'", local_i32); // 3 spaces -LL + println!("val='{local_i32}'"); // 3 spaces - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:42:5 - | -LL | println!("val='{ }'", local_i32); // tab - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{ }'", local_i32); // tab -LL + println!("val='{local_i32}'"); // tab - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:43:5 - | -LL | println!("val='{ }'", local_i32); // space+tab - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{ }'", local_i32); // space+tab -LL + println!("val='{local_i32}'"); // space+tab - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:44:5 - | -LL | println!("val='{ }'", local_i32); // tab+space - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{ }'", local_i32); // tab+space -LL + println!("val='{local_i32}'"); // tab+space - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:45:5 - | -LL | / println!( -LL | | "val='{ -LL | | }'", -LL | | local_i32 -LL | | ); - | |_____^ - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:50:5 - | -LL | println!("{}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{}", local_i32); -LL + println!("{local_i32}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:51:5 - | -LL | println!("{}", fn_arg); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{}", fn_arg); -LL + println!("{fn_arg}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:52:5 - | -LL | println!("{:?}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:?}", local_i32); -LL + println!("{local_i32:?}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:53:5 - | -LL | println!("{:#?}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:#?}", local_i32); -LL + println!("{local_i32:#?}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:54:5 - | -LL | println!("{:4}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:4}", local_i32); -LL + println!("{local_i32:4}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:55:5 - | -LL | println!("{:04}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:04}", local_i32); -LL + println!("{local_i32:04}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:56:5 - | -LL | println!("{:<3}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:<3}", local_i32); -LL + println!("{local_i32:<3}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:57:5 - | -LL | println!("{:#010x}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:#010x}", local_i32); -LL + println!("{local_i32:#010x}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:58:5 - | -LL | println!("{:.1}", local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:.1}", local_f64); -LL + println!("{local_f64:.1}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:62:5 - | -LL | println!("{} {}", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{} {}", local_i32, local_f64); -LL + println!("{local_i32} {local_f64}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:64:5 - | -LL | println!("{}", val); - | ^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{}", val); -LL + println!("{val}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:65:5 - | -LL | println!("{}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{}", v = val); -LL + println!("{val}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:67:5 - | -LL | println!("val='{/t }'", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{/t }'", local_i32); -LL + println!("val='{local_i32}'"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:68:5 - | -LL | println!("val='{/n }'", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{/n }'", local_i32); -LL + println!("val='{local_i32}'"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:69:5 - | -LL | println!("val='{local_i32}'", local_i32 = local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{local_i32}'", local_i32 = local_i32); -LL + println!("val='{local_i32}'"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:70:5 - | -LL | println!("val='{local_i32}'", local_i32 = fn_arg); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("val='{local_i32}'", local_i32 = fn_arg); -LL + println!("val='{fn_arg}'"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:71:5 - | -LL | println!("{0}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0}", local_i32); -LL + println!("{local_i32}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:72:5 - | -LL | println!("{0:?}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:?}", local_i32); -LL + println!("{local_i32:?}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:73:5 - | -LL | println!("{0:#?}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:#?}", local_i32); -LL + println!("{local_i32:#?}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:74:5 - | -LL | println!("{0:04}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:04}", local_i32); -LL + println!("{local_i32:04}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:75:5 - | -LL | println!("{0:<3}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:<3}", local_i32); -LL + println!("{local_i32:<3}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:76:5 - | -LL | println!("{0:#010x}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:#010x}", local_i32); -LL + println!("{local_i32:#010x}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:77:5 - | -LL | println!("{0:.1}", local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:.1}", local_f64); -LL + println!("{local_f64:.1}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:78:5 - | -LL | println!("{0} {0}", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0} {0}", local_i32); -LL + println!("{local_i32} {local_i32}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:79:5 - | -LL | println!("{1} {} {0} {}", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{1} {} {0} {}", local_i32, local_f64); -LL + println!("{local_f64} {local_i32} {local_i32} {local_f64}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:80:5 - | -LL | println!("{0} {1}", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0} {1}", local_i32, local_f64); -LL + println!("{local_i32} {local_f64}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:81:5 - | -LL | println!("{1} {0}", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{1} {0}", local_i32, local_f64); -LL + println!("{local_f64} {local_i32}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:82:5 - | -LL | println!("{1} {0} {1} {0}", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{1} {0} {1} {0}", local_i32, local_f64); -LL + println!("{local_f64} {local_i32} {local_f64} {local_i32}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:84:5 - | -LL | println!("{v}", v = local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{v}", v = local_i32); -LL + println!("{local_i32}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:85:5 - | -LL | println!("{local_i32:0$}", width); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{local_i32:0$}", width); -LL + println!("{local_i32:width$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:86:5 - | -LL | println!("{local_i32:w$}", w = width); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{local_i32:w$}", w = width); -LL + println!("{local_i32:width$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:87:5 - | -LL | println!("{local_i32:.0$}", prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{local_i32:.0$}", prec); -LL + println!("{local_i32:.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:88:5 - | -LL | println!("{local_i32:.p$}", p = prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{local_i32:.p$}", p = prec); -LL + println!("{local_i32:.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:89:5 - | -LL | println!("{:0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:0$}", v = val); -LL + println!("{val:val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:90:5 - | -LL | println!("{0:0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:0$}", v = val); -LL + println!("{val:val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:91:5 - | -LL | println!("{:0$.0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:0$.0$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:92:5 - | -LL | println!("{0:0$.0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:0$.0$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:93:5 - | -LL | println!("{0:0$.v$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:0$.v$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:94:5 - | -LL | println!("{0:v$.0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{0:v$.0$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:95:5 - | -LL | println!("{v:0$.0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{v:0$.0$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:96:5 - | -LL | println!("{v:v$.0$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{v:v$.0$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:97:5 - | -LL | println!("{v:0$.v$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{v:0$.v$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:98:5 - | -LL | println!("{v:v$.v$}", v = val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{v:v$.v$}", v = val); -LL + println!("{val:val$.val$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:99:5 - | -LL | println!("{:0$}", width); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:0$}", width); -LL + println!("{width:width$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:100:5 - | -LL | println!("{:1$}", local_i32, width); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:1$}", local_i32, width); -LL + println!("{local_i32:width$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:101:5 - | -LL | println!("{:w$}", w = width); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:w$}", w = width); -LL + println!("{width:width$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:102:5 - | -LL | println!("{:w$}", local_i32, w = width); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:w$}", local_i32, w = width); -LL + println!("{local_i32:width$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:103:5 - | -LL | println!("{:.0$}", prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:.0$}", prec); -LL + println!("{prec:.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:104:5 - | -LL | println!("{:.1$}", local_i32, prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:.1$}", local_i32, prec); -LL + println!("{local_i32:.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:105:5 - | -LL | println!("{:.p$}", p = prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:.p$}", p = prec); -LL + println!("{prec:.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:106:5 - | -LL | println!("{:.p$}", local_i32, p = prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:.p$}", local_i32, p = prec); -LL + println!("{local_i32:.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:107:5 - | -LL | println!("{:0$.1$}", width, prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:0$.1$}", width, prec); -LL + println!("{width:width$.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:108:5 - | -LL | println!("{:0$.w$}", width, w = prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:0$.w$}", width, w = prec); -LL + println!("{width:width$.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:109:5 - | -LL | println!("{:1$.2$}", local_f64, width, prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:1$.2$}", local_f64, width, prec); -LL + println!("{local_f64:width$.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:110:5 - | -LL | println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); -LL + println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:111:5 - | -LL | / println!( -LL | | "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$}", -LL | | local_i32, width, prec, -LL | | ); - | |_____^ - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:122:5 - | -LL | println!("Width = {}, value with width = {:0$}", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("Width = {}, value with width = {:0$}", local_i32, local_f64); -LL + println!("Width = {local_i32}, value with width = {local_f64:local_i32$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:123:5 - | -LL | println!("{:w$.p$}", local_i32, w = width, p = prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:w$.p$}", local_i32, w = width, p = prec); -LL + println!("{local_i32:width$.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:124:5 - | -LL | println!("{:w$.p$}", w = width, p = prec); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{:w$.p$}", w = width, p = prec); -LL + println!("{width:width$.prec$}"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:143:5 - | -LL | / println!( -LL | | "{}", -LL | | // comment with a comma , in it -LL | | val, -LL | | ); - | |_____^ - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:148:5 - | -LL | println!("{}", /* comment with a comma , in it */ val); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{}", /* comment with a comma , in it */ val); -LL + println!("{val}"); - | - error: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:154:9 | LL | panic!("p1 {}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = note: `-D clippy::uninlined-format-args` implied by `-D warnings` help: change this to | LL - panic!("p1 {}", local_i32); @@ -832,17 +35,5 @@ LL - panic!("p3 {local_i32}", local_i32 = local_i32); LL + panic!("p3 {local_i32}"); | -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:180:5 - | -LL | println!("expand='{}'", local_i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("expand='{}'", local_i32); -LL + println!("expand='{local_i32}'"); - | - -error: aborting due to 71 previous errors +error: aborting due to 3 previous errors diff --git a/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.fixed b/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.fixed index 559050b3df62c..83fbb9afd2a19 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.fixed +++ b/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.fixed @@ -8,7 +8,7 @@ fn main() { let var = 1; - println!("val='{var}'"); + println!("val='{}'", var); if var > 0 { panic!("p1 {}", var); diff --git a/src/tools/clippy/tests/ui/write_literal.stderr b/src/tools/clippy/tests/ui/write_literal.stderr index 1e306ae28a263..9aabdf56a45d8 100644 --- a/src/tools/clippy/tests/ui/write_literal.stderr +++ b/src/tools/clippy/tests/ui/write_literal.stderr @@ -11,137 +11,5 @@ LL - write!(v, "Hello {}", "world"); LL + write!(v, "Hello world"); | -error: literal with an empty format string - --> $DIR/write_literal.rs:32:39 - | -LL | writeln!(v, "Hello {} {}", world, "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "Hello {} {}", world, "world"); -LL + writeln!(v, "Hello {} world", world); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:33:29 - | -LL | writeln!(v, "Hello {}", "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "Hello {}", "world"); -LL + writeln!(v, "Hello world"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:34:29 - | -LL | writeln!(v, "{} {:.4}", "a literal", 5); - | ^^^^^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{} {:.4}", "a literal", 5); -LL + writeln!(v, "a literal {:.4}", 5); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:39:28 - | -LL | writeln!(v, "{0} {1}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{0} {1}", "hello", "world"); -LL + writeln!(v, "hello {1}", "world"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:39:37 - | -LL | writeln!(v, "{0} {1}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{0} {1}", "hello", "world"); -LL + writeln!(v, "{0} world", "hello"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:40:37 - | -LL | writeln!(v, "{1} {0}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{1} {0}", "hello", "world"); -LL + writeln!(v, "world {0}", "hello"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:40:28 - | -LL | writeln!(v, "{1} {0}", "hello", "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{1} {0}", "hello", "world"); -LL + writeln!(v, "{1} hello", "world"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:43:38 - | -LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); -LL + writeln!(v, "hello {bar}", bar = "world"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:43:53 - | -LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); -LL + writeln!(v, "{foo} world", foo = "hello"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:44:53 - | -LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); -LL + writeln!(v, "world {foo}", foo = "hello"); - | - -error: literal with an empty format string - --> $DIR/write_literal.rs:44:38 - | -LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); - | ^^^^^^^ - | -help: try this - | -LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); -LL + writeln!(v, "{bar} hello", bar = "world"); - | - -error: aborting due to 12 previous errors +error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/writeln_empty_string.fixed b/src/tools/clippy/tests/ui/writeln_empty_string.fixed index 45dedd9ead6a8..3b9f51a15d2f7 100644 --- a/src/tools/clippy/tests/ui/writeln_empty_string.fixed +++ b/src/tools/clippy/tests/ui/writeln_empty_string.fixed @@ -8,10 +8,10 @@ fn main() { let mut v = Vec::new(); // These should fail - writeln!(v); + writeln!(v, ""); let mut suggestion = Vec::new(); - writeln!(suggestion); + writeln!(suggestion, ""); // These should be fine writeln!(v); diff --git a/src/tools/miri/tests/fail/erroneous_const2.stderr b/src/tools/miri/tests/fail/erroneous_const2.stderr index 9aad1fc9b023f..cc080afa4ffc8 100644 --- a/src/tools/miri/tests/fail/erroneous_const2.stderr +++ b/src/tools/miri/tests/fail/erroneous_const2.stderr @@ -16,7 +16,7 @@ note: erroneous constant used LL | println!("{}", FOO); | ^^^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index 9bda5f575c99f..215437ad30bce 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -11,10 +11,10 @@ let _9: (); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let _10: (); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let mut _11: std::fmt::Arguments<'_>; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _12: &[&str]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 - let mut _13: &[&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 - let _14: &[&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 - let _15: [&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 + let mut _12: &[&str]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _13: &[&str; 3]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _14: &[&str; 3]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _15: [&str; 3]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let mut _16: &[core::fmt::rt::Argument<'_>]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let mut _17: &[core::fmt::rt::Argument<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let _18: &[core::fmt::rt::Argument<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -43,7 +43,7 @@ scope 4 { debug x => _8; // in scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 let _8: std::boxed::Box; // in scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 - let mut _26: &[&str; 3]; // in scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + let mut _26: &[&str; 3]; // in scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -93,17 +93,17 @@ StorageLive(_9); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_10); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_11); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_12); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 - StorageLive(_13); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 - StorageLive(_14); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 - _26 = const _; // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + StorageLive(_12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_14); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _26 = const _; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $DIR/lifetimes.rs:27:19: 27:28 + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(foo, [T], Some(promoted[0])) } - _14 = &(*_26); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 - _13 = &(*_14); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 - _12 = move _13 as &[&str] (Pointer(Unsize)); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 - StorageDead(_13); // scope 4 at $DIR/lifetimes.rs:+10:27: +10:28 + _14 = &(*_26); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _13 = &(*_14); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _12 = move _13 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_16); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_17); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_18); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/tests/pretty/dollar-crate.pp b/tests/pretty/dollar-crate.pp index 60fddb630d964..afa4d01f8acd6 100644 --- a/tests/pretty/dollar-crate.pp +++ b/tests/pretty/dollar-crate.pp @@ -8,4 +8,6 @@ // pretty-mode:expanded // pp-exact:dollar-crate.pp -fn main() { { ::std::io::_print(format_args!("rust\n")); }; } +fn main() { + { ::std::io::_print(format_args!("{0}\n", format_args!("rust"))); }; +} diff --git a/tests/ui/borrowck/borrowck-and-init.stderr b/tests/ui/borrowck/borrowck-and-init.stderr index 5abf07a3118d8..c899cfefe82c3 100644 --- a/tests/ui/borrowck/borrowck-and-init.stderr +++ b/tests/ui/borrowck/borrowck-and-init.stderr @@ -9,7 +9,7 @@ LL | println!("{}", false && { i = 5; true }); LL | println!("{}", i); | ^ `i` used here but it is possibly-uninitialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-break-uninit-2.stderr b/tests/ui/borrowck/borrowck-break-uninit-2.stderr index ea93a8f409ce4..cb4a7991754c0 100644 --- a/tests/ui/borrowck/borrowck-break-uninit-2.stderr +++ b/tests/ui/borrowck/borrowck-break-uninit-2.stderr @@ -7,7 +7,7 @@ LL | let x: isize; LL | println!("{}", x); | ^ `x` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: isize = 0; diff --git a/tests/ui/borrowck/borrowck-break-uninit.stderr b/tests/ui/borrowck/borrowck-break-uninit.stderr index a7a8fc2ff8378..e04445175b22a 100644 --- a/tests/ui/borrowck/borrowck-break-uninit.stderr +++ b/tests/ui/borrowck/borrowck-break-uninit.stderr @@ -7,7 +7,7 @@ LL | let x: isize; LL | println!("{}", x); | ^ `x` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: isize = 0; diff --git a/tests/ui/borrowck/borrowck-or-init.stderr b/tests/ui/borrowck/borrowck-or-init.stderr index 16d66bf40d109..2882c06bb8895 100644 --- a/tests/ui/borrowck/borrowck-or-init.stderr +++ b/tests/ui/borrowck/borrowck-or-init.stderr @@ -9,7 +9,7 @@ LL | println!("{}", false || { i = 5; true }); LL | println!("{}", i); | ^ `i` used here but it is possibly-uninitialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-while-break.stderr b/tests/ui/borrowck/borrowck-while-break.stderr index 13143d436df8e..7f4c4c2fd48da 100644 --- a/tests/ui/borrowck/borrowck-while-break.stderr +++ b/tests/ui/borrowck/borrowck-while-break.stderr @@ -9,7 +9,7 @@ LL | while cond { LL | println!("{}", v); | ^ `v` used here but it is possibly-uninitialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-24267-flow-exit.stderr b/tests/ui/borrowck/issue-24267-flow-exit.stderr index 58d1c8c0f73ad..806c12dc63888 100644 --- a/tests/ui/borrowck/issue-24267-flow-exit.stderr +++ b/tests/ui/borrowck/issue-24267-flow-exit.stderr @@ -7,7 +7,7 @@ LL | loop { x = break; } LL | println!("{}", x); | ^ `x` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: i32 = 0; @@ -22,7 +22,7 @@ LL | for _ in 0..10 { x = continue; } LL | println!("{}", x); | ^ `x` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: i32 = 0; diff --git a/tests/ui/borrowck/issue-47646.stderr b/tests/ui/borrowck/issue-47646.stderr index 84cf9237a56d2..f0146ceed6d42 100644 --- a/tests/ui/borrowck/issue-47646.stderr +++ b/tests/ui/borrowck/issue-47646.stderr @@ -13,7 +13,7 @@ LL | println!("{:?}", heap); LL | }; | - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option>, ())` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/borrowck/suggest-assign-rvalue.stderr b/tests/ui/borrowck/suggest-assign-rvalue.stderr index 92acba640d756..fd2a80bb370e1 100644 --- a/tests/ui/borrowck/suggest-assign-rvalue.stderr +++ b/tests/ui/borrowck/suggest-assign-rvalue.stderr @@ -19,7 +19,7 @@ LL | let my_float: f32; LL | println!("my_float: {}", my_float); | ^^^^^^^^ `my_float` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let my_float: f32 = 0.0; @@ -33,7 +33,7 @@ LL | let demo: Demo; LL | println!("demo: {:?}", demo); | ^^^^ `demo` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let demo: Demo = Default::default(); @@ -47,7 +47,7 @@ LL | let demo_no: DemoNoDef; LL | println!("demo_no: {:?}", demo_no); | ^^^^^^^ `demo_no` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let demo_no: DemoNoDef = todo!(); @@ -61,7 +61,7 @@ LL | let arr: [i32; 5]; LL | println!("arr: {:?}", arr); | ^^^ `arr` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let arr: [i32; 5] = todo!(); @@ -75,7 +75,7 @@ LL | let foo: Vec<&str>; LL | println!("foo: {:?}", foo); | ^^^ `foo` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let foo: Vec<&str> = vec![]; @@ -89,7 +89,7 @@ LL | let my_string: String; LL | println!("my_string: {}", my_string); | ^^^^^^^^^ `my_string` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let my_string: String = Default::default(); @@ -103,7 +103,7 @@ LL | let my_int: &i32; LL | println!("my_int: {}", *my_int); | ^^^^^^^ `*my_int` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let my_int: &i32 = todo!(); @@ -117,7 +117,7 @@ LL | let hello: &str; LL | println!("hello: {}", hello); | ^^^^^ `hello` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let hello: &str = todo!(); @@ -131,7 +131,7 @@ LL | let never: !; LL | println!("never: {}", never); | ^^^^^ `never` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr index 9e5200ef34b54..a13376a5c8c5b 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr @@ -82,7 +82,7 @@ LL | println!("{}", arr[3]); LL | c(); | - mutable borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable --> $DIR/arrays.rs:73:24 diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr index 2e3259e640596..793977e484479 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/box.stderr @@ -26,7 +26,7 @@ LL | LL | c(); | - mutable borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed --> $DIR/box.rs:55:5 diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr index 8c44229bcebe1..ad139e1f577a0 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr @@ -7,7 +7,7 @@ LL | println!("{}", foo.x); = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr index 06157b2af7a07..5d3e2cea8d070 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr @@ -14,7 +14,7 @@ LL | LL | c(); | - mutable borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/codemap_tests/tab_3.stderr b/tests/ui/codemap_tests/tab_3.stderr index 17bea2f366fa0..e86fb8305a1c9 100644 --- a/tests/ui/codemap_tests/tab_3.stderr +++ b/tests/ui/codemap_tests/tab_3.stderr @@ -11,7 +11,7 @@ LL | println!("{:?}", some_vec); | note: `into_iter` takes ownership of the receiver `self`, which moves `some_vec` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | some_vec.clone().into_iter(); diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index 70a1abb0a9555..f8370f566b634 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -23,7 +23,7 @@ LL | println!("{:?}", 0); | ^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `Arguments::<'_>::new_v1` in constant functions --> $DIR/format.rs:8:5 @@ -32,7 +32,7 @@ LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `_print` in constant functions --> $DIR/format.rs:8:5 @@ -72,16 +72,20 @@ LL | panic!("{:?}", 0); = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used - --> $DIR/format.rs:8:14 + --> $DIR/format.rs:8:5 | LL | println!("{:?}", 0); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used - --> $DIR/format.rs:8:14 + --> $DIR/format.rs:8:5 | LL | println!("{:?}", 0); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used --> $DIR/format.rs:8:22 @@ -89,7 +93,7 @@ note: erroneous constant used LL | println!("{:?}", 0); | ^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used --> $DIR/format.rs:8:22 @@ -97,7 +101,7 @@ note: erroneous constant used LL | println!("{:?}", 0); | ^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index f3952809e4bb4..5fec00ea8061f 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -16,7 +16,7 @@ note: erroneous constant used LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used --> $DIR/issue-44578.rs:25:20 @@ -24,7 +24,7 @@ note: erroneous constant used LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.rs b/tests/ui/feature-gates/feature-gate-format_args_nl.rs deleted file mode 100644 index aeee2fbad9071..0000000000000 --- a/tests/ui/feature-gates/feature-gate-format_args_nl.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - format_args_nl!(""); //~ ERROR `format_args_nl` is only for internal language use -} diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.stderr b/tests/ui/feature-gates/feature-gate-format_args_nl.stderr deleted file mode 100644 index b211e2f8ed8a2..0000000000000 --- a/tests/ui/feature-gates/feature-gate-format_args_nl.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: use of unstable library feature 'format_args_nl': `format_args_nl` is only for internal language use and is subject to change - --> $DIR/feature-gate-format_args_nl.rs:2:5 - | -LL | format_args_nl!(""); - | ^^^^^^^^^^^^^^ - | - = help: add `#![feature(format_args_nl)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/fmt/format-args-argument-span.stderr b/tests/ui/fmt/format-args-argument-span.stderr index 4e2702383d6cb..70f134e883c99 100644 --- a/tests/ui/fmt/format-args-argument-span.stderr +++ b/tests/ui/fmt/format-args-argument-span.stderr @@ -6,7 +6,7 @@ LL | println!("{x:?} {x} {x:?}"); | = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Option<{integer}>` doesn't implement `std::fmt::Display` --> $DIR/format-args-argument-span.rs:15:37 @@ -16,7 +16,7 @@ LL | println!("{x:?} {x} {x:?}", x = Some(1)); | = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `DisplayOnly` doesn't implement `Debug` --> $DIR/format-args-argument-span.rs:18:19 @@ -26,7 +26,7 @@ LL | println!("{x} {x:?} {x}"); | = help: the trait `Debug` is not implemented for `DisplayOnly` = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `DisplayOnly` with `#[derive(Debug)]` | LL + #[derive(Debug)] @@ -41,7 +41,7 @@ LL | println!("{x} {x:?} {x}", x = DisplayOnly); | = help: the trait `Debug` is not implemented for `DisplayOnly` = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `DisplayOnly` with `#[derive(Debug)]` | LL + #[derive(Debug)] diff --git a/tests/ui/fmt/ifmt-bad-arg.stderr b/tests/ui/fmt/ifmt-bad-arg.stderr index ed008c454a31c..7bc2adb6ab982 100644 --- a/tests/ui/fmt/ifmt-bad-arg.stderr +++ b/tests/ui/fmt/ifmt-bad-arg.stderr @@ -308,7 +308,7 @@ LL | println!("{} {:.*} {}", 1, 3.2, 4); found reference `&{float}` note: associated function defined here --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:81:35 @@ -322,7 +322,7 @@ LL | println!("{} {:07$.*} {}", 1, 3.2, 4); found reference `&{float}` note: associated function defined here --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 38 previous errors diff --git a/tests/ui/generator/yield-while-ref-reborrowed.stderr b/tests/ui/generator/yield-while-ref-reborrowed.stderr index 47147f9c05d78..e492efac44fca 100644 --- a/tests/ui/generator/yield-while-ref-reborrowed.stderr +++ b/tests/ui/generator/yield-while-ref-reborrowed.stderr @@ -11,7 +11,7 @@ LL | println!("{}", x); LL | Pin::new(&mut b).resume(()); | ------ first borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/hygiene/format-args.rs b/tests/ui/hygiene/format-args.rs index d74889b95cc12..4706a126836e3 100644 --- a/tests/ui/hygiene/format-args.rs +++ b/tests/ui/hygiene/format-args.rs @@ -1,12 +1,10 @@ // check-pass #![allow(non_upper_case_globals)] -#![feature(format_args_nl)] static arg0: () = (); fn main() { static arg1: () = (); format_args!("{} {:?}", 0, 1); - format_args_nl!("{} {:?}", 0, 1); } diff --git a/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr b/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr index 464655bbcf451..fd38a47ddf0c0 100644 --- a/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr +++ b/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | println!("{:?}", []); | ^^ cannot infer type | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/infinite/issue-41731-infinite-macro-println.rs b/tests/ui/infinite/issue-41731-infinite-macro-println.rs index 3c2b7ee023b5c..bd27d03f98752 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-println.rs +++ b/tests/ui/infinite/issue-41731-infinite-macro-println.rs @@ -1,6 +1,6 @@ // compile-flags: -Z trace-macros -#![recursion_limit = "5"] +#![recursion_limit = "6"] fn main() { macro_rules! stack { diff --git a/tests/ui/infinite/issue-41731-infinite-macro-println.stderr b/tests/ui/infinite/issue-41731-infinite-macro-println.stderr index 66b466dafa0da..cf5772232e0aa 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-println.stderr +++ b/tests/ui/infinite/issue-41731-infinite-macro-println.stderr @@ -1,10 +1,10 @@ -error: recursion limit reached while expanding `$crate::format_args_nl!` +error: recursion limit reached while expanding `$crate::format_args!` --> $DIR/issue-41731-infinite-macro-println.rs:14:5 | LL | stack!("overflow"); | ^^^^^^^^^^^^^^^^^^ | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "10"]` attribute to your crate (`issue_41731_infinite_macro_println`) + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "12"]` attribute to your crate (`issue_41731_infinite_macro_println`) = note: this error originates in the macro `println` which comes from the expansion of the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) note: trace_macro @@ -16,11 +16,19 @@ LL | stack!("overflow"); = note: expanding `stack! { "overflow" }` = note: to `println! (stack! ("overflow")) ;` = note: expanding `println! { stack! ("overflow") }` - = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))) ; }` + = note: to `{ + $crate :: io :: + _print($crate :: format_args! + ("{}\n", $crate :: format_args! (stack! ("overflow")))) ; + }` = note: expanding `stack! { "overflow" }` = note: to `println! (stack! ("overflow")) ;` = note: expanding `println! { stack! ("overflow") }` - = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))) ; }` + = note: to `{ + $crate :: io :: + _print($crate :: format_args! + ("{}\n", $crate :: format_args! (stack! ("overflow")))) ; + }` error: format argument must be a string literal --> $DIR/issue-41731-infinite-macro-println.rs:14:5 diff --git a/tests/ui/issues/issue-42796.stderr b/tests/ui/issues/issue-42796.stderr index f2971df5db275..750039cfe8e2d 100644 --- a/tests/ui/issues/issue-42796.stderr +++ b/tests/ui/issues/issue-42796.stderr @@ -9,7 +9,7 @@ LL | let mut s_copy = s; LL | println!("{}", s); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | let mut s_copy = s.clone(); diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 510b36edd8f47..32e7f31bb0ea4 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -15,7 +15,7 @@ note: erroneous constant used LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used --> $DIR/issue-55878.rs:7:26 @@ -23,7 +23,7 @@ note: erroneous constant used LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this note originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/liveness/liveness-move-in-while.stderr b/tests/ui/liveness/liveness-move-in-while.stderr index 4dff7447dd766..28bbe8aec389d 100644 --- a/tests/ui/liveness/liveness-move-in-while.stderr +++ b/tests/ui/liveness/liveness-move-in-while.stderr @@ -35,7 +35,7 @@ LL | while true { while true { while true { x = y; x.clone(); } } } | | inside of this loop | inside of this loop | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | while true { while true { while true { x = y.clone(); x.clone(); } } } diff --git a/tests/ui/liveness/liveness-use-after-move.stderr b/tests/ui/liveness/liveness-use-after-move.stderr index 3accba197a13d..5b6e8b97617d8 100644 --- a/tests/ui/liveness/liveness-use-after-move.stderr +++ b/tests/ui/liveness/liveness-use-after-move.stderr @@ -9,7 +9,7 @@ LL | LL | println!("{}", *x); | ^^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | let y = x.clone(); diff --git a/tests/ui/liveness/liveness-use-after-send.stderr b/tests/ui/liveness/liveness-use-after-send.stderr index 65d55ca8f7073..5538e0bf03d58 100644 --- a/tests/ui/liveness/liveness-use-after-send.stderr +++ b/tests/ui/liveness/liveness-use-after-send.stderr @@ -13,7 +13,7 @@ note: consider changing this parameter type in function `send` to borrow instead | LL | fn send(ch: Chan, data: T) { | ---- in this function ^ this parameter takes ownership of the value - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | send(ch, message.clone()); diff --git a/tests/ui/loops/loop-proper-liveness.stderr b/tests/ui/loops/loop-proper-liveness.stderr index f9d94b6810cb0..f83882f1e74b2 100644 --- a/tests/ui/loops/loop-proper-liveness.stderr +++ b/tests/ui/loops/loop-proper-liveness.stderr @@ -7,7 +7,7 @@ LL | let x: i32; LL | println!("{:?}", x); | ^ `x` used here but it isn't initialized | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider assigning a value | LL | let x: i32 = 0; diff --git a/tests/ui/macros/issue-92267.stderr b/tests/ui/macros/issue-92267.stderr index 5359f68cd5517..058df7bdb6c1a 100644 --- a/tests/ui/macros/issue-92267.stderr +++ b/tests/ui/macros/issue-92267.stderr @@ -2,15 +2,9 @@ error: argument never used --> $DIR/issue-92267.rs:3:34 | LL | pub fn main() { println!("🦀%%%", 0) } - | ^ argument never used - | -note: format specifiers use curly braces, and the conversion specifier ` - ` is unknown or unsupported - --> $DIR/issue-92267.rs:3:30 - | -LL | pub fn main() { println!("🦀%%%", 0) } - | ^^ - = note: printf formatting is not supported; see the documentation for `std::fmt` + | ------- ^ argument never used + | | + | formatting specifier missing error: aborting due to previous error diff --git a/tests/ui/macros/trace-macro.stderr b/tests/ui/macros/trace-macro.stderr index 43272248c280e..a03093e7456ed 100644 --- a/tests/ui/macros/trace-macro.stderr +++ b/tests/ui/macros/trace-macro.stderr @@ -5,5 +5,9 @@ LL | println!("Hello, World!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expanding `println! { "Hello, World!" }` - = note: to `{ $crate :: io :: _print($crate :: format_args_nl! ("Hello, World!")) ; }` + = note: to `{ + $crate :: io :: + _print($crate :: format_args! + ("{}\n", $crate :: format_args! ("Hello, World!"))) ; + }` diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr index 38a910b57b474..92340c28bfe44 100644 --- a/tests/ui/modules/issue-107649.stderr +++ b/tests/ui/modules/issue-107649.stderr @@ -6,7 +6,7 @@ error[E0277]: `Dummy` doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `Dummy` = note: add `#[derive(Debug)]` to `Dummy` or manually `impl Debug for Dummy` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Dummy` with `#[derive(Debug)]` --> $DIR/auxiliary/dummy_lib.rs:2:1 | diff --git a/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr index 34b7ea6586718..4591c07c59854 100644 --- a/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr @@ -11,7 +11,7 @@ LL | }); LL | println!("{}", x); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/on-unimplemented/no-debug.stderr b/tests/ui/on-unimplemented/no-debug.stderr index 97d67dbd82e77..013486e3f1c38 100644 --- a/tests/ui/on-unimplemented/no-debug.stderr +++ b/tests/ui/on-unimplemented/no-debug.stderr @@ -6,7 +6,7 @@ LL | println!("{:?} {:?}", Foo, Bar); | = help: the trait `Debug` is not implemented for `Foo` = note: add `#[derive(Debug)]` to `Foo` or manually `impl Debug for Foo` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Foo` with `#[derive(Debug)]` | LL + #[derive(Debug)] @@ -20,7 +20,7 @@ LL | println!("{:?} {:?}", Foo, Bar); | ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `Bar` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Foo` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:23 @@ -30,7 +30,7 @@ LL | println!("{} {}", Foo, Bar); | = help: the trait `std::fmt::Display` is not implemented for `Foo` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Bar` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:28 @@ -40,7 +40,7 @@ LL | println!("{} {}", Foo, Bar); | = help: the trait `std::fmt::Display` is not implemented for `Bar` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index ce165e6463292..caea0a4304986 100644 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -6,7 +6,7 @@ LL | let _: NotDebug = dbg!(NotDebug); | = help: the trait `Debug` is not implemented for `NotDebug` = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NotDebug` with `#[derive(Debug)]` | LL + #[derive(Debug)] diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs b/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs index b604c65d75100..220ba0988b2cf 100644 --- a/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs +++ b/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs @@ -6,7 +6,9 @@ trait Tr { fn req(&self); fn prov(&self) { - println!("lul"); //~ ERROR: cannot call non-const fn `_print` in constant functions + println!("lul"); + //~^ ERROR: cannot call non-const fn + //~| ERROR: cannot call non-const fn self.req(); } } diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr b/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr index 082c0333fbfcd..2d9dbc76034c2 100644 --- a/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr @@ -1,3 +1,12 @@ +error[E0015]: cannot call non-const fn `Arguments::<'_>::new_v1` in constant functions + --> $DIR/issue-79450.rs:9:9 + | +LL | println!("lul"); + | ^^^^^^^^^^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0015]: cannot call non-const fn `_print` in constant functions --> $DIR/issue-79450.rs:9:9 | @@ -7,6 +16,6 @@ LL | println!("lul"); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/suggestions/bound-suggestions.stderr b/tests/ui/suggestions/bound-suggestions.stderr index cd27947f02fad..2337c5ae114bb 100644 --- a/tests/ui/suggestions/bound-suggestions.stderr +++ b/tests/ui/suggestions/bound-suggestions.stderr @@ -4,7 +4,7 @@ error[E0277]: `impl Sized` doesn't implement `Debug` LL | println!("{:?}", t); | ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_impl(t: impl Sized + std::fmt::Debug) { @@ -16,7 +16,7 @@ error[E0277]: `T` doesn't implement `Debug` LL | println!("{:?}", t); | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | LL | fn test_no_bounds(t: T) { @@ -28,7 +28,7 @@ error[E0277]: `T` doesn't implement `Debug` LL | println!("{:?}", t); | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_one_bound(t: T) { @@ -40,7 +40,7 @@ error[E0277]: `Y` doesn't implement `Debug` LL | println!("{:?} {:?}", x, y); | ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `Y` | LL | fn test_no_bounds_where(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug { @@ -52,7 +52,7 @@ error[E0277]: `X` doesn't implement `Debug` LL | println!("{:?}", x); | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_one_bound_where(x: X) where X: Sized + std::fmt::Debug { @@ -64,7 +64,7 @@ error[E0277]: `X` doesn't implement `Debug` LL | println!("{:?}", x); | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_many_bounds_where(x: X) where X: Sized + std::fmt::Debug, X: Sized { diff --git a/tests/ui/suggestions/issue-97760.stderr b/tests/ui/suggestions/issue-97760.stderr index 5415c247c8fff..aed09dbda3099 100644 --- a/tests/ui/suggestions/issue-97760.stderr +++ b/tests/ui/suggestions/issue-97760.stderr @@ -6,7 +6,7 @@ LL | println!("{x}"); | = help: the trait `std::fmt::Display` is not implemented for `::Item` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: introduce a type parameter with a trait bound instead of using `impl Trait` | LL ~ pub fn print_values(values: &I) diff --git a/tests/ui/suggestions/path-display.stderr b/tests/ui/suggestions/path-display.stderr index 8359b36588e6b..e3d599f32569c 100644 --- a/tests/ui/suggestions/path-display.stderr +++ b/tests/ui/suggestions/path-display.stderr @@ -6,7 +6,7 @@ LL | println!("{}", path); | = help: the trait `std::fmt::Display` is not implemented for `Path` = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `PathBuf` doesn't implement `std::fmt::Display` --> $DIR/path-display.rs:9:20 @@ -16,7 +16,7 @@ LL | println!("{}", path); | = help: the trait `std::fmt::Display` is not implemented for `PathBuf` = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr b/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr index 71c7e460c3992..f28f5761389a9 100644 --- a/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr +++ b/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr @@ -22,7 +22,7 @@ LL | }; LL | println!("{}", x); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | ::std::mem::drop(x.clone()); diff --git a/tests/ui/type-alias-impl-trait/nested.stderr b/tests/ui/type-alias-impl-trait/nested.stderr index 732af5c0b561f..849c6a03eae06 100644 --- a/tests/ui/type-alias-impl-trait/nested.stderr +++ b/tests/ui/type-alias-impl-trait/nested.stderr @@ -5,7 +5,7 @@ LL | println!("{:?}", bar()); | ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `Bar` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/type/binding-assigned-block-without-tail-expression.stderr b/tests/ui/type/binding-assigned-block-without-tail-expression.stderr index 3e96d7f317b4a..83666ca3dc16f 100644 --- a/tests/ui/type/binding-assigned-block-without-tail-expression.stderr +++ b/tests/ui/type/binding-assigned-block-without-tail-expression.stderr @@ -9,7 +9,7 @@ LL | println!("{}", x); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/binding-assigned-block-without-tail-expression.rs:15:20 @@ -22,7 +22,7 @@ LL | println!("{}", y); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/binding-assigned-block-without-tail-expression.rs:16:20 @@ -35,7 +35,7 @@ LL | println!("{}", z); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/binding-assigned-block-without-tail-expression.rs:17:20 @@ -51,7 +51,7 @@ LL | println!("{}", s); | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/binding-assigned-block-without-tail-expression.rs:18:18 diff --git a/tests/ui/use/use-after-move-based-on-type.stderr b/tests/ui/use/use-after-move-based-on-type.stderr index 7b4d2454994d7..fb8ffd3ac67d9 100644 --- a/tests/ui/use/use-after-move-based-on-type.stderr +++ b/tests/ui/use/use-after-move-based-on-type.stderr @@ -8,7 +8,7 @@ LL | let _y = x; LL | println!("{}", x); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | LL | let _y = x.clone(); diff --git a/tests/ui/walk-struct-literal-with.stderr b/tests/ui/walk-struct-literal-with.stderr index 2b85fa9bed480..25662d7656b55 100644 --- a/tests/ui/walk-struct-literal-with.stderr +++ b/tests/ui/walk-struct-literal-with.stderr @@ -13,7 +13,7 @@ note: `Mine::make_string_bar` takes ownership of the receiver `self`, which move | LL | fn make_string_bar(mut self) -> Mine{ | ^^^^ - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error