diff --git a/compiler/rustc_ast/src/util/literal.rs b/compiler/rustc_ast/src/util/literal.rs index 9c18f55c03b4d..231dd72af2c7d 100644 --- a/compiler/rustc_ast/src/util/literal.rs +++ b/compiler/rustc_ast/src/util/literal.rs @@ -23,7 +23,7 @@ pub enum LitError { impl LitKind { /// Converts literal token into a semantic literal. - pub fn from_lit_token(lit: token::Lit) -> Result { + fn from_lit_token(lit: token::Lit) -> Result { let token::Lit { kind, symbol, suffix } = lit; if suffix.is_some() && !kind.may_have_suffix() { return Err(LitError::InvalidSuffix); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 345247b07001b..5ba1fe9b4786f 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1093,12 +1093,12 @@ impl HandlerInner { let warnings = match self.deduplicated_warn_count { 0 => String::new(), 1 => "1 warning emitted".to_string(), - count => format!("{count} warnings emitted"), + count => format!("{} warnings emitted", count), }; let errors = match self.deduplicated_err_count { 0 => String::new(), 1 => "aborting due to previous error".to_string(), - count => format!("aborting due to {count} previous errors"), + count => format!("aborting due to {} previous errors", count), }; if self.treat_err_as_bug() { return; diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index 8a9efe01368e3..b024524aa2968 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -3,7 +3,6 @@ #![feature(crate_visibility_modifier)] #![feature(decl_macro)] #![feature(if_let_guard)] -#![feature(let_chains)] #![feature(let_else)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_internals)] diff --git a/compiler/rustc_expand/src/mbe.rs b/compiler/rustc_expand/src/mbe.rs index 3d4c77aba7339..5244ac36bba5d 100644 --- a/compiler/rustc_expand/src/mbe.rs +++ b/compiler/rustc_expand/src/mbe.rs @@ -6,17 +6,17 @@ crate mod macro_check; crate mod macro_parser; crate mod macro_rules; -crate mod metavar_expr; crate mod quoted; crate mod transcribe; -use metavar_expr::MetaVarExpr; use rustc_ast::token::{self, NonterminalKind, Token, TokenKind}; use rustc_ast::tokenstream::DelimSpan; -use rustc_data_structures::sync::Lrc; + use rustc_span::symbol::Ident; use rustc_span::Span; +use rustc_data_structures::sync::Lrc; + /// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note /// that the delimiter itself might be `NoDelim`. #[derive(Clone, PartialEq, Encodable, Decodable, Debug)] @@ -73,8 +73,8 @@ enum KleeneOp { ZeroOrOne, } -/// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, `$(...)`, -/// and `${...}` are "first-class" token trees. Useful for parsing macros. +/// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)` +/// are "first-class" token trees. Useful for parsing macros. #[derive(Debug, Clone, PartialEq, Encodable, Decodable)] enum TokenTree { Token(Token), @@ -85,8 +85,6 @@ enum TokenTree { MetaVar(Span, Ident), /// e.g., `$var:expr`. This is only used in the left hand side of MBE macros. MetaVarDecl(Span, Ident /* name to bind */, Option), - /// A meta-variable expression inside `${...}` - MetaVarExpr(DelimSpan, MetaVarExpr), } impl TokenTree { @@ -141,9 +139,7 @@ impl TokenTree { TokenTree::Token(Token { span, .. }) | TokenTree::MetaVar(span, _) | TokenTree::MetaVarDecl(span, _, _) => span, - TokenTree::Delimited(span, _) - | TokenTree::MetaVarExpr(span, _) - | TokenTree::Sequence(span, _) => span.entire(), + TokenTree::Delimited(span, _) | TokenTree::Sequence(span, _) => span.entire(), } } diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index f18cf95a2bf11..3497e5ad543a1 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -278,8 +278,6 @@ fn check_binders( binders.insert(name, BinderInfo { span, ops: ops.into() }); } } - // `MetaVarExpr` can not appear in the LHS of a macro arm - TokenTree::MetaVarExpr(..) => {} TokenTree::Delimited(_, ref del) => { for tt in &del.tts { check_binders(sess, node_id, tt, macros, binders, ops, valid); @@ -337,12 +335,6 @@ fn check_occurrences( let name = MacroRulesNormalizedIdent::new(name); check_ops_is_prefix(sess, node_id, macros, binders, ops, span, name); } - TokenTree::MetaVarExpr(dl, ref mve) => { - let Some(name) = mve.ident().map(MacroRulesNormalizedIdent::new) else { - return; - }; - check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name); - } TokenTree::Delimited(_, ref del) => { check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid); } diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 07081c75d46f0..e39a7f71a8170 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -200,7 +200,7 @@ struct MatcherPos<'root, 'tt> { // This type is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(MatcherPos<'_, '_>, 240); +rustc_data_structures::static_assert_size!(MatcherPos<'_, '_>, 192); impl<'root, 'tt> MatcherPos<'root, 'tt> { /// Generates the top-level matcher position in which the "dot" is before the first token of @@ -321,16 +321,10 @@ pub(super) fn count_names(ms: &[TokenTree]) -> usize { ms.iter().fold(0, |count, elt| { count + match *elt { + TokenTree::Sequence(_, ref seq) => seq.num_captures, TokenTree::Delimited(_, ref delim) => count_names(&delim.tts), TokenTree::MetaVar(..) => 0, TokenTree::MetaVarDecl(..) => 1, - // Panicking here would abort execution because `parse_tree` makes use of this - // function. In other words, RHS meta-variable expressions eventually end-up here. - // - // `0` is still returned to inform that no meta-variable was found. `Meta-variables - // != Meta-variable expressions` - TokenTree::MetaVarExpr(..) => 0, - TokenTree::Sequence(_, ref seq) => seq.num_captures, TokenTree::Token(..) => 0, } }) @@ -442,8 +436,7 @@ fn nameize>( } Occupied(..) => return Err((sp, format!("duplicated bind name: {}", bind_name))), }, - TokenTree::Token(..) => (), - TokenTree::MetaVar(..) | TokenTree::MetaVarExpr(..) => unreachable!(), + TokenTree::MetaVar(..) | TokenTree::Token(..) => (), } Ok(()) @@ -658,12 +651,7 @@ fn parse_tt_inner<'root, 'tt>( next_items.push(item); } - // There was another token that was not `token`... This means we can't add any - // rules. NOTE that this is not necessarily an error unless _all_ items in - // `cur_items` end up doing this. There may still be some other matchers that do - // end up working out. - TokenTree::Token(..) => {} - + // These cannot appear in a matcher. TokenTree::MetaVar(..) | TokenTree::MetaVarExpr(..) => unreachable!(), } } diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index c3b1b34aa29b9..62ea3aa76a46c 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -580,10 +580,7 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool { use mbe::TokenTree; for tt in tts { match *tt { - TokenTree::Token(..) - | TokenTree::MetaVar(..) - | TokenTree::MetaVarDecl(..) - | TokenTree::MetaVarExpr(..) => (), + TokenTree::Token(..) | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) => (), TokenTree::Delimited(_, ref del) => { if !check_lhs_no_empty_seq(sess, &del.tts) { return false; @@ -672,10 +669,7 @@ impl FirstSets { let mut first = TokenSet::empty(); for tt in tts.iter().rev() { match *tt { - TokenTree::Token(..) - | TokenTree::MetaVar(..) - | TokenTree::MetaVarDecl(..) - | TokenTree::MetaVarExpr(..) => { + TokenTree::Token(..) | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) => { first.replace_with(tt.clone()); } TokenTree::Delimited(span, ref delimited) => { @@ -737,10 +731,7 @@ impl FirstSets { for tt in tts.iter() { assert!(first.maybe_empty); match *tt { - TokenTree::Token(..) - | TokenTree::MetaVar(..) - | TokenTree::MetaVarDecl(..) - | TokenTree::MetaVarExpr(..) => { + TokenTree::Token(..) | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) => { first.add_one(tt.clone()); return first; } @@ -916,10 +907,7 @@ fn check_matcher_core( // First, update `last` so that it corresponds to the set // of NT tokens that might end the sequence `... token`. match *token { - TokenTree::Token(..) - | TokenTree::MetaVar(..) - | TokenTree::MetaVarDecl(..) - | TokenTree::MetaVarExpr(..) => { + TokenTree::Token(..) | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) => { if token_can_be_followed_by_any(token) { // don't need to track tokens that work with any, last.replace_with_irrelevant(); diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 12c5dac9e0bf4..dedc6c618b9a4 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -1,13 +1,13 @@ use crate::mbe::macro_parser; -use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree}; +use crate::mbe::{Delimited, KleeneOp, KleeneToken, SequenceRepetition, TokenTree}; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream; use rustc_ast::{NodeId, DUMMY_NODE_ID}; use rustc_ast_pretty::pprust; use rustc_feature::Features; -use rustc_session::parse::{feature_err, ParseSess}; -use rustc_span::symbol::{kw, sym, Ident}; +use rustc_session::parse::ParseSess; +use rustc_span::symbol::{kw, Ident}; use rustc_span::edition::Edition; use rustc_span::{Span, SyntaxContext}; @@ -25,22 +25,22 @@ const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ /// # Parameters /// /// - `input`: a token stream to read from, the contents of which we are parsing. -/// - `parsing_patterns`: `parse` can be used to parse either the "patterns" or the "body" of a -/// macro. Both take roughly the same form _except_ that: -/// - In a pattern, metavars are declared with their "matcher" type. For example `$var:expr` or -/// `$id:ident`. In this example, `expr` and `ident` are "matchers". They are not present in the -/// body of a macro rule -- just in the pattern. -/// - Metavariable expressions are only valid in the "body", not the "pattern". +/// - `expect_matchers`: `parse` can be used to parse either the "patterns" or the "body" of a +/// macro. Both take roughly the same form _except_ that in a pattern, metavars are declared with +/// their "matcher" type. For example `$var:expr` or `$id:ident`. In this example, `expr` and +/// `ident` are "matchers". They are not present in the body of a macro rule -- just in the +/// pattern, so we pass a parameter to indicate whether to expect them or not. /// - `sess`: the parsing session. Any errors will be emitted to this session. /// - `node_id`: the NodeId of the macro we are parsing. /// - `features`: language features so we can do feature gating. +/// - `edition`: the edition of the crate defining the macro /// /// # Returns /// /// A collection of `self::TokenTree`. There may also be some errors emitted to `sess`. pub(super) fn parse( input: tokenstream::TokenStream, - parsing_patterns: bool, + expect_matchers: bool, sess: &ParseSess, node_id: NodeId, features: &Features, @@ -55,9 +55,9 @@ pub(super) fn parse( while let Some(tree) = trees.next() { // Given the parsed tree, if there is a metavar and we are expecting matchers, actually // parse out the matcher (i.e., in `$id:ident` this would parse the `:` and `ident`). - let tree = parse_tree(tree, &mut trees, parsing_patterns, sess, node_id, features, edition); + let tree = parse_tree(tree, &mut trees, expect_matchers, sess, node_id, features, edition); match tree { - TokenTree::MetaVar(start_sp, ident) if parsing_patterns => { + TokenTree::MetaVar(start_sp, ident) if expect_matchers => { let span = match trees.next() { Some(tokenstream::TokenTree::Token(Token { kind: token::Colon, span })) => { match trees.next() { @@ -118,14 +118,6 @@ pub(super) fn parse( result } -/// Asks for the `macro_metavar_expr` feature if it is not already declared -fn maybe_emit_macro_metavar_expr_feature(features: &Features, sess: &ParseSess, span: Span) { - if !features.macro_metavar_expr { - let msg = "meta-variable expressions are unstable"; - feature_err(&sess, sym::macro_metavar_expr, span, msg).emit(); - } -} - /// Takes a `tokenstream::TokenTree` and returns a `self::TokenTree`. Specifically, this takes a /// generic `TokenTree`, such as is used in the rest of the compiler, and returns a `TokenTree` /// for use in parsing a macro. @@ -137,13 +129,14 @@ fn maybe_emit_macro_metavar_expr_feature(features: &Features, sess: &ParseSess, /// - `tree`: the tree we wish to convert. /// - `outer_trees`: an iterator over trees. We may need to read more tokens from it in order to finish /// converting `tree` -/// - `parsing_patterns`: same as [parse]. +/// - `expect_matchers`: same as for `parse` (see above). /// - `sess`: the parsing session. Any errors will be emitted to this session. /// - `features`: language features so we can do feature gating. +/// - `edition` - the edition of the crate defining the macro fn parse_tree( tree: tokenstream::TokenTree, outer_trees: &mut impl Iterator, - parsing_patterns: bool, + expect_matchers: bool, sess: &ParseSess, node_id: NodeId, features: &Features, @@ -165,57 +158,24 @@ fn parse_tree( } match next { - // `tree` is followed by a delimited set of token trees. - Some(tokenstream::TokenTree::Delimited(delim_span, delim, tts)) => { - if parsing_patterns { - if delim != token::Paren { - span_dollar_dollar_or_metavar_in_the_lhs_err( - sess, - &Token { kind: token::OpenDelim(delim), span: delim_span.entire() }, - ); - } - } else { - match delim { - token::Brace => { - // The delimiter is `{`. This indicates the beginning - // of a meta-variable expression (e.g. `${count(ident)}`). - // Try to parse the meta-variable expression. - match MetaVarExpr::parse(&tts, delim_span.entire(), sess) { - Err(mut err) => { - err.emit(); - // Returns early the same read `$` to avoid spanning - // unrelated diagnostics that could be performed afterwards - return TokenTree::token(token::Dollar, span); - } - Ok(elem) => { - maybe_emit_macro_metavar_expr_feature( - features, - sess, - delim_span.entire(), - ); - return TokenTree::MetaVarExpr(delim_span, elem); - } - } - } - token::Paren => {} - _ => { - let tok = pprust::token_kind_to_string(&token::OpenDelim(delim)); - let msg = format!("expected `(` or `{{`, found `{}`", tok); - sess.span_diagnostic.span_err(delim_span.entire(), &msg); - } - } + // `tree` is followed by a delimited set of token trees. This indicates the beginning + // of a repetition sequence in the macro (e.g. `$(pat)*`). + Some(tokenstream::TokenTree::Delimited(span, delim, tts)) => { + // Must have `(` not `{` or `[` + if delim != token::Paren { + let tok = pprust::token_kind_to_string(&token::OpenDelim(delim)); + let msg = format!("expected `(`, found `{}`", tok); + sess.span_diagnostic.span_err(span.entire(), &msg); } - // If we didn't find a metavar expression above, then we must have a - // repetition sequence in the macro (e.g. `$(pat)*`). Parse the - // contents of the sequence itself - let sequence = parse(tts, parsing_patterns, sess, node_id, features, edition); + // Parse the contents of the sequence itself + let sequence = parse(tts, expect_matchers, sess, node_id, features, edition); // Get the Kleene operator and optional separator let (separator, kleene) = - parse_sep_and_kleene_op(&mut trees, delim_span.entire(), sess); + parse_sep_and_kleene_op(&mut trees, span.entire(), sess); // Count the number of captured "names" (i.e., named metavars) let name_captures = macro_parser::count_names(&sequence); TokenTree::Sequence( - delim_span, + span, Lrc::new(SequenceRepetition { tts: sequence, separator, @@ -237,20 +197,7 @@ fn parse_tree( } } - // `tree` is followed by another `$`. This is an escaped `$`. - Some(tokenstream::TokenTree::Token(Token { kind: token::Dollar, span })) => { - if parsing_patterns { - span_dollar_dollar_or_metavar_in_the_lhs_err( - sess, - &Token { kind: token::Dollar, span }, - ); - } else { - maybe_emit_macro_metavar_expr_feature(features, sess, span); - } - TokenTree::token(token::Dollar, span) - } - - // `tree` is followed by some other token. This is an error. + // `tree` is followed by a random token. This is an error. Some(tokenstream::TokenTree::Token(token)) => { let msg = format!( "expected identifier, found `{}`", @@ -274,7 +221,7 @@ fn parse_tree( span, Lrc::new(Delimited { delim, - tts: parse(tts, parsing_patterns, sess, node_id, features, edition), + tts: parse(tts, expect_matchers, sess, node_id, features, edition), }), ), } @@ -362,15 +309,3 @@ fn parse_sep_and_kleene_op( // Return a dummy (None, KleeneToken::new(KleeneOp::ZeroOrMore, span)) } - -// `$$` or a meta-variable is the lhs of a macro but shouldn't. -// -// For example, `macro_rules! foo { ( ${length()} ) => {} }` -fn span_dollar_dollar_or_metavar_in_the_lhs_err<'sess>(sess: &'sess ParseSess, token: &Token) { - sess.span_diagnostic - .span_err(token.span, &format!("unexpected token: {}", pprust::token_to_string(token))); - sess.span_diagnostic.span_note_without_error( - token.span, - "`$$` and meta-variable expressions are not allowed inside macro parameter definitions", - ); -} diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 5ec63739cf574..5e0b6a1ccb62f 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -255,11 +255,6 @@ pub(super) fn transcribe<'a>( } } - // Replace meta-variable expressions with the result of their expansion. - mbe::TokenTree::MetaVarExpr(sp, expr) => { - transcribe_metavar_expr(cx, expr, interp, &repeats, &mut result, &sp)?; - } - // If we are entering a new delimiter, we push its contents to the `stack` to be // processed, and we push all of the currently produced results to the `result_stack`. // We will produce all of the results of the inside of the `Delimited` and then we will @@ -396,165 +391,7 @@ fn lockstep_iter_size( _ => LockstepIterSize::Unconstrained, } } - TokenTree::MetaVarExpr(_, ref expr) => { - let default_rslt = LockstepIterSize::Unconstrained; - let Some(ident) = expr.ident() else { return default_rslt; }; - let name = MacroRulesNormalizedIdent::new(ident); - match lookup_cur_matched(name, interpolations, repeats) { - Some(MatchedSeq(ref ads)) => { - default_rslt.with(LockstepIterSize::Constraint(ads.len(), name)) - } - _ => default_rslt, - } - } - TokenTree::Token(..) => LockstepIterSize::Unconstrained, - } -} - -/// Used solely by the `count` meta-variable expression, counts the outer-most repetitions at a -/// given optional nested depth. -/// -/// For example, a macro parameter of `$( { $( $foo:ident ),* } )*` called with `{ a, b } { c }`: -/// -/// * `[ $( ${count(foo)} ),* ]` will return [2, 1] with a, b = 2 and c = 1 -/// * `[ $( ${count(foo, 0)} ),* ]` will be the same as `[ $( ${count(foo)} ),* ]` -/// * `[ $( ${count(foo, 1)} ),* ]` will return an error because `${count(foo, 1)}` is -/// declared inside a single repetition and the index `1` implies two nested repetitions. -fn count_repetitions<'a>( - cx: &ExtCtxt<'a>, - depth_opt: Option, - mut matched: &NamedMatch, - repeats: &[(usize, usize)], - sp: &DelimSpan, -) -> PResult<'a, usize> { - // Recursively count the number of matches in `matched` at given depth - // (or at the top-level of `matched` if no depth is given). - fn count<'a>( - cx: &ExtCtxt<'a>, - declared_lhs_depth: usize, - depth_opt: Option, - matched: &NamedMatch, - sp: &DelimSpan, - ) -> PResult<'a, usize> { - match matched { - MatchedNonterminal(_) => { - if declared_lhs_depth == 0 { - return Err(cx.struct_span_err( - sp.entire(), - "`count` can not be placed inside the inner-most repetition", - )); - } - match depth_opt { - None => Ok(1), - Some(_) => Err(out_of_bounds_err(cx, declared_lhs_depth, sp.entire(), "count")), - } - } - MatchedSeq(ref named_matches) => { - let new_declared_lhs_depth = declared_lhs_depth + 1; - match depth_opt { - None => named_matches - .iter() - .map(|elem| count(cx, new_declared_lhs_depth, None, elem, sp)) - .sum(), - Some(0) => Ok(named_matches.len()), - Some(depth) => named_matches - .iter() - .map(|elem| count(cx, new_declared_lhs_depth, Some(depth - 1), elem, sp)) - .sum(), - } - } - } - } - // `repeats` records all of the nested levels at which we are currently - // matching meta-variables. The meta-var-expr `count($x)` only counts - // matches that occur in this "subtree" of the `NamedMatch` where we - // are currently transcribing, so we need to descend to that subtree - // before we start counting. `matched` contains the various levels of the - // tree as we descend, and its final value is the subtree we are currently at. - for &(idx, _) in repeats { - if let MatchedSeq(ref ads) = matched { - matched = &ads[idx]; - } - } - count(cx, 0, depth_opt, matched, sp) -} -/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident] -fn matched_from_ident<'ctx, 'interp, 'rslt>( - cx: &ExtCtxt<'ctx>, - ident: Ident, - interp: &'interp FxHashMap, -) -> PResult<'ctx, &'rslt NamedMatch> -where - 'interp: 'rslt, -{ - let span = ident.span; - let key = MacroRulesNormalizedIdent::new(ident); - interp.get(&key).ok_or_else(|| { - cx.struct_span_err( - span, - &format!("variable `{}` is not recognized in meta-variable expression", key), - ) - }) -} - -/// Used by meta-variable expressions when an user input is out of the actual declared bounds. For -/// example, index(999999) in an repetition of only three elements. -fn out_of_bounds_err<'a>( - cx: &ExtCtxt<'a>, - max: usize, - span: Span, - ty: &str, -) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - cx.struct_span_err(span, &format!("{ty} depth must be less than {max}")) -} - -fn transcribe_metavar_expr<'a>( - cx: &ExtCtxt<'a>, - expr: MetaVarExpr, - interp: &FxHashMap, - repeats: &[(usize, usize)], - result: &mut Vec, - sp: &DelimSpan, -) -> PResult<'a, ()> { - match expr { - MetaVarExpr::Count(original_ident, depth_opt) => { - let matched = matched_from_ident(cx, original_ident, interp)?; - let count = count_repetitions(cx, depth_opt, matched, &repeats, sp)?; - let tt = TokenTree::token( - TokenKind::lit(token::Integer, sym::integer(count), None), - sp.entire(), - ); - result.push(tt.into()); - } - MetaVarExpr::Ignore(original_ident) => { - // Used to ensure that `original_ident` is present in the LHS - let _ = matched_from_ident(cx, original_ident, interp)?; - } - MetaVarExpr::Index(depth) => match repeats.iter().nth_back(depth) { - Some((index, _)) => { - result.push( - TokenTree::token( - TokenKind::lit(token::Integer, sym::integer(*index), None), - sp.entire(), - ) - .into(), - ); - } - None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "index")), - }, - MetaVarExpr::Length(depth) => match repeats.iter().nth_back(depth) { - Some((_, length)) => { - result.push( - TokenTree::token( - TokenKind::lit(token::Integer, sym::integer(*length), None), - sp.entire(), - ) - .into(), - ); - } - None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "length")), - }, + TokenTree::Token(..) => LockstepIterSize::Unconstrained, } - Ok(()) } diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index d9748b19e13fe..bb43715d49bca 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -430,8 +430,6 @@ declare_features! ( (active, link_cfg, "1.14.0", Some(37406), None), /// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check. (active, lint_reasons, "1.31.0", Some(54503), None), - /// Give access to additional metadata about declarative macro meta-variables. - (active, macro_metavar_expr, "1.61.0", Some(83527), None), /// Allows `#[marker]` on certain traits allowing overlapping implementations. (active, marker_trait_attr, "1.30.0", Some(29864), None), /// A minimal, sound subset of specialization intended to be used by the diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 8539e8868e2c7..62eba796eae54 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3400,7 +3400,7 @@ declare_lint! { /// // ^^^^^^^^ /// // This call to try_into matches both Foo:try_into and TryInto::try_into as /// // `TryInto` has been added to the Rust prelude in 2021 edition. - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` /// diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index 1446f7dac3638..47a1712cad56c 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -281,7 +281,7 @@ pub struct CaptureInfo { /// let mut t = (0,1); /// /// let c = || { - /// println!("{t}"); // L1 + /// println!("{}",t); // L1 /// t.1 = 4; // L2 /// }; /// ``` diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 4dd1c3fed6b36..856b405d92a47 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -847,7 +847,6 @@ symbols! { macro_export, macro_lifetime_matcher, macro_literal_matcher, - macro_metavar_expr, macro_reexport, macro_use, macro_vis_matcher, diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 1a94b7261f7ab..142f976a4110f 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -458,10 +458,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// let s: String; // hir_id_s /// let mut p: Point; // his_id_p /// let c = || { - /// println!("{s}"); // L1 + /// println!("{}", s); // L1 /// p.x += 10; // L2 - /// println!("{}" , p.y); // L3 - /// println!("{p}"); // L4 + /// println!("{}" , p.y) // L3 + /// println!("{}", p) // L4 /// drop(s); // L5 /// }; /// ``` diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index bd7d721b5e173..9d4f9af91a5e1 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -397,7 +397,7 @@ pub mod __alloc_error_handler { // if there is no `#[alloc_error_handler]` #[rustc_std_internal_symbol] pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! { - panic!("memory allocation of {size} bytes failed") + panic!("memory allocation of {} bytes failed", size) } // if there is an `#[alloc_error_handler]` diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 8b13e36c4b3c7..63234ee91f091 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -161,7 +161,7 @@ where /// let readonly = [1, 2]; /// let borrowed = Items::new((&readonly[..]).into()); /// match borrowed { -/// Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"), +/// Items { values: Cow::Borrowed(b) } => println!("borrowed {:?}", b), /// _ => panic!("expect borrowed value"), /// } /// diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 7dce3db0a4766..f753189c68308 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -31,7 +31,7 @@ //! } //! //! let list: List = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil)))); -//! println!("{list:?}"); +//! println!("{:?}", list); //! ``` //! //! This will print `Cons(1, Cons(2, Nil))`. @@ -1407,7 +1407,7 @@ impl From<&[T]> for Box<[T]> { /// let slice: &[u8] = &[104, 101, 108, 108, 111]; /// let boxed_slice: Box<[u8]> = Box::from(slice); /// - /// println!("{boxed_slice:?}"); + /// println!("{:?}", boxed_slice); /// ``` fn from(slice: &[T]) -> Box<[T]> { let len = slice.len(); @@ -1449,7 +1449,7 @@ impl From<&str> for Box { /// /// ```rust /// let boxed: Box = Box::from("hello"); - /// println!("{boxed}"); + /// println!("{}", boxed); /// ``` #[inline] fn from(s: &str) -> Box { @@ -1474,14 +1474,14 @@ impl From> for Box { /// /// let unboxed = Cow::Borrowed("hello"); /// let boxed: Box = Box::from(unboxed); - /// println!("{boxed}"); + /// println!("{}", boxed); /// ``` /// /// ```rust /// # use std::borrow::Cow; /// let unboxed = Cow::Owned("hello".to_string()); /// let boxed: Box = Box::from(unboxed); - /// println!("{boxed}"); + /// println!("{}", boxed); /// ``` #[inline] fn from(cow: Cow<'_, str>) -> Box { @@ -1528,7 +1528,7 @@ impl From<[T; N]> for Box<[T]> { /// /// ```rust /// let boxed: Box<[u8]> = Box::from([4, 2]); - /// println!("{boxed:?}"); + /// println!("{:?}", boxed); /// ``` fn from(array: [T; N]) -> Box<[T]> { box array diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index e6c3d38dab3a2..eff21e5c11e7c 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -194,7 +194,7 @@ use super::SpecExtend; /// // We can iterate over the items in the heap, although they are returned in /// // a random order. /// for x in &heap { -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // If we instead pop these scores, they should come back in order. @@ -830,7 +830,7 @@ impl BinaryHeap { /// /// // Print 1, 2, 3, 4 in arbitrary order /// for x in heap.iter() { - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -1110,7 +1110,7 @@ impl BinaryHeap { /// /// // Will print in some order /// for x in vec { - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` #[must_use = "`self` will be dropped if the result is not used"] @@ -1179,7 +1179,7 @@ impl BinaryHeap { /// assert!(!heap.is_empty()); /// /// for x in heap.drain() { - /// println!("{x}"); + /// println!("{}", x); /// } /// /// assert!(heap.is_empty()); @@ -1624,7 +1624,7 @@ impl IntoIterator for BinaryHeap { /// // Print 1, 2, 3, 4 in arbitrary order /// for x in heap.into_iter() { /// // x has type i32, not &i32 - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` fn into_iter(self) -> IntoIter { diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index d0ff3eb747598..12c9952558005 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -104,8 +104,8 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; /// let to_find = ["Up!", "Office Space"]; /// for movie in &to_find { /// match movie_reviews.get(movie) { -/// Some(review) => println!("{movie}: {review}"), -/// None => println!("{movie} is unreviewed.") +/// Some(review) => println!("{}: {}", movie, review), +/// None => println!("{} is unreviewed.", movie) /// } /// } /// @@ -114,7 +114,7 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; /// /// // iterate over everything. /// for (movie, review) in &movie_reviews { -/// println!("{movie}: \"{review}\""); +/// println!("{}: \"{}\"", movie, review); /// } /// ``` /// @@ -1061,7 +1061,7 @@ impl BTreeMap { /// map.insert(5, "b"); /// map.insert(8, "c"); /// for (&key, &value) in map.range((Included(&4), Included(&8))) { - /// println!("{key}: {value}"); + /// println!("{}: {}", key, value); /// } /// assert_eq!(Some((&5, &"b")), map.range(4..).next()); /// ``` @@ -1104,7 +1104,7 @@ impl BTreeMap { /// *balance += 100; /// } /// for (name, balance) in &map { - /// println!("{name} => {balance}"); + /// println!("{} => {}", name, balance); /// } /// ``` #[stable(feature = "btree_range", since = "1.17.0")] @@ -2088,7 +2088,7 @@ impl BTreeMap { /// map.insert(1, "a"); /// /// for (key, value) in map.iter() { - /// println!("{key}: {value}"); + /// println!("{}: {}", key, value); /// } /// /// let (first_key, first_value) = map.iter().next().unwrap(); diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 4d21df3241724..65468d5fe5716 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -1758,7 +1758,7 @@ fn test_ord_absence() { } fn map_debug(mut map: BTreeMap) { - format!("{map:?}"); + format!("{:?}", map); format!("{:?}", map.iter()); format!("{:?}", map.iter_mut()); format!("{:?}", map.keys()); diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index d6733425288d4..c6a15953e8710 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -60,7 +60,7 @@ use super::Recover; /// /// // Iterate over everything. /// for book in &books { -/// println!("{book}"); +/// println!("{}", book); /// } /// ``` /// @@ -284,7 +284,7 @@ impl BTreeSet { /// set.insert(5); /// set.insert(8); /// for &elem in set.range((Included(&4), Included(&8))) { - /// println!("{elem}"); + /// println!("{}", elem); /// } /// assert_eq!(Some(&5), set.range(4..).next()); /// ``` diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 032563e4f09be..7865d37ae51f1 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -431,10 +431,10 @@ fn test_show() { set.insert(1); set.insert(2); - let set_str = format!("{set:?}"); + let set_str = format!("{:?}", set); assert_eq!(set_str, "{1, 2}"); - assert_eq!(format!("{empty:?}"), "{}"); + assert_eq!(format!("{:?}", empty), "{}"); } #[test] @@ -649,7 +649,7 @@ fn test_ord_absence() { } fn set_debug(set: BTreeSet) { - format!("{set:?}"); + format!("{:?}", set); format!("{:?}", set.iter()); format!("{:?}", set.into_iter()); } diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 501a6353b2c97..aeb7554f8e914 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -416,9 +416,9 @@ //! fn main() { //! let myvector = Vector2D { x: 3, y: 4 }; //! -//! println!("{myvector}"); // => "(3, 4)" -//! println!("{myvector:?}"); // => "Vector2D {x: 3, y:4}" -//! println!("{myvector:10.3b}"); // => " 5.000" +//! println!("{}", myvector); // => "(3, 4)" +//! println!("{:?}", myvector); // => "Vector2D {x: 3, y:4}" +//! println!("{:10.3b}", myvector); // => " 5.000" //! } //! ``` //! diff --git a/library/alloc/src/rc/tests.rs b/library/alloc/src/rc/tests.rs index d7c28f8063337..843a9b07fa934 100644 --- a/library/alloc/src/rc/tests.rs +++ b/library/alloc/src/rc/tests.rs @@ -309,7 +309,7 @@ fn test_cowrc_clone_weak() { #[test] fn test_show() { let foo = Rc::new(75); - assert_eq!(format!("{foo:?}"), "75"); + assert_eq!(format!("{:?}", foo), "75"); } #[test] @@ -324,7 +324,7 @@ fn test_maybe_thin_unsized() { use std::ffi::{CStr, CString}; let x: Rc = Rc::from(CString::new("swordfish").unwrap().into_boxed_c_str()); - assert_eq!(format!("{x:?}"), "\"swordfish\""); + assert_eq!(format!("{:?}", x), "\"swordfish\""); let y: Weak = Rc::downgrade(&x); drop(x); @@ -451,7 +451,7 @@ fn test_from_box_trait_zero_sized() { let b: Box = box (); let r: Rc = Rc::from(b); - assert_eq!(format!("{r:?}"), "()"); + assert_eq!(format!("{:?}", r), "()"); } #[test] diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index f52871c73d9fc..f0397d08f95a8 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -48,7 +48,7 @@ //! ``` //! let numbers = &[0, 1, 2]; //! for n in numbers { -//! println!("{n} is a number!"); +//! println!("{} is a number!", n); //! } //! ``` //! diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 71419c151968d..716bb4983a651 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2718,7 +2718,7 @@ impl From for Vec { /// let v1 = Vec::from(s1); /// /// for b in v1 { - /// println!("{b}"); + /// println!("{}", b); /// } /// ``` fn from(string: String) -> Vec { diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 2140c3f168d1c..7e7670aad6425 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -200,7 +200,7 @@ macro_rules! acquire { /// let five = Arc::clone(&five); /// /// thread::spawn(move || { -/// println!("{five:?}"); +/// println!("{:?}", five); /// }); /// } /// ``` @@ -221,7 +221,7 @@ macro_rules! acquire { /// /// thread::spawn(move || { /// let v = val.fetch_add(1, Ordering::SeqCst); -/// println!("{v:?}"); +/// println!("{:?}", v); /// }); /// } /// ``` diff --git a/library/alloc/src/sync/tests.rs b/library/alloc/src/sync/tests.rs index 452a88773018c..4ccb32fbbf63d 100644 --- a/library/alloc/src/sync/tests.rs +++ b/library/alloc/src/sync/tests.rs @@ -335,7 +335,7 @@ fn test_weak_count() { #[test] fn show_arc() { let a = Arc::new(5); - assert_eq!(format!("{a:?}"), "5"); + assert_eq!(format!("{:?}", a), "5"); } // Make sure deriving works with Arc @@ -347,7 +347,7 @@ struct Foo { #[test] fn test_unsized() { let x: Arc<[i32]> = Arc::new([1, 2, 3]); - assert_eq!(format!("{x:?}"), "[1, 2, 3]"); + assert_eq!(format!("{:?}", x), "[1, 2, 3]"); let y = Arc::downgrade(&x.clone()); drop(x); assert!(y.upgrade().is_none()); @@ -359,7 +359,7 @@ fn test_maybe_thin_unsized() { use std::ffi::{CStr, CString}; let x: Arc = Arc::from(CString::new("swordfish").unwrap().into_boxed_c_str()); - assert_eq!(format!("{x:?}"), "\"swordfish\""); + assert_eq!(format!("{:?}", x), "\"swordfish\""); let y: Weak = Arc::downgrade(&x); drop(x); @@ -509,7 +509,7 @@ fn test_from_box_trait_zero_sized() { let b: Box = box (); let r: Arc = Arc::from(b); - assert_eq!(format!("{r:?}"), "()"); + assert_eq!(format!("{:?}", r), "()"); } #[test] diff --git a/library/alloc/src/tests.rs b/library/alloc/src/tests.rs index 299ed156a5d27..b4741c35c583f 100644 --- a/library/alloc/src/tests.rs +++ b/library/alloc/src/tests.rs @@ -47,8 +47,8 @@ fn any_move() { fn test_show() { let a = Box::new(8) as Box; let b = Box::new(Test) as Box; - let a_str = format!("{a:?}"); - let b_str = format!("{b:?}"); + let a_str = format!("{:?}", a); + let b_str = format!("{:?}", b); assert_eq!(a_str, "Any { .. }"); assert_eq!(b_str, "Any { .. }"); @@ -56,9 +56,9 @@ fn test_show() { static TEST: Test = Test; let a = &EIGHT as &dyn Any; let b = &TEST as &dyn Any; - let s = format!("{a:?}"); + let s = format!("{:?}", a); assert_eq!(s, "Any { .. }"); - let s = format!("{b:?}"); + let s = format!("{:?}", b); assert_eq!(s, "Any { .. }"); } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 5131168db0c82..b898bd8743f63 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -169,7 +169,7 @@ mod spec_extend; /// vec.extend([1, 2, 3].iter().copied()); /// /// for x in &vec { -/// println!("{x}"); +/// println!("{}", x); /// } /// assert_eq!(vec, [7, 1, 2, 3]); /// ``` @@ -211,7 +211,7 @@ mod spec_extend; /// /// while let Some(top) = stack.pop() { /// // Prints 3, 2, 1 -/// println!("{top}"); +/// println!("{}", top); /// } /// ``` /// @@ -1297,7 +1297,7 @@ impl Vec { #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { - panic!("swap_remove index (is {index}) should be < len (is {len})"); + panic!("swap_remove index (is {}) should be < len (is {})", index, len); } let len = self.len(); @@ -1338,7 +1338,7 @@ impl Vec { #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { - panic!("insertion index (is {index}) should be <= len (is {len})"); + panic!("insertion index (is {}) should be <= len (is {})", index, len); } let len = self.len(); @@ -1397,7 +1397,7 @@ impl Vec { #[inline(never)] #[track_caller] fn assert_failed(index: usize, len: usize) -> ! { - panic!("removal index (is {index}) should be < len (is {len})"); + panic!("removal index (is {}) should be < len (is {})", index, len); } let len = self.len(); @@ -1942,7 +1942,7 @@ impl Vec { #[cold] #[inline(never)] fn assert_failed(at: usize, len: usize) -> ! { - panic!("`at` split index (is {at}) should be <= len (is {len})"); + panic!("`at` split index (is {}) should be <= len (is {})", at, len); } if at > self.len() { @@ -2568,7 +2568,7 @@ impl IntoIterator for Vec { /// let v = vec!["a".to_string(), "b".to_string()]; /// for s in v.into_iter() { /// // s has type String, not &String - /// println!("{s}"); + /// println!("{}", s); /// } /// ``` #[inline] diff --git a/library/alloc/tests/fmt.rs b/library/alloc/tests/fmt.rs index 1575a5999f932..27ab6c07e4309 100644 --- a/library/alloc/tests/fmt.rs +++ b/library/alloc/tests/fmt.rs @@ -84,8 +84,8 @@ fn test_format_macro_interface() { } t!(format!("{:p}", 0x1234 as *const isize), "0x1234"); t!(format!("{:p}", 0x1234 as *mut isize), "0x1234"); - t!(format!("{A:x}"), "aloha"); - t!(format!("{B:X}"), "adios"); + t!(format!("{:x}", A), "aloha"); + t!(format!("{:X}", B), "adios"); t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃"); t!(format!("{1} {0}", 0, 1), "1 0"); t!(format!("{foo} {bar}", foo = 0, bar = 1), "0 1"); @@ -94,11 +94,11 @@ fn test_format_macro_interface() { t!(format!("{_foo}", _foo = 6usize), "6"); t!(format!("{foo_bar}", foo_bar = 1), "1"); t!(format!("{}", 5 + 5), "10"); - t!(format!("{C:#4}"), "☃123"); - t!(format!("{D:b}"), "aa☃bb"); + t!(format!("{:#4}", C), "☃123"); + t!(format!("{:b}", D), "aa☃bb"); let a: &dyn fmt::Debug = &1; - t!(format!("{a:?}"), "1"); + t!(format!("{:?}", a), "1"); // Formatting strings and their arguments t!(format!("{}", "a"), "a"); @@ -206,7 +206,7 @@ fn test_format_macro_interface() { // Test that pointers don't get truncated. { let val = usize::MAX; - let exp = format!("{val:#x}"); + let exp = format!("{:#x}", val); t!(format!("{:p}", val as *const isize), exp); } @@ -216,14 +216,14 @@ fn test_format_macro_interface() { // make sure that format! doesn't move out of local variables let a = Box::new(3); - format!("{a}"); - format!("{a}"); + format!("{}", a); + format!("{}", a); // make sure that format! doesn't cause spurious unused-unsafe warnings when // it's inside of an outer unsafe block unsafe { let a: isize = ::std::mem::transmute(3_usize); - format!("{a}"); + format!("{}", a); } // test that trailing commas are acceptable @@ -315,9 +315,9 @@ fn test_once() { #[test] fn test_refcell() { let refcell = RefCell::new(5); - assert_eq!(format!("{refcell:?}"), "RefCell { value: 5 }"); + assert_eq!(format!("{:?}", refcell), "RefCell { value: 5 }"); let borrow = refcell.borrow_mut(); - assert_eq!(format!("{refcell:?}"), "RefCell { value: }"); + assert_eq!(format!("{:?}", refcell), "RefCell { value: }"); drop(borrow); - assert_eq!(format!("{refcell:?}"), "RefCell { value: 5 }"); + assert_eq!(format!("{:?}", refcell), "RefCell { value: 5 }"); } diff --git a/library/alloc/tests/linked_list.rs b/library/alloc/tests/linked_list.rs index 66a9cca6644c4..5f5bd9af2fe5f 100644 --- a/library/alloc/tests/linked_list.rs +++ b/library/alloc/tests/linked_list.rs @@ -302,10 +302,10 @@ fn test_ord_nan() { #[test] fn test_show() { let list: LinkedList<_> = (0..10).collect(); - assert_eq!(format!("{list:?}"), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + assert_eq!(format!("{:?}", list), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let list: LinkedList<_> = ["just", "one", "test", "more"].into_iter().collect(); - assert_eq!(format!("{list:?}"), "[\"just\", \"one\", \"test\", \"more\"]"); + assert_eq!(format!("{:?}", list), "[\"just\", \"one\", \"test\", \"more\"]"); } #[test] diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index b027a25a146bc..b93d7938bc9a5 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1045,10 +1045,10 @@ fn test_split_iterators_size_hint() { a(v.rsplit_mut(p), b, "rsplit_mut"); for n in 0..=3 { - a(v.splitn(n, p), b, f!("splitn, n = {n}")); - a(v.splitn_mut(n, p), b, f!("splitn_mut, n = {n}")); - a(v.rsplitn(n, p), b, f!("rsplitn, n = {n}")); - a(v.rsplitn_mut(n, p), b, f!("rsplitn_mut, n = {n}")); + a(v.splitn(n, p), b, f!("splitn, n = {}", n)); + a(v.splitn_mut(n, p), b, f!("splitn_mut, n = {}", n)); + a(v.rsplitn(n, p), b, f!("rsplitn, n = {}", n)); + a(v.rsplitn_mut(n, p), b, f!("rsplitn_mut, n = {}", n)); } } } @@ -1184,8 +1184,8 @@ fn test_show() { macro_rules! test_show_vec { ($x:expr, $x_str:expr) => {{ let (x, x_str) = ($x, $x_str); - assert_eq!(format!("{x:?}"), x_str); - assert_eq!(format!("{x:?}"), x_str); + assert_eq!(format!("{:?}", x), x_str); + assert_eq!(format!("{:?}", x), x_str); }}; } let empty = Vec::::new(); diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index f3ed611acda5a..6b8be2506b64e 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -1259,7 +1259,7 @@ fn test_chars_debug() { let s = "ศไทย中华Việt Nam"; let c = s.chars(); assert_eq!( - format!("{c:?}"), + format!("{:?}", c), r#"Chars(['ศ', 'ไ', 'ท', 'ย', '中', '华', 'V', 'i', 'ệ', 't', ' ', 'N', 'a', 'm'])"# ); } @@ -1870,7 +1870,7 @@ mod pattern { } if let Some(err) = err { - panic!("Input skipped range at {err}"); + panic!("Input skipped range at {}", err); } if first_index != haystack.len() { @@ -2187,10 +2187,10 @@ fn utf8() { fn check_str_eq(a: String, b: String) { let mut i: isize = 0; for ab in a.bytes() { - println!("{i}"); - println!("{ab}"); + println!("{}", i); + println!("{}", ab); let bb: u8 = b.as_bytes()[i as usize]; - println!("{bb}"); + println!("{}", bb); assert_eq!(ab, bb); i += 1; } diff --git a/library/alloc/tests/string.rs b/library/alloc/tests/string.rs index b6836fdc88ee8..893283e5a2485 100644 --- a/library/alloc/tests/string.rs +++ b/library/alloc/tests/string.rs @@ -470,7 +470,7 @@ fn test_simple_types() { #[test] fn test_vectors() { let x: Vec = vec![]; - assert_eq!(format!("{x:?}"), "[]"); + assert_eq!(format!("{:?}", x), "[]"); assert_eq!(format!("{:?}", vec![1]), "[1]"); assert_eq!(format!("{:?}", vec![1, 2, 3]), "[1, 2, 3]"); assert!(format!("{:?}", vec![vec![], vec![1], vec![1, 1]]) == "[[], [1], [1, 1]]"); @@ -871,6 +871,6 @@ fn test_from_char() { fn test_str_concat() { let a: String = "hello".to_string(); let b: String = "world".to_string(); - let s: String = format!("{a}{b}"); + let s: String = format!("{}{}", a, b); assert_eq!(s.as_bytes()[9], 'd' as u8); } diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index ca0fcc855c7b8..705914b44971c 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -100,7 +100,7 @@ fn test_debug_fmt() { assert_eq!("[0, 1]", format!("{:?}", vec2)); let slice: &[isize] = &[4, 5]; - assert_eq!("[4, 5]", format!("{slice:?}")); + assert_eq!("[4, 5]", format!("{:?}", slice)); } #[test] @@ -918,7 +918,7 @@ fn test_into_iter_as_mut_slice() { fn test_into_iter_debug() { let vec = vec!['a', 'b', 'c']; let into_iter = vec.into_iter(); - let debug = format!("{into_iter:?}"); + let debug = format!("{:?}", into_iter); assert_eq!(debug, "IntoIter(['a', 'b', 'c'])"); } @@ -2336,7 +2336,7 @@ fn test_vec_dedup_panicking() { let ok = vec.iter().zip(expected.iter()).all(|(x, y)| x.index == y.index); if !ok { - panic!("expected: {expected:?}\ngot: {vec:?}\n"); + panic!("expected: {:?}\ngot: {:?}\n", expected, vec); } } diff --git a/library/alloc/tests/vec_deque.rs b/library/alloc/tests/vec_deque.rs index 89cc7f905be2c..18954f094c671 100644 --- a/library/alloc/tests/vec_deque.rs +++ b/library/alloc/tests/vec_deque.rs @@ -647,10 +647,10 @@ fn test_ord() { #[test] fn test_show() { let ringbuf: VecDeque<_> = (0..10).collect(); - assert_eq!(format!("{ringbuf:?}"), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"].iter().cloned().collect(); - assert_eq!(format!("{ringbuf:?}"), "[\"just\", \"one\", \"test\", \"more\"]"); + assert_eq!(format!("{:?}", ringbuf), "[\"just\", \"one\", \"test\", \"more\"]"); } #[test] diff --git a/library/core/benches/num/flt2dec/mod.rs b/library/core/benches/num/flt2dec/mod.rs index 32fd5e626bc1f..a1ce33d0bb49e 100644 --- a/library/core/benches/num/flt2dec/mod.rs +++ b/library/core/benches/num/flt2dec/mod.rs @@ -12,7 +12,7 @@ use test::Bencher; pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { FullDecoded::Finite(decoded) => decoded, - full_decoded => panic!("expected finite, got {full_decoded:?} instead"), + full_decoded => panic!("expected finite, got {:?} instead", full_decoded), } } diff --git a/library/core/benches/num/flt2dec/strategy/grisu.rs b/library/core/benches/num/flt2dec/strategy/grisu.rs index 8e47a046cdea5..76425731e1ddd 100644 --- a/library/core/benches/num/flt2dec/strategy/grisu.rs +++ b/library/core/benches/num/flt2dec/strategy/grisu.rs @@ -6,7 +6,7 @@ use test::Bencher; pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { FullDecoded::Finite(decoded) => decoded, - full_decoded => panic!("expected finite, got {full_decoded:?} instead"), + full_decoded => panic!("expected finite, got {:?} instead", full_decoded), } } diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 3b15ab1e6895b..72528185707a6 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -62,7 +62,7 @@ //! println!("String ({}): {}", as_string.len(), as_string); //! } //! None => { -//! println!("{value:?}"); +//! println!("{:?}", value); //! } //! } //! } diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 9dbb5eecd469b..aef7ad7756803 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -85,7 +85,7 @@ //! // of scope then the subsequent borrow would cause a dynamic thread panic. //! // This is the major hazard of using `RefCell`. //! let total: i32 = shared_map.borrow().values().sum(); -//! println!("{total}"); +//! println!("{}", total); //! } //! ``` //! diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 66de94d1b92dc..c4c0a5a6c78ad 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -370,7 +370,7 @@ impl char { /// /// ``` /// for c in '❤'.escape_unicode() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` @@ -448,7 +448,7 @@ impl char { /// /// ``` /// for c in '\n'.escape_debug() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` @@ -504,7 +504,7 @@ impl char { /// /// ``` /// for c in '"'.escape_default() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` @@ -949,7 +949,7 @@ impl char { /// /// ``` /// for c in 'İ'.to_lowercase() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` @@ -1016,7 +1016,7 @@ impl char { /// /// ``` /// for c in 'ß'.to_uppercase() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 84cf1753f86ba..90c5719f486cb 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -64,7 +64,7 @@ pub mod rt { /// /// let pythagorean_triple = Triangle { a: 3.0, b: 4.0, c: 5.0 }; /// -/// assert_eq!(format!("{pythagorean_triple}"), "(3, 4, 5)"); +/// assert_eq!(format!("{}", pythagorean_triple), "(3, 4, 5)"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub type Result = result::Result<(), Error>; @@ -174,7 +174,7 @@ pub trait Write { /// use std::fmt::{Error, Write}; /// /// fn writer(f: &mut W, s: &str) -> Result<(), Error> { - /// f.write_fmt(format_args!("{s}")) + /// f.write_fmt(format_args!("{}", s)) /// } /// /// let mut buf = String::new(); @@ -562,7 +562,7 @@ impl Display for Arguments<'_> { /// /// let origin = Point { x: 0, y: 0 }; /// -/// assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }"); +/// assert_eq!(format!("The origin is: {:?}", origin), "The origin is: Point { x: 0, y: 0 }"); /// ``` /// /// Manually implementing: @@ -586,7 +586,7 @@ impl Display for Arguments<'_> { /// /// let origin = Point { x: 0, y: 0 }; /// -/// assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }"); +/// assert_eq!(format!("The origin is: {:?}", origin), "The origin is: Point { x: 0, y: 0 }"); /// ``` /// /// There are a number of helper methods on the [`Formatter`] struct to help you with manual @@ -627,7 +627,7 @@ impl Display for Arguments<'_> { /// /// let origin = Point { x: 0, y: 0 }; /// -/// assert_eq!(format!("The origin is: {origin:#?}"), +/// assert_eq!(format!("The origin is: {:#?}", origin), /// "The origin is: Point { /// x: 0, /// y: 0, @@ -670,9 +670,9 @@ pub trait Debug { /// } /// /// let position = Position { longitude: 1.987, latitude: 2.983 }; - /// assert_eq!(format!("{position:?}"), "(1.987, 2.983)"); + /// assert_eq!(format!("{:?}", position), "(1.987, 2.983)"); /// - /// assert_eq!(format!("{position:#?}"), "( + /// assert_eq!(format!("{:#?}", position), "( /// 1.987, /// 2.983, /// )"); @@ -724,7 +724,7 @@ pub use macros::Debug; /// /// let origin = Point { x: 0, y: 0 }; /// -/// assert_eq!(format!("The origin is: {origin}"), "The origin is: (0, 0)"); +/// assert_eq!(format!("The origin is: {}", origin), "The origin is: (0, 0)"); /// ``` #[rustc_on_unimplemented( on( @@ -786,8 +786,8 @@ pub trait Display { /// ``` /// let x = 42; // 42 is '52' in octal /// -/// assert_eq!(format!("{x:o}"), "52"); -/// assert_eq!(format!("{x:#o}"), "0o52"); +/// assert_eq!(format!("{:o}", x), "52"); +/// assert_eq!(format!("{:#o}", x), "0o52"); /// /// assert_eq!(format!("{:o}", -16), "37777777760"); /// ``` @@ -809,9 +809,9 @@ pub trait Display { /// /// let l = Length(9); /// -/// assert_eq!(format!("l as octal is: {l:o}"), "l as octal is: 11"); +/// assert_eq!(format!("l as octal is: {:o}", l), "l as octal is: 11"); /// -/// assert_eq!(format!("l as octal is: {l:#06o}"), "l as octal is: 0o0011"); +/// assert_eq!(format!("l as octal is: {:#06o}", l), "l as octal is: 0o0011"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait Octal { @@ -840,8 +840,8 @@ pub trait Octal { /// ``` /// let x = 42; // 42 is '101010' in binary /// -/// assert_eq!(format!("{x:b}"), "101010"); -/// assert_eq!(format!("{x:#b}"), "0b101010"); +/// assert_eq!(format!("{:b}", x), "101010"); +/// assert_eq!(format!("{:#b}", x), "0b101010"); /// /// assert_eq!(format!("{:b}", -16), "11111111111111111111111111110000"); /// ``` @@ -863,10 +863,10 @@ pub trait Octal { /// /// let l = Length(107); /// -/// assert_eq!(format!("l as binary is: {l:b}"), "l as binary is: 1101011"); +/// assert_eq!(format!("l as binary is: {:b}", l), "l as binary is: 1101011"); /// /// assert_eq!( -/// format!("l as binary is: {l:#032b}"), +/// format!("l as binary is: {:#032b}", l), /// "l as binary is: 0b000000000000000000000001101011" /// ); /// ``` @@ -898,8 +898,8 @@ pub trait Binary { /// ``` /// let x = 42; // 42 is '2a' in hex /// -/// assert_eq!(format!("{x:x}"), "2a"); -/// assert_eq!(format!("{x:#x}"), "0x2a"); +/// assert_eq!(format!("{:x}", x), "2a"); +/// assert_eq!(format!("{:#x}", x), "0x2a"); /// /// assert_eq!(format!("{:x}", -16), "fffffff0"); /// ``` @@ -921,9 +921,9 @@ pub trait Binary { /// /// let l = Length(9); /// -/// assert_eq!(format!("l as hex is: {l:x}"), "l as hex is: 9"); +/// assert_eq!(format!("l as hex is: {:x}", l), "l as hex is: 9"); /// -/// assert_eq!(format!("l as hex is: {l:#010x}"), "l as hex is: 0x00000009"); +/// assert_eq!(format!("l as hex is: {:#010x}", l), "l as hex is: 0x00000009"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait LowerHex { @@ -953,8 +953,8 @@ pub trait LowerHex { /// ``` /// let x = 42; // 42 is '2A' in hex /// -/// assert_eq!(format!("{x:X}"), "2A"); -/// assert_eq!(format!("{x:#X}"), "0x2A"); +/// assert_eq!(format!("{:X}", x), "2A"); +/// assert_eq!(format!("{:#X}", x), "0x2A"); /// /// assert_eq!(format!("{:X}", -16), "FFFFFFF0"); /// ``` @@ -976,9 +976,9 @@ pub trait LowerHex { /// /// let l = Length(i32::MAX); /// -/// assert_eq!(format!("l as hex is: {l:X}"), "l as hex is: 7FFFFFFF"); +/// assert_eq!(format!("l as hex is: {:X}", l), "l as hex is: 7FFFFFFF"); /// -/// assert_eq!(format!("l as hex is: {l:#010X}"), "l as hex is: 0x7FFFFFFF"); +/// assert_eq!(format!("l as hex is: {:#010X}", l), "l as hex is: 0x7FFFFFFF"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait UpperHex { @@ -1003,7 +1003,7 @@ pub trait UpperHex { /// ``` /// let x = &42; /// -/// let address = format!("{x:p}"); // this produces something like '0x7f06092ac6d0' +/// let address = format!("{:p}", x); // this produces something like '0x7f06092ac6d0' /// ``` /// /// Implementing `Pointer` on a type: @@ -1024,9 +1024,9 @@ pub trait UpperHex { /// /// let l = Length(42); /// -/// println!("l is in memory here: {l:p}"); +/// println!("l is in memory here: {:p}", l); /// -/// let l_ptr = format!("{l:018p}"); +/// let l_ptr = format!("{:018p}", l); /// assert_eq!(l_ptr.len(), 18); /// assert_eq!(&l_ptr[..2], "0x"); /// ``` @@ -1054,7 +1054,7 @@ pub trait Pointer { /// ``` /// let x = 42.0; // 42.0 is '4.2e1' in scientific notation /// -/// assert_eq!(format!("{x:e}"), "4.2e1"); +/// assert_eq!(format!("{:e}", x), "4.2e1"); /// ``` /// /// Implementing `LowerExp` on a type: @@ -1074,12 +1074,12 @@ pub trait Pointer { /// let l = Length(100); /// /// assert_eq!( -/// format!("l in scientific notation is: {l:e}"), +/// format!("l in scientific notation is: {:e}", l), /// "l in scientific notation is: 1e2" /// ); /// /// assert_eq!( -/// format!("l in scientific notation is: {l:05e}"), +/// format!("l in scientific notation is: {:05e}", l), /// "l in scientific notation is: 001e2" /// ); /// ``` @@ -1105,7 +1105,7 @@ pub trait LowerExp { /// ``` /// let x = 42.0; // 42.0 is '4.2E1' in scientific notation /// -/// assert_eq!(format!("{x:E}"), "4.2E1"); +/// assert_eq!(format!("{:E}", x), "4.2E1"); /// ``` /// /// Implementing `UpperExp` on a type: @@ -1125,12 +1125,12 @@ pub trait LowerExp { /// let l = Length(100); /// /// assert_eq!( -/// format!("l in scientific notation is: {l:E}"), +/// format!("l in scientific notation is: {:E}", l), /// "l in scientific notation is: 1E2" /// ); /// /// assert_eq!( -/// format!("l in scientific notation is: {l:05E}"), +/// format!("l in scientific notation is: {:05E}", l), /// "l in scientific notation is: 001E2" /// ); /// ``` @@ -1429,8 +1429,8 @@ impl<'a> Formatter<'a> { /// } /// } /// - /// assert_eq!(&format!("{Foo:<4}"), "Foo "); - /// assert_eq!(&format!("{Foo:0>4}"), "0Foo"); + /// assert_eq!(&format!("{:<4}", Foo), "Foo "); + /// assert_eq!(&format!("{:0>4}", Foo), "0Foo"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn pad(&mut self, s: &str) -> Result { @@ -1613,8 +1613,8 @@ impl<'a> Formatter<'a> { /// } /// } /// - /// assert_eq!(&format!("{Foo}"), "Foo"); - /// assert_eq!(&format!("{Foo:0>8}"), "Foo"); + /// assert_eq!(&format!("{}", Foo), "Foo"); + /// assert_eq!(&format!("{:0>8}", Foo), "Foo"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn write_str(&mut self, data: &str) -> Result { @@ -1670,18 +1670,18 @@ impl<'a> Formatter<'a> { /// let c = formatter.fill(); /// if let Some(width) = formatter.width() { /// for _ in 0..width { - /// write!(formatter, "{c}")?; + /// write!(formatter, "{}", c)?; /// } /// Ok(()) /// } else { - /// write!(formatter, "{c}") + /// write!(formatter, "{}", c) /// } /// } /// } /// /// // We set alignment to the right with ">". - /// assert_eq!(&format!("{Foo:G>3}"), "GGG"); - /// assert_eq!(&format!("{Foo:t>6}"), "tttttt"); + /// assert_eq!(&format!("{:G>3}", Foo), "GGG"); + /// assert_eq!(&format!("{:t>6}", Foo), "tttttt"); /// ``` #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] @@ -1711,14 +1711,14 @@ impl<'a> Formatter<'a> { /// } else { /// "into the void" /// }; - /// write!(formatter, "{s}") + /// write!(formatter, "{}", s) /// } /// } /// - /// assert_eq!(&format!("{Foo:<}"), "left"); - /// assert_eq!(&format!("{Foo:>}"), "right"); - /// assert_eq!(&format!("{Foo:^}"), "center"); - /// assert_eq!(&format!("{Foo}"), "into the void"); + /// assert_eq!(&format!("{:<}", Foo), "left"); + /// assert_eq!(&format!("{:>}", Foo), "right"); + /// assert_eq!(&format!("{:^}", Foo), "center"); + /// assert_eq!(&format!("{}", Foo), "into the void"); /// ``` #[must_use] #[stable(feature = "fmt_flags_align", since = "1.28.0")] diff --git a/library/core/src/iter/adapters/map.rs b/library/core/src/iter/adapters/map.rs index 4b03449972c9a..d2077a63e150a 100644 --- a/library/core/src/iter/adapters/map.rs +++ b/library/core/src/iter/adapters/map.rs @@ -34,7 +34,7 @@ use crate::ops::Try; /// /// for pair in ['a', 'b', 'c'].into_iter() /// .map(|letter| { c += 1; (letter, c) }) { -/// println!("{pair:?}"); +/// println!("{:?}", pair); /// } /// ``` /// @@ -52,7 +52,7 @@ use crate::ops::Try; /// for pair in ['a', 'b', 'c'].into_iter() /// .map(|letter| { c += 1; (letter, c) }) /// .rev() { -/// println!("{pair:?}"); +/// println!("{:?}", pair); /// } /// ``` #[must_use = "iterators are lazy and do nothing unless consumed"] diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index 5a987733134a4..65f56f64dbfa6 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -144,7 +144,7 @@ //! let values = vec![1, 2, 3, 4, 5]; //! //! for x in values { -//! println!("{x}"); +//! println!("{}", x); //! } //! ``` //! @@ -164,7 +164,7 @@ //! let values = vec![1, 2, 3, 4, 5]; //! //! for x in values { -//! println!("{x}"); +//! println!("{}", x); //! } //! ``` //! @@ -181,7 +181,7 @@ //! None => break, //! }; //! let x = next; -//! let () = { println!("{x}"); }; +//! let () = { println!("{}", x); }; //! }, //! }; //! result @@ -280,7 +280,7 @@ //! ``` //! # #![allow(unused_must_use)] //! let v = vec![1, 2, 3, 4, 5]; -//! v.iter().map(|x| println!("{x}")); +//! v.iter().map(|x| println!("{}", x)); //! ``` //! //! This will not print any values, as we only created an iterator, rather than @@ -297,10 +297,10 @@ //! ``` //! let v = vec![1, 2, 3, 4, 5]; //! -//! v.iter().for_each(|x| println!("{x}")); +//! v.iter().for_each(|x| println!("{}", x)); //! // or //! for x in &v { -//! println!("{x}"); +//! println!("{}", x); //! } //! ``` //! @@ -329,7 +329,7 @@ //! let five_numbers = numbers.take(5); //! //! for number in five_numbers { -//! println!("{number}"); +//! println!("{}", number); //! } //! ``` //! @@ -345,7 +345,7 @@ //! let ones = std::iter::repeat(1); //! let least = ones.min().unwrap(); // Oh no! An infinite loop! //! // `ones.min()` causes an infinite loop, so we won't reach this point! -//! println!("The smallest number one is {least}."); +//! println!("The smallest number one is {}.", least); //! ``` //! //! [`take`]: Iterator::take diff --git a/library/core/src/iter/sources/once.rs b/library/core/src/iter/sources/once.rs index 6e9ed0d3c5278..27bc3dcfd79e0 100644 --- a/library/core/src/iter/sources/once.rs +++ b/library/core/src/iter/sources/once.rs @@ -48,7 +48,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// /// // this will give us all of the files in .foo as well as .foorc /// for f in files { -/// println!("{f:?}"); +/// println!("{:?}", f); /// } /// ``` #[stable(feature = "iter_once", since = "1.2.0")] diff --git a/library/core/src/iter/sources/once_with.rs b/library/core/src/iter/sources/once_with.rs index d79f85c2559fe..cf6a3c1152452 100644 --- a/library/core/src/iter/sources/once_with.rs +++ b/library/core/src/iter/sources/once_with.rs @@ -52,7 +52,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// /// // this will give us all of the files in .foo as well as .foorc /// for f in files { -/// println!("{f:?}"); +/// println!("{:?}", f); /// } /// ``` #[inline] diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs index 7b75ab96ee7de..dee66e6e07283 100644 --- a/library/core/src/iter/traits/collect.rs +++ b/library/core/src/iter/traits/collect.rs @@ -227,7 +227,7 @@ pub trait FromIterator: Sized { /// { /// collection /// .into_iter() -/// .map(|item| format!("{item:?}")) +/// .map(|item| format!("{:?}", item)) /// .collect() /// } /// ``` @@ -345,7 +345,7 @@ impl IntoIterator for I { /// c.extend(vec![1, 2, 3]); /// /// // we've added these elements onto the end -/// assert_eq!("MyCollection([5, 6, 7, 1, 2, 3])", format!("{c:?}")); +/// assert_eq!("MyCollection([5, 6, 7, 1, 2, 3])", format!("{:?}", c)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait Extend { diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index bdf94c792c27c..a6aed6d210beb 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -281,7 +281,7 @@ pub trait DoubleEndedIterator: Iterator { /// let zero = "0".to_string(); /// /// let result = numbers.iter().rfold(zero, |acc, &x| { - /// format!("({x} + {acc})") + /// format!("({} + {})", x, acc) /// }); /// /// assert_eq!(result, "(1 + (2 + (3 + (4 + (5 + 0)))))"); diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index d980f5930810b..c35d0784dd5a4 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -709,13 +709,13 @@ pub trait Iterator { /// ``` /// # #![allow(unused_must_use)] /// // don't do this: - /// (0..5).map(|x| println!("{x}")); + /// (0..5).map(|x| println!("{}", x)); /// /// // it won't even execute, as it is lazy. Rust will warn you about this. /// /// // Instead, use for: /// for x in 0..5 { - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` #[inline] @@ -761,7 +761,7 @@ pub trait Iterator { /// (0..5).flat_map(|x| x * 100 .. x * 110) /// .enumerate() /// .filter(|&(i, x)| (i + x) % 3 == 0) - /// .for_each(|(i, x)| println!("{i}:{x}")); + /// .for_each(|(i, x)| println!("{}:{}", i, x)); /// ``` #[inline] #[stable(feature = "iterator_for_each", since = "1.21.0")] @@ -1575,17 +1575,17 @@ pub trait Iterator { /// .filter(|x| x % 2 == 0) /// .fold(0, |sum, i| sum + i); /// - /// println!("{sum}"); + /// println!("{}", sum); /// /// // let's add some inspect() calls to investigate what's happening /// let sum = a.iter() /// .cloned() - /// .inspect(|x| println!("about to filter: {x}")) + /// .inspect(|x| println!("about to filter: {}", x)) /// .filter(|x| x % 2 == 0) - /// .inspect(|x| println!("made it through filter: {x}")) + /// .inspect(|x| println!("made it through filter: {}", x)) /// .fold(0, |sum, i| sum + i); /// - /// println!("{sum}"); + /// println!("{}", sum); /// ``` /// /// This will print: @@ -1611,13 +1611,13 @@ pub trait Iterator { /// .map(|line| line.parse::()) /// .inspect(|num| { /// if let Err(ref e) = *num { - /// println!("Parsing error: {e}"); + /// println!("Parsing error: {}", e); /// } /// }) /// .filter_map(Result::ok) /// .sum(); /// - /// println!("Sum: {sum}"); + /// println!("Sum: {}", sum); /// ``` /// /// This will print: @@ -2205,7 +2205,7 @@ pub trait Iterator { /// /// let data = ["no_tea.txt", "stale_bread.json", "torrential_rain.png"]; /// - /// let res = data.iter().try_for_each(|x| writeln!(stdout(), "{x}")); + /// let res = data.iter().try_for_each(|x| writeln!(stdout(), "{}", x)); /// assert!(res.is_ok()); /// /// let mut it = data.iter().cloned(); @@ -2319,7 +2319,7 @@ pub trait Iterator { /// let zero = "0".to_string(); /// /// let result = numbers.iter().fold(zero, |acc, &x| { - /// format!("({acc} + {x})") + /// format!("({} + {})", acc, x) /// }); /// /// assert_eq!(result, "(((((0 + 1) + 2) + 3) + 4) + 5)"); diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index ba7ae55ec6f4b..65a2c3ff6edc9 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -895,7 +895,7 @@ pub(crate) mod builtin { /// /// ``` /// let path: &'static str = env!("PATH"); - /// println!("the $PATH variable at the time of compiling was: {path}"); + /// println!("the $PATH variable at the time of compiling was: {}", path); /// ``` /// /// You can customize the error message by passing a string as the second @@ -935,7 +935,7 @@ pub(crate) mod builtin { /// /// ``` /// let key: Option<&'static str> = option_env!("SECRET_KEY"); - /// println!("the secret key might be: {key:?}"); + /// println!("the secret key might be: {:?}", key); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_builtin_macro] @@ -1046,7 +1046,7 @@ pub(crate) mod builtin { /// /// ``` /// let current_line = line!(); - /// println!("defined on line: {current_line}"); + /// println!("defined on line: {}", current_line); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_builtin_macro] @@ -1074,7 +1074,7 @@ pub(crate) mod builtin { /// /// ``` /// let current_col = column!(); - /// println!("defined on column: {current_col}"); + /// println!("defined on column: {}", current_col); /// ``` /// /// `column!` counts Unicode code points, not bytes or graphemes. As a result, the first two @@ -1112,7 +1112,7 @@ pub(crate) mod builtin { /// /// ``` /// let this_file = file!(); - /// println!("defined in file: {this_file}"); + /// println!("defined in file: {}", this_file); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_builtin_macro] @@ -1176,7 +1176,7 @@ pub(crate) mod builtin { /// fn main() { /// let my_str = include_str!("spanish.in"); /// assert_eq!(my_str, "adiós\n"); - /// print!("{my_str}"); + /// print!("{}", my_str); /// } /// ``` /// @@ -1325,7 +1325,7 @@ pub(crate) mod builtin { /// fn main() { /// let my_string = include!("monkeys.in"); /// assert_eq!("🙈🙊🙉🙈🙊🙉", my_string); - /// println!("{my_string}"); + /// println!("{}", my_string); /// } /// ``` /// diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 82bac2640b405..71eea43aa54e1 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -219,7 +219,7 @@ pub trait StructuralEq { /// /// // `x` has moved into `y`, and so cannot be used /// -/// // println!("{x:?}"); // error: use of moved value +/// // println!("{:?}", x); // error: use of moved value /// ``` /// /// However, if a type implements `Copy`, it instead has 'copy semantics': @@ -236,7 +236,7 @@ pub trait StructuralEq { /// /// // `y` is a copy of `x` /// -/// println!("{x:?}"); // A-OK! +/// println!("{:?}", x); // A-OK! /// ``` /// /// It's important to note that in these two examples, the only difference is whether you diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs index 541adb69b8e2b..09c6b76ab3827 100644 --- a/library/core/src/num/dec2flt/mod.rs +++ b/library/core/src/num/dec2flt/mod.rs @@ -166,7 +166,7 @@ from_str_float_impl!(f64); /// use std::str::FromStr; /// /// if let Err(e) = f64::from_str("a.12") { -/// println!("Failed conversion to f64: {e}"); +/// println!("Failed conversion to f64: {}", e); /// } /// ``` #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index 1a223016dae0f..8a9ecbe98dff6 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -61,7 +61,7 @@ impl const From for TryFromIntError { /// /// ``` /// if let Err(e) = i32::from_str_radix("a12", 10) { -/// println!("Failed conversion to i32: {e}"); +/// println!("Failed conversion to i32: {}", e); /// } /// ``` #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index e2e569cb7ea81..964378cc9c3c6 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -106,7 +106,7 @@ pub trait Index { /// type Output = Weight; /// /// fn index(&self, index: Side) -> &Self::Output { -/// println!("Accessing {index:?}-side of balance immutably"); +/// println!("Accessing {:?}-side of balance immutably", index); /// match index { /// Side::Left => &self.left, /// Side::Right => &self.right, @@ -116,7 +116,7 @@ pub trait Index { /// /// impl IndexMut for Balance { /// fn index_mut(&mut self, index: Side) -> &mut Self::Output { -/// println!("Accessing {index:?}-side of balance mutably"); +/// println!("Accessing {:?}-side of balance mutably", index); /// match index { /// Side::Left => &mut self.left, /// Side::Right => &mut self.right, diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index a3b14847342cb..5029e0560b892 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -653,7 +653,7 @@ impl> RangeToInclusive { /// map.insert(8, "c"); /// /// for (key, value) in map.range((Excluded(3), Included(8))) { -/// println!("{key}: {value}"); +/// println!("{}: {}", key, value); /// } /// /// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next()); diff --git a/library/core/src/option.rs b/library/core/src/option.rs index de1628f83ade8..8387819368e41 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -34,7 +34,7 @@ //! // Pattern match to retrieve the value //! match result { //! // The division was valid -//! Some(x) => println!("Result: {x}"), +//! Some(x) => println!("Result: {}", x), //! // The division was invalid //! None => println!("Cannot divide by 0"), //! } @@ -66,7 +66,7 @@ //! //! fn check_optional(optional: Option>) { //! match optional { -//! Some(p) => println!("has value {p}"), +//! Some(p) => println!("has value {}", p), //! None => println!("has no value"), //! } //! } @@ -493,7 +493,7 @@ //! } //! //! match name_of_biggest_animal { -//! Some(name) => println!("the biggest animal is {name}"), +//! Some(name) => println!("the biggest animal is {}", name), //! None => println!("there are no animals :("), //! } //! ``` @@ -615,7 +615,7 @@ impl Option { /// // First, cast `Option` to `Option<&String>` with `as_ref`, /// // then consume *that* with `map`, leaving `text` on the stack. /// let text_length: Option = text.as_ref().map(|s| s.len()); - /// println!("still can print text: {text:?}"); + /// println!("still can print text: {:?}", text); /// ``` #[inline] #[rustc_const_stable(feature = "const_option", since = "1.48.0")] @@ -918,10 +918,10 @@ impl Option { /// let v = vec![1, 2, 3, 4, 5]; /// /// // prints "got: 4" - /// let x: Option<&usize> = v.get(3).inspect(|x| println!("got: {x}")); + /// let x: Option<&usize> = v.get(3).inspect(|x| println!("got: {}", x)); /// /// // prints nothing - /// let x: Option<&usize> = v.get(5).inspect(|x| println!("got: {x}")); + /// let x: Option<&usize> = v.get(5).inspect(|x| println!("got: {}", x)); /// ``` #[inline] #[unstable(feature = "result_option_inspect", issue = "91345")] @@ -1976,7 +1976,7 @@ impl<'a, T> const From<&'a Option> for Option<&'a T> { /// let s: Option = Some(String::from("Hello, Rustaceans!")); /// let o: Option = Option::from(&s).map(|ss: &String| ss.len()); /// - /// println!("Can still print s: {s:?}"); + /// println!("Can still print s: {:?}", s); /// /// assert_eq!(o, Some(18)); /// ``` diff --git a/library/core/src/panic/panic_info.rs b/library/core/src/panic/panic_info.rs index 1923155ebc15f..be8598fae09d7 100644 --- a/library/core/src/panic/panic_info.rs +++ b/library/core/src/panic/panic_info.rs @@ -16,7 +16,7 @@ use crate::panic::Location; /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(s) = panic_info.payload().downcast_ref::<&str>() { -/// println!("panic occurred: {s:?}"); +/// println!("panic occurred: {:?}", s); /// } else { /// println!("panic occurred"); /// } @@ -75,7 +75,7 @@ impl<'a> PanicInfo<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(s) = panic_info.payload().downcast_ref::<&str>() { - /// println!("panic occurred: {s:?}"); + /// println!("panic occurred: {:?}", s); /// } else { /// println!("panic occurred"); /// } diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index a908b1f3ba4ce..89cebaa653f4b 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -39,7 +39,7 @@ use crate::panic::{Location, PanicInfo}; #[rustc_const_unstable(feature = "core_panic", issue = "none")] #[lang = "panic"] // needed by codegen for panic on overflow and other `Assert` MIR terminators pub const fn panic(expr: &'static str) -> ! { - // Use Arguments::new_v1 instead of format_args!("{expr}") to potentially + // Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially // reduce size overhead. The format_args! macro uses str's Display trait to // write expr, which calls Formatter::pad, which must accommodate string // truncation and padding (even though none is used here). Using @@ -81,7 +81,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! { super::intrinsics::abort() } - panic!("index out of bounds: the len is {len} but the index is {index}") + panic!("index out of bounds: the len is {} but the index is {}", len, index) } // This function is called directly by the codegen backend, and must not have diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 225a679efd221..ebb1d8971b99d 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -607,7 +607,7 @@ mod prim_pointer {} /// /// // This loop prints: 0 1 2 /// for x in array { -/// print!("{x} "); +/// print!("{} ", x); /// } /// ``` /// @@ -646,19 +646,19 @@ mod prim_pointer {} /// // This creates a slice iterator, producing references to each value. /// for item in array.into_iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// /// // The `array_into_iter` lint suggests this change for future compatibility: /// for item in array.iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// /// // You can explicitly iterate an array by value using `IntoIterator::into_iter` /// for item in IntoIterator::into_iter(array).enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// ``` /// @@ -673,13 +673,13 @@ mod prim_pointer {} /// // This iterates by reference: /// for item in array.iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// /// // This iterates by value: /// for item in array.into_iter().enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// ``` /// @@ -702,26 +702,26 @@ mod prim_pointer {} /// // This iterates by reference: /// for item in array.iter() { /// let x: &i32 = item; -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // This iterates by value: /// for item in IntoIterator::into_iter(array) { /// let x: i32 = item; -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // This iterates by value: /// for item in array { /// let x: i32 = item; -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // IntoIter can also start a chain. /// // This iterates by value: /// for item in IntoIterator::into_iter(array).enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// ``` /// diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 753220669831f..ee544b4842e86 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -153,7 +153,7 @@ impl *const T { /// /// unsafe { /// if let Some(val_back) = ptr.as_ref() { - /// println!("We got back the value: {val_back}!"); + /// println!("We got back the value: {}!", val_back); /// } /// } /// ``` @@ -169,7 +169,7 @@ impl *const T { /// /// unsafe { /// let val_back = &*ptr; - /// println!("We got back the value: {val_back}!"); + /// println!("We got back the value: {}!", val_back); /// } /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 861412703d3c6..3374b48c88c6b 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -160,7 +160,7 @@ impl *mut T { /// /// unsafe { /// if let Some(val_back) = ptr.as_ref() { - /// println!("We got back the value: {val_back}!"); + /// println!("We got back the value: {}!", val_back); /// } /// } /// ``` @@ -176,7 +176,7 @@ impl *mut T { /// /// unsafe { /// let val_back = &*ptr; - /// println!("We got back the value: {val_back}!"); + /// println!("We got back the value: {}!", val_back); /// } /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] @@ -409,7 +409,7 @@ impl *mut T { /// let first_value = unsafe { ptr.as_mut().unwrap() }; /// *first_value = 4; /// # assert_eq!(s, [4, 2, 3]); - /// println!("{s:?}"); // It'll print: "[4, 2, 3]". + /// println!("{:?}", s); // It'll print: "[4, 2, 3]". /// ``` /// /// # Null-unchecked version @@ -424,7 +424,7 @@ impl *mut T { /// let first_value = unsafe { &mut *ptr }; /// *first_value = 4; /// # assert_eq!(s, [4, 2, 3]); - /// println!("{s:?}"); // It'll print: "[4, 2, 3]". + /// println!("{:?}", s); // It'll print: "[4, 2, 3]". /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index a698aec51ca71..c744ad5dd2deb 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -314,7 +314,7 @@ impl NonNull { /// let ptr = NonNull::new(&mut x as *mut _).expect("ptr is null!"); /// /// let ref_x = unsafe { ptr.as_ref() }; - /// println!("{ref_x}"); + /// println!("{}", ref_x); /// ``` /// /// [the module documentation]: crate::ptr#safety diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 9a243cbc3a2a0..e400b4482c282 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -35,8 +35,8 @@ //! //! let version = parse_version(&[1, 2, 3, 4]); //! match version { -//! Ok(v) => println!("working with version: {v:?}"), -//! Err(e) => println!("error parsing header: {e:?}"), +//! Ok(v) => println!("working with version: {:?}", v), +//! Err(e) => println!("error parsing header: {:?}", e), //! } //! ``` //! @@ -447,9 +447,9 @@ //! .collect(); //! assert_eq!(errs.len(), 3); //! assert_eq!(nums, [17, 99]); -//! println!("results {results:?}"); -//! println!("errs {errs:?}"); -//! println!("nums {nums:?}"); +//! println!("results {:?}", results); +//! println!("errs {:?}", errs); +//! println!("nums {:?}", nums); //! ``` //! //! ## Collecting into `Result` @@ -756,7 +756,7 @@ impl Result { /// /// for num in line.lines() { /// match num.parse::().map(|i| i * 2) { - /// Ok(n) => println!("{n}"), + /// Ok(n) => println!("{}", n), /// Err(..) => {} /// } /// } @@ -838,7 +838,7 @@ impl Result { /// Basic usage: /// /// ``` - /// fn stringify(x: u32) -> String { format!("error code: {x}") } + /// fn stringify(x: u32) -> String { format!("error code: {}", x) } /// /// let x: Result = Ok(2); /// assert_eq!(x.map_err(stringify), Ok(2)); @@ -864,7 +864,7 @@ impl Result { /// /// let x: u8 = "4" /// .parse::() - /// .inspect(|x| println!("original: {x}")) + /// .inspect(|x| println!("original: {}", x)) /// .map(|x| x.pow(3)) /// .expect("failed to parse number"); /// ``` @@ -889,7 +889,7 @@ impl Result { /// /// fn read() -> io::Result { /// fs::read_to_string("address.txt") - /// .inspect_err(|e| eprintln!("failed to read file: {e}")) + /// .inspect_err(|e| eprintln!("failed to read file: {}", e)) /// } /// ``` #[inline] @@ -1198,7 +1198,7 @@ impl Result { /// } /// /// let s: String = only_good_news().into_ok(); - /// println!("{s}"); + /// println!("{}", s); /// ``` #[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")] #[inline] @@ -1235,7 +1235,7 @@ impl Result { /// } /// /// let error: String = only_bad_news().into_err(); - /// println!("{error}"); + /// println!("{}", error); /// ``` #[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")] #[inline] @@ -1781,7 +1781,7 @@ impl Result { #[cold] #[track_caller] fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! { - panic!("{msg}: {error:?}") + panic!("{}: {:?}", msg, error) } // This is a separate function to avoid constructing a `dyn Debug` diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 3353c239866af..7e6fbbe353889 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -48,7 +48,7 @@ const fn slice_start_index_len_fail(index: usize, len: usize) -> ! { // FIXME const-hack fn slice_start_index_len_fail_rt(index: usize, len: usize) -> ! { - panic!("range start index {index} out of range for slice of length {len}"); + panic!("range start index {} out of range for slice of length {}", index, len); } const fn slice_start_index_len_fail_ct(_: usize, _: usize) -> ! { @@ -69,7 +69,7 @@ const fn slice_end_index_len_fail(index: usize, len: usize) -> ! { // FIXME const-hack fn slice_end_index_len_fail_rt(index: usize, len: usize) -> ! { - panic!("range end index {index} out of range for slice of length {len}"); + panic!("range end index {} out of range for slice of length {}", index, len); } const fn slice_end_index_len_fail_ct(_: usize, _: usize) -> ! { @@ -88,7 +88,7 @@ const fn slice_index_order_fail(index: usize, end: usize) -> ! { // FIXME const-hack fn slice_index_order_fail_rt(index: usize, end: usize) -> ! { - panic!("slice index starts at {index} but ends at {end}"); + panic!("slice index starts at {} but ends at {}", index, end); } const fn slice_index_order_fail_ct(_: usize, _: usize) -> ! { diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 82bd7dbcf6cd2..d260cc69469cf 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -55,7 +55,7 @@ fn size_from_ptr(_: *const T) -> usize { /// /// // Then, we iterate over it: /// for element in slice.iter() { -/// println!("{element}"); +/// println!("{}", element); /// } /// ``` /// @@ -176,7 +176,7 @@ impl AsRef<[T]> for Iter<'_, T> { /// } /// /// // We now have "[2, 3, 4]": -/// println!("{slice:?}"); +/// println!("{:?}", slice); /// ``` /// /// [`iter_mut`]: slice::iter_mut @@ -266,7 +266,7 @@ impl<'a, T> IterMut<'a, T> { /// *iter.next().unwrap() += 1; /// } /// // Now slice is "[2, 2, 3]": - /// println!("{slice:?}"); + /// println!("{:?}", slice); /// ``` #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "iter_to_slice", since = "1.4.0")] diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index c0eb000e87791..3ef98a44ff25e 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -2011,7 +2011,7 @@ impl [T] { /// let v = [10, 40, 30, 20, 60, 50]; /// /// for group in v.splitn(2, |num| *num % 3 == 0) { - /// println!("{group:?}"); + /// println!("{:?}", group); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -2066,7 +2066,7 @@ impl [T] { /// let v = [10, 40, 30, 20, 60, 50]; /// /// for group in v.rsplitn(2, |num| *num % 3 == 0) { - /// println!("{group:?}"); + /// println!("{:?}", group); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index b1d36f2710737..f66bab999a98a 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -104,7 +104,7 @@ fn slice_error_fail_rt(s: &str, begin: usize, end: usize) -> ! { // 1. out of bounds if begin > s.len() || end > s.len() { let oob_index = if begin > s.len() { begin } else { end }; - panic!("byte index {oob_index} is out of bounds of `{s_trunc}`{ellipsis}"); + panic!("byte index {} is out of bounds of `{}`{}", oob_index, s_trunc, ellipsis); } // 2. begin <= end @@ -2446,7 +2446,7 @@ impl str { /// /// ``` /// for c in "❤\n!".escape_debug() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` @@ -2492,7 +2492,7 @@ impl str { /// /// ``` /// for c in "❤\n!".escape_default() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` @@ -2530,7 +2530,7 @@ impl str { /// /// ``` /// for c in "❤\n!".escape_unicode() { - /// print!("{c}"); + /// print!("{}", c); /// } /// println!(); /// ``` diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index a9edec80540dd..bc36798409b3b 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -94,7 +94,7 @@ //! } //! //! if let Err(panic) = thread.join() { -//! println!("Thread had an error: {panic:?}"); +//! println!("Thread had an error: {:?}", panic); //! } //! } //! ``` @@ -1419,7 +1419,7 @@ impl const From for AtomicBool { /// ``` /// use std::sync::atomic::AtomicBool; /// let atomic_bool = AtomicBool::from(true); - /// assert_eq!(format!("{atomic_bool:?}"), "true") + /// assert_eq!(format!("{:?}", atomic_bool), "true") /// ``` #[inline] fn from(b: bool) -> Self { diff --git a/library/core/src/time.rs b/library/core/src/time.rs index bd72d82b71c00..243c044b5d9d0 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -1214,7 +1214,7 @@ impl fmt::Debug for Duration { /// use std::time::Duration; /// /// if let Err(e) = Duration::try_from_secs_f32(-1.0) { -/// println!("Failed conversion to Duration: {e}"); +/// println!("Failed conversion to Duration: {}", e); /// } /// ``` #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/library/core/src/unit.rs b/library/core/src/unit.rs index 6656dd5c40beb..f41f4a5e94a76 100644 --- a/library/core/src/unit.rs +++ b/library/core/src/unit.rs @@ -9,7 +9,7 @@ use crate::iter::FromIterator; /// use std::io::*; /// let data = vec![1, 2, 3, 4, 5]; /// let res: Result<()> = data.iter() -/// .map(|x| writeln!(stdout(), "{x}")) +/// .map(|x| writeln!(stdout(), "{}", x)) /// .collect(); /// assert!(res.is_ok()); /// ``` diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs index eccddcbbf59fe..b36d6f0d40405 100644 --- a/library/core/tests/any.rs +++ b/library/core/tests/any.rs @@ -46,12 +46,12 @@ fn any_downcast_ref() { match a.downcast_ref::() { Some(&5) => {} - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } match a.downcast_ref::() { None => {} - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } } @@ -69,7 +69,7 @@ fn any_downcast_mut() { assert_eq!(*x, 5); *x = 612; } - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } match b_r.downcast_mut::() { @@ -77,27 +77,27 @@ fn any_downcast_mut() { assert_eq!(*x, 7); *x = 413; } - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } match a_r.downcast_mut::() { None => (), - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } match b_r.downcast_mut::() { None => (), - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } match a_r.downcast_mut::() { Some(&mut 612) => {} - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } match b_r.downcast_mut::() { Some(&mut 413) => {} - x => panic!("Unexpected value {x:?}"), + x => panic!("Unexpected value {:?}", x), } } diff --git a/library/core/tests/cell.rs b/library/core/tests/cell.rs index f15e03076caf7..4707cc7076ec0 100644 --- a/library/core/tests/cell.rs +++ b/library/core/tests/cell.rs @@ -62,10 +62,10 @@ fn cell_update() { #[test] fn cell_has_sensible_show() { let x = Cell::new("foo bar"); - assert!(format!("{x:?}").contains(x.get())); + assert!(format!("{:?}", x).contains(x.get())); x.set("baz qux"); - assert!(format!("{x:?}").contains(x.get())); + assert!(format!("{:?}", x).contains(x.get())); } #[test] @@ -73,11 +73,11 @@ fn ref_and_refmut_have_sensible_show() { let refcell = RefCell::new("foo"); let refcell_refmut = refcell.borrow_mut(); - assert!(format!("{refcell_refmut:?}").contains("foo")); + assert!(format!("{:?}", refcell_refmut).contains("foo")); drop(refcell_refmut); let refcell_ref = refcell.borrow(); - assert!(format!("{refcell_ref:?}").contains("foo")); + assert!(format!("{:?}", refcell_ref).contains("foo")); drop(refcell_ref); } diff --git a/library/core/tests/fmt/builders.rs b/library/core/tests/fmt/builders.rs index 487ce46be28d7..9567479c8137b 100644 --- a/library/core/tests/fmt/builders.rs +++ b/library/core/tests/fmt/builders.rs @@ -11,8 +11,8 @@ mod debug_struct { } } - assert_eq!("Foo", format!("{Foo:?}")); - assert_eq!("Foo", format!("{Foo:#?}")); + assert_eq!("Foo", format!("{:?}", Foo)); + assert_eq!("Foo", format!("{:#?}", Foo)); } #[test] @@ -25,12 +25,12 @@ mod debug_struct { } } - assert_eq!("Foo { bar: true }", format!("{Foo:?}")); + assert_eq!("Foo { bar: true }", format!("{:?}", Foo)); assert_eq!( "Foo { bar: true, }", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -47,13 +47,13 @@ mod debug_struct { } } - assert_eq!("Foo { bar: true, baz: 10/20 }", format!("{Foo:?}")); + assert_eq!("Foo { bar: true, baz: 10/20 }", format!("{:?}", Foo)); assert_eq!( "Foo { bar: true, baz: 10/20, }", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -80,7 +80,7 @@ mod debug_struct { assert_eq!( "Bar { foo: Foo { bar: true, baz: 10/20 }, hello: \"world\" }", - format!("{Bar:?}") + format!("{:?}", Bar) ); assert_eq!( "Bar { @@ -90,7 +90,7 @@ mod debug_struct { }, hello: \"world\", }", - format!("{Bar:#?}") + format!("{:#?}", Bar) ); } @@ -104,8 +104,8 @@ mod debug_struct { } } - assert_eq!("Foo { .. }", format!("{Foo:?}")); - assert_eq!("Foo { .. }", format!("{Foo:#?}")); + assert_eq!("Foo { .. }", format!("{:?}", Foo)); + assert_eq!("Foo { .. }", format!("{:#?}", Foo)); } #[test] @@ -121,14 +121,14 @@ mod debug_struct { } } - assert_eq!("Foo { bar: true, baz: 10/20, .. }", format!("{Foo:?}")); + assert_eq!("Foo { bar: true, baz: 10/20, .. }", format!("{:?}", Foo)); assert_eq!( "Foo { bar: true, baz: 10/20, .. }", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -158,7 +158,7 @@ mod debug_struct { assert_eq!( "Bar { foo: Foo { bar: true, baz: 10/20, .. }, hello: \"world\", .. }", - format!("{Bar:?}") + format!("{:?}", Bar) ); assert_eq!( "Bar { @@ -170,7 +170,7 @@ mod debug_struct { hello: \"world\", .. }", - format!("{Bar:#?}") + format!("{:#?}", Bar) ); } } @@ -188,8 +188,8 @@ mod debug_tuple { } } - assert_eq!("Foo", format!("{Foo:?}")); - assert_eq!("Foo", format!("{Foo:#?}")); + assert_eq!("Foo", format!("{:?}", Foo)); + assert_eq!("Foo", format!("{:#?}", Foo)); } #[test] @@ -202,12 +202,12 @@ mod debug_tuple { } } - assert_eq!("Foo(true)", format!("{Foo:?}")); + assert_eq!("Foo(true)", format!("{:?}", Foo)); assert_eq!( "Foo( true, )", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -221,13 +221,13 @@ mod debug_tuple { } } - assert_eq!("Foo(true, 10/20)", format!("{Foo:?}")); + assert_eq!("Foo(true, 10/20)", format!("{:?}", Foo)); assert_eq!( "Foo( true, 10/20, )", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -249,7 +249,7 @@ mod debug_tuple { } } - assert_eq!("Bar(Foo(true, 10/20), \"world\")", format!("{Bar:?}")); + assert_eq!("Bar(Foo(true, 10/20), \"world\")", format!("{:?}", Bar)); assert_eq!( "Bar( Foo( @@ -258,7 +258,7 @@ mod debug_tuple { ), \"world\", )", - format!("{Bar:#?}") + format!("{:#?}", Bar) ); } } @@ -276,8 +276,8 @@ mod debug_map { } } - assert_eq!("{}", format!("{Foo:?}")); - assert_eq!("{}", format!("{Foo:#?}")); + assert_eq!("{}", format!("{:?}", Foo)); + assert_eq!("{}", format!("{:#?}", Foo)); } #[test] @@ -298,15 +298,15 @@ mod debug_map { } } - assert_eq!(format!("{Entry:?}"), format!("{KeyValue:?}")); - assert_eq!(format!("{Entry:#?}"), format!("{KeyValue:#?}")); + assert_eq!(format!("{:?}", Entry), format!("{:?}", KeyValue)); + assert_eq!(format!("{:#?}", Entry), format!("{:#?}", KeyValue)); - assert_eq!("{\"bar\": true}", format!("{Entry:?}")); + assert_eq!("{\"bar\": true}", format!("{:?}", Entry)); assert_eq!( "{ \"bar\": true, }", - format!("{Entry:#?}") + format!("{:#?}", Entry) ); } @@ -336,16 +336,16 @@ mod debug_map { } } - assert_eq!(format!("{Entry:?}"), format!("{KeyValue:?}")); - assert_eq!(format!("{Entry:#?}"), format!("{KeyValue:#?}")); + assert_eq!(format!("{:?}", Entry), format!("{:?}", KeyValue)); + assert_eq!(format!("{:#?}", Entry), format!("{:#?}", KeyValue)); - assert_eq!("{\"bar\": true, 10: 10/20}", format!("{Entry:?}")); + assert_eq!("{\"bar\": true, 10: 10/20}", format!("{:?}", Entry)); assert_eq!( "{ \"bar\": true, 10: 10/20, }", - format!("{Entry:#?}") + format!("{:#?}", Entry) ); } @@ -373,7 +373,7 @@ mod debug_map { assert_eq!( "{\"foo\": {\"bar\": true, 10: 10/20}, \ {\"bar\": true, 10: 10/20}: \"world\"}", - format!("{Bar:?}") + format!("{:?}", Bar) ); assert_eq!( "{ @@ -386,7 +386,7 @@ mod debug_map { 10: 10/20, }: \"world\", }", - format!("{Bar:#?}") + format!("{:#?}", Bar) ); } @@ -441,7 +441,7 @@ mod debug_map { } } - format!("{Foo:?}"); + format!("{:?}", Foo); } #[test] @@ -455,7 +455,7 @@ mod debug_map { } } - format!("{Foo:?}"); + format!("{:?}", Foo); } #[test] @@ -469,7 +469,7 @@ mod debug_map { } } - format!("{Foo:?}"); + format!("{:?}", Foo); } } @@ -486,8 +486,8 @@ mod debug_set { } } - assert_eq!("{}", format!("{Foo:?}")); - assert_eq!("{}", format!("{Foo:#?}")); + assert_eq!("{}", format!("{:?}", Foo)); + assert_eq!("{}", format!("{:#?}", Foo)); } #[test] @@ -500,12 +500,12 @@ mod debug_set { } } - assert_eq!("{true}", format!("{Foo:?}")); + assert_eq!("{true}", format!("{:?}", Foo)); assert_eq!( "{ true, }", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -519,13 +519,13 @@ mod debug_set { } } - assert_eq!("{true, 10/20}", format!("{Foo:?}")); + assert_eq!("{true, 10/20}", format!("{:?}", Foo)); assert_eq!( "{ true, 10/20, }", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -547,7 +547,7 @@ mod debug_set { } } - assert_eq!("{{true, 10/20}, \"world\"}", format!("{Bar:?}")); + assert_eq!("{{true, 10/20}, \"world\"}", format!("{:?}", Bar)); assert_eq!( "{ { @@ -556,7 +556,7 @@ mod debug_set { }, \"world\", }", - format!("{Bar:#?}") + format!("{:#?}", Bar) ); } } @@ -574,8 +574,8 @@ mod debug_list { } } - assert_eq!("[]", format!("{Foo:?}")); - assert_eq!("[]", format!("{Foo:#?}")); + assert_eq!("[]", format!("{:?}", Foo)); + assert_eq!("[]", format!("{:#?}", Foo)); } #[test] @@ -588,12 +588,12 @@ mod debug_list { } } - assert_eq!("[true]", format!("{Foo:?}")); + assert_eq!("[true]", format!("{:?}", Foo)); assert_eq!( "[ true, ]", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -607,13 +607,13 @@ mod debug_list { } } - assert_eq!("[true, 10/20]", format!("{Foo:?}")); + assert_eq!("[true, 10/20]", format!("{:?}", Foo)); assert_eq!( "[ true, 10/20, ]", - format!("{Foo:#?}") + format!("{:#?}", Foo) ); } @@ -635,7 +635,7 @@ mod debug_list { } } - assert_eq!("[[true, 10/20], \"world\"]", format!("{Bar:?}")); + assert_eq!("[[true, 10/20], \"world\"]", format!("{:?}", Bar)); assert_eq!( "[ [ @@ -644,7 +644,7 @@ mod debug_list { ], \"world\", ]", - format!("{Bar:#?}") + format!("{:#?}", Bar) ); } } @@ -668,13 +668,13 @@ fn test_formatting_parameters_are_forwarded() { set.insert(1024); set.insert(7); - assert_eq!(format!("{struct_:03?}"), "Foo { bar: 1024, baz: 007 }"); - assert_eq!(format!("{tuple:03?}"), "(1024, 007)"); - assert_eq!(format!("{list:03?}"), "[1024, 007]"); - assert_eq!(format!("{map:03?}"), r#"{"bar": 1024, "baz": 007}"#); - assert_eq!(format!("{set:03?}"), "{007, 1024}"); + assert_eq!(format!("{:03?}", struct_), "Foo { bar: 1024, baz: 007 }"); + assert_eq!(format!("{:03?}", tuple), "(1024, 007)"); + assert_eq!(format!("{:03?}", list), "[1024, 007]"); + assert_eq!(format!("{:03?}", map), r#"{"bar": 1024, "baz": 007}"#); + assert_eq!(format!("{:03?}", set), "{007, 1024}"); assert_eq!( - format!("{struct_:#03?}"), + format!("{:#03?}", struct_), " Foo { bar: 1024, @@ -684,7 +684,7 @@ Foo { .trim() ); assert_eq!( - format!("{tuple:#03?}"), + format!("{:#03?}", tuple), " ( 1024, @@ -694,7 +694,7 @@ Foo { .trim() ); assert_eq!( - format!("{list:#03?}"), + format!("{:#03?}", list), " [ 1024, @@ -704,7 +704,7 @@ Foo { .trim() ); assert_eq!( - format!("{map:#03?}"), + format!("{:#03?}", map), r#" { "bar": 1024, @@ -714,7 +714,7 @@ Foo { .trim() ); assert_eq!( - format!("{set:#03?}"), + format!("{:#03?}", set), " { 007, diff --git a/library/core/tests/fmt/mod.rs b/library/core/tests/fmt/mod.rs index 61807635813c4..7b281ce48e6aa 100644 --- a/library/core/tests/fmt/mod.rs +++ b/library/core/tests/fmt/mod.rs @@ -6,7 +6,7 @@ mod num; fn test_format_flags() { // No residual flags left by pointer formatting let p = "".as_ptr(); - assert_eq!(format!("{:p} {:x}", p, 16), format!("{p:p} 10")); + assert_eq!(format!("{:p} {:x}", p, 16), format!("{:p} 10", p)); assert_eq!(format!("{: >3}", 'a'), " a"); } @@ -15,8 +15,8 @@ fn test_format_flags() { fn test_pointer_formats_data_pointer() { let b: &[u8] = b""; let s: &str = ""; - assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr())); - assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr())); + assert_eq!(format!("{:p}", s), format!("{:p}", s.as_ptr())); + assert_eq!(format!("{:p}", b), format!("{:p}", b.as_ptr())); } #[test] @@ -41,5 +41,5 @@ fn pad_integral_resets() { } } - assert_eq!(format!("{Bar:<03}"), "1 0051 "); + assert_eq!(format!("{:<03}", Bar), "1 0051 "); } diff --git a/library/core/tests/fmt/num.rs b/library/core/tests/fmt/num.rs index b9ede65c9ff09..b958422d14f84 100644 --- a/library/core/tests/fmt/num.rs +++ b/library/core/tests/fmt/num.rs @@ -126,7 +126,7 @@ fn test_format_int_exp_limits() { fn test_format_int_exp_precision() { //test that float and integer match let big_int: u32 = 314_159_265; - assert_eq!(format!("{big_int:.1e}"), format!("{:.1e}", f64::from(big_int))); + assert_eq!(format!("{:.1e}", big_int), format!("{:.1e}", f64::from(big_int))); //test adding precision assert_eq!(format!("{:.10e}", i8::MIN), "-1.2800000000e2"); diff --git a/library/core/tests/lazy.rs b/library/core/tests/lazy.rs index 416d2b2dae41f..064024ab87b28 100644 --- a/library/core/tests/lazy.rs +++ b/library/core/tests/lazy.rs @@ -113,7 +113,7 @@ fn aliasing_in_get() { x.set(42).unwrap(); let at_x = x.get().unwrap(); // --- (shared) borrow of inner `Option` --+ let _ = x.set(27); // <-- temporary (unique) borrow of inner `Option` | - println!("{at_x}"); // <------- up until here ---------------------------+ + println!("{}", at_x); // <------- up until here ---------------------------+ } #[test] diff --git a/library/core/tests/num/dec2flt/mod.rs b/library/core/tests/num/dec2flt/mod.rs index c4e105cba600d..4990d4a083df6 100644 --- a/library/core/tests/num/dec2flt/mod.rs +++ b/library/core/tests/num/dec2flt/mod.rs @@ -15,7 +15,7 @@ macro_rules! test_literal { for input in inputs { assert_eq!(input.parse(), Ok(x64)); assert_eq!(input.parse(), Ok(x32)); - let neg_input = &format!("-{input}"); + let neg_input = &format!("-{}", input); assert_eq!(neg_input.parse(), Ok(-x64)); assert_eq!(neg_input.parse(), Ok(-x32)); } @@ -123,9 +123,9 @@ fn inf() { #[test] fn massive_exponent() { let max = i64::MAX; - assert_eq!(format!("1e{max}000").parse(), Ok(f64::INFINITY)); - assert_eq!(format!("1e-{max}000").parse(), Ok(0.0)); - assert_eq!(format!("1e{max}000").parse(), Ok(f64::INFINITY)); + assert_eq!(format!("1e{}000", max).parse(), Ok(f64::INFINITY)); + assert_eq!(format!("1e-{}000", max).parse(), Ok(0.0)); + assert_eq!(format!("1e{}000", max).parse(), Ok(f64::INFINITY)); } #[test] diff --git a/library/core/tests/num/dec2flt/parse.rs b/library/core/tests/num/dec2flt/parse.rs index edc77377d5820..473feacc91fa9 100644 --- a/library/core/tests/num/dec2flt/parse.rs +++ b/library/core/tests/num/dec2flt/parse.rs @@ -46,7 +46,7 @@ fn valid() { assert_eq!(parse_positive(b".1e300"), Some(new_number(299, 1))); assert_eq!(parse_positive(b"101e-33"), Some(new_number(-33, 101))); let zeros = "0".repeat(25); - let s = format!("1.5e{zeros}"); + let s = format!("1.5e{}", zeros); assert_eq!(parse_positive(s.as_bytes()), Some(new_number(-1, 15))); } diff --git a/library/core/tests/num/flt2dec/mod.rs b/library/core/tests/num/flt2dec/mod.rs index 798473bbde377..4874e8ec09f8c 100644 --- a/library/core/tests/num/flt2dec/mod.rs +++ b/library/core/tests/num/flt2dec/mod.rs @@ -20,7 +20,7 @@ mod random; pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { FullDecoded::Finite(decoded) => decoded, - full_decoded => panic!("expected finite, got {full_decoded:?} instead"), + full_decoded => panic!("expected finite, got {:?} instead", full_decoded), } } diff --git a/library/core/tests/num/flt2dec/random.rs b/library/core/tests/num/flt2dec/random.rs index d0950039314ac..57b3dcf8e1e04 100644 --- a/library/core/tests/num/flt2dec/random.rs +++ b/library/core/tests/num/flt2dec/random.rs @@ -15,7 +15,7 @@ use rand::SeedableRng; pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { FullDecoded::Finite(decoded) => decoded, - full_decoded => panic!("expected finite, got {full_decoded:?} instead"), + full_decoded => panic!("expected finite, got {:?} instead", full_decoded), } } diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index af8e78f1f4e16..9c65871ac4b4c 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -550,7 +550,7 @@ fn dyn_metadata() { assert_eq!(meta.align_of(), std::mem::align_of::()); assert_eq!(meta.layout(), std::alloc::Layout::new::()); - assert!(format!("{meta:?}").starts_with("DynMetadata(0x")); + assert!(format!("{:?}", meta).starts_with("DynMetadata(0x")); } #[test] diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index 98b870512b046..1652c1b83de33 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -80,9 +80,9 @@ fn test_fmt_default() { let ok: Result = Ok(100); let err: Result = Err("Err"); - let s = format!("{ok:?}"); + let s = format!("{:?}", ok); assert_eq!(s, "Ok(100)"); - let s = format!("{err:?}"); + let s = format!("{:?}", err); assert_eq!(s, "Err(\"Err\")"); } diff --git a/library/portable-simd/crates/core_simd/examples/nbody.rs b/library/portable-simd/crates/core_simd/examples/nbody.rs index df38a00967feb..664a0454bbd09 100644 --- a/library/portable-simd/crates/core_simd/examples/nbody.rs +++ b/library/portable-simd/crates/core_simd/examples/nbody.rs @@ -187,7 +187,7 @@ mod tests { fn main() { { let (energy_before, energy_after) = nbody::run(1000); - println!("Energy before: {energy_before}"); - println!("Energy after: {energy_after}"); + println!("Energy before: {}", energy_before); + println!("Energy after: {}", energy_after); } } diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 5338cd077572c..31900912df468 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -1106,7 +1106,7 @@ impl Literal { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn f32_unsuffixed(n: f32) -> Literal { if !n.is_finite() { - panic!("Invalid float literal {n}"); + panic!("Invalid float literal {}", n); } let mut repr = n.to_string(); if !repr.contains('.') { @@ -1131,7 +1131,7 @@ impl Literal { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn f32_suffixed(n: f32) -> Literal { if !n.is_finite() { - panic!("Invalid float literal {n}"); + panic!("Invalid float literal {}", n); } Literal(bridge::client::Literal::f32(&n.to_string())) } @@ -1151,7 +1151,7 @@ impl Literal { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn f64_unsuffixed(n: f64) -> Literal { if !n.is_finite() { - panic!("Invalid float literal {n}"); + panic!("Invalid float literal {}", n); } let mut repr = n.to_string(); if !repr.contains('.') { @@ -1176,7 +1176,7 @@ impl Literal { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn f64_suffixed(n: f64) -> Literal { if !n.is_finite() { - panic!("Invalid float literal {n}"); + panic!("Invalid float literal {}", n); } Literal(bridge::client::Literal::f64(&n.to_string())) } diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index a880439624690..8ee55234cea43 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -83,7 +83,7 @@ pub use alloc_crate::alloc::*; /// /// fn main() { /// let a = Box::new(4); // Allocates from the system allocator. -/// println!("{a}"); +/// println!("{}", a); /// } /// ``` /// diff --git a/library/std/src/backtrace/tests.rs b/library/std/src/backtrace/tests.rs index 4dfbf88e83ebc..f5da93f93fd93 100644 --- a/library/std/src/backtrace/tests.rs +++ b/library/std/src/backtrace/tests.rs @@ -57,10 +57,10 @@ fn test_debug() { \n { fn: \"std::rt::lang_start\", file: \"rust/rt.rs\", line: 400 },\ \n]"; - assert_eq!(format!("{backtrace:#?}"), expected); + assert_eq!(format!("{:#?}", backtrace), expected); // Format the backtrace a second time, just to make sure lazily resolved state is stable - assert_eq!(format!("{backtrace:#?}"), expected); + assert_eq!(format!("{:#?}", backtrace), expected); } #[test] @@ -91,5 +91,5 @@ fn test_frames() { let mut iter = frames.iter().zip(expected.iter()); - assert!(iter.all(|(f, e)| format!("{f:#?}") == *e)); + assert!(iter.all(|(f, e)| format!("{:#?}", f) == *e)); } diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 6b63191eb583d..59dc13246aa3a 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -109,8 +109,8 @@ use crate::sys; /// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"]; /// for &book in &to_find { /// match book_reviews.get(book) { -/// Some(review) => println!("{book}: {review}"), -/// None => println!("{book} is unreviewed.") +/// Some(review) => println!("{}: {}", book, review), +/// None => println!("{} is unreviewed.", book) /// } /// } /// @@ -119,7 +119,7 @@ use crate::sys; /// /// // Iterate over everything. /// for (book, review) in &book_reviews { -/// println!("{book}: \"{review}\""); +/// println!("{}: \"{}\"", book, review); /// } /// ``` /// @@ -199,7 +199,7 @@ use crate::sys; /// /// // Use derived implementation to print the status of the vikings. /// for (viking, health) in &vikings { -/// println!("{viking:?} has {health} hp"); +/// println!("{:?} has {} hp", viking, health); /// } /// ``` @@ -341,7 +341,7 @@ impl HashMap { /// ]); /// /// for key in map.keys() { - /// println!("{key}"); + /// println!("{}", key); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -392,7 +392,7 @@ impl HashMap { /// ]); /// /// for val in map.values() { - /// println!("{val}"); + /// println!("{}", val); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -419,7 +419,7 @@ impl HashMap { /// } /// /// for val in map.values() { - /// println!("{val}"); + /// println!("{}", val); /// } /// ``` #[stable(feature = "map_values_mut", since = "1.10.0")] @@ -470,7 +470,7 @@ impl HashMap { /// ]); /// /// for (key, val) in map.iter() { - /// println!("key: {key} val: {val}"); + /// println!("key: {} val: {}", key, val); /// } /// ``` #[rustc_lint_query_instability] @@ -500,7 +500,7 @@ impl HashMap { /// } /// /// for (key, val) in &map { - /// println!("key: {key} val: {val}"); + /// println!("key: {} val: {}", key, val); /// } /// ``` #[rustc_lint_query_instability] diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs index 7ebc41588b3df..30da22b80849c 100644 --- a/library/std/src/collections/hash/map/tests.rs +++ b/library/std/src/collections/hash/map/tests.rs @@ -515,10 +515,10 @@ fn test_show() { map.insert(1, 2); map.insert(3, 4); - let map_str = format!("{map:?}"); + let map_str = format!("{:?}", map); assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}"); - assert_eq!(format!("{empty:?}"), "{}"); + assert_eq!(format!("{:?}", empty), "{}"); } #[test] @@ -702,7 +702,7 @@ fn test_entry_take_doesnt_corrupt() { // Test for #19292 fn check(m: &HashMap) { for k in m.keys() { - assert!(m.contains_key(k), "{k} is in keys() but not in the map?"); + assert!(m.contains_key(k), "{} is in keys() but not in the map?", k); } } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index fa471a3c3f323..4fd6996269e50 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -66,7 +66,7 @@ use super::map::{map_try_reserve_error, RandomState}; /// /// // Iterate over everything. /// for book in &books { -/// println!("{book}"); +/// println!("{}", book); /// } /// ``` /// @@ -91,7 +91,7 @@ use super::map::{map_try_reserve_error, RandomState}; /// /// // Use derived implementation to print the vikings. /// for x in &vikings { -/// println!("{x:?}"); +/// println!("{:?}", x); /// } /// ``` /// @@ -181,7 +181,7 @@ impl HashSet { /// /// // Will print in an arbitrary order. /// for x in set.iter() { - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` #[inline] @@ -244,7 +244,7 @@ impl HashSet { /// /// // print 1, 2, 3 in an arbitrary order /// for i in set.drain() { - /// println!("{i}"); + /// println!("{}", i); /// } /// /// assert!(set.is_empty()); @@ -525,7 +525,7 @@ where /// /// // Can be seen as `a - b`. /// for x in a.difference(&b) { - /// println!("{x}"); // Print 1 + /// println!("{}", x); // Print 1 /// } /// /// let diff: HashSet<_> = a.difference(&b).collect(); @@ -555,7 +555,7 @@ where /// /// // Print 1, 4 in arbitrary order. /// for x in a.symmetric_difference(&b) { - /// println!("{x}"); + /// println!("{}", x); /// } /// /// let diff1: HashSet<_> = a.symmetric_difference(&b).collect(); @@ -586,7 +586,7 @@ where /// /// // Print 2, 3 in arbitrary order. /// for x in a.intersection(&b) { - /// println!("{x}"); + /// println!("{}", x); /// } /// /// let intersection: HashSet<_> = a.intersection(&b).collect(); @@ -615,7 +615,7 @@ where /// /// // Print 1, 2, 3, 4 in arbitrary order. /// for x in a.union(&b) { - /// println!("{x}"); + /// println!("{}", x); /// } /// /// let union: HashSet<_> = a.union(&b).collect(); @@ -1451,7 +1451,7 @@ impl IntoIterator for HashSet { /// /// // Will print in an arbitrary order. /// for x in &v { - /// println!("{x}"); + /// println!("{}", x); /// } /// ``` #[inline] diff --git a/library/std/src/collections/hash/set/tests.rs b/library/std/src/collections/hash/set/tests.rs index 233db276b9e61..6a625e6243c21 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -301,10 +301,10 @@ fn test_show() { set.insert(1); set.insert(2); - let set_str = format!("{set:?}"); + let set_str = format!("{:?}", set); assert!(set_str == "{1, 2}" || set_str == "{2, 1}"); - assert_eq!(format!("{empty:?}"), "{}"); + assert_eq!(format!("{:?}", empty), "{}"); } #[test] diff --git a/library/std/src/collections/mod.rs b/library/std/src/collections/mod.rs index 0caec8fe05aa7..b5e81deb48080 100644 --- a/library/std/src/collections/mod.rs +++ b/library/std/src/collections/mod.rs @@ -199,7 +199,7 @@ //! ``` //! let vec = vec![1, 2, 3, 4]; //! for x in vec.iter() { -//! println!("vec contained {x:?}"); +//! println!("vec contained {}", x); //! } //! ``` //! @@ -246,7 +246,7 @@ //! ``` //! let vec = vec![1, 2, 3, 4]; //! for x in vec.iter().rev() { -//! println!("vec contained {x:?}"); +//! println!("vec contained {}", x); //! } //! ``` //! @@ -306,7 +306,7 @@ //! //! println!("Number of occurrences of each character"); //! for (char, count) in &count { -//! println!("{char}: {count}"); +//! println!("{}: {}", char, count); //! } //! ``` //! @@ -339,7 +339,7 @@ //! // Check if they're sober enough to have another beer. //! if person.blood_alcohol > 0.3 { //! // Too drunk... for now. -//! println!("Sorry {id}, I have to cut you off"); +//! println!("Sorry {}, I have to cut you off", id); //! } else { //! // Have another! //! person.blood_alcohol += 0.1; diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 05f08c498e683..5ed9fa9d6f0fd 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -118,7 +118,7 @@ pub struct VarsOs { /// // We will iterate through the references to the element returned by /// // env::vars(); /// for (key, value) in env::vars() { -/// println!("{key}: {value}"); +/// println!("{}: {}", key, value); /// } /// ``` /// @@ -148,7 +148,7 @@ pub fn vars() -> Vars { /// // We will iterate through the references to the element returned by /// // env::vars_os(); /// for (key, value) in env::vars_os() { -/// println!("{key:?}: {value:?}"); +/// println!("{:?}: {:?}", key, value); /// } /// ``` #[must_use] @@ -212,8 +212,8 @@ impl fmt::Debug for VarsOs { /// /// let key = "HOME"; /// match env::var(key) { -/// Ok(val) => println!("{key}: {val:?}"), -/// Err(e) => println!("couldn't interpret {key}: {e}"), +/// Ok(val) => println!("{}: {:?}", key, val), +/// Err(e) => println!("couldn't interpret {}: {}", key, e), /// } /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -252,8 +252,8 @@ fn _var(key: &OsStr) -> Result { /// /// let key = "HOME"; /// match env::var_os(key) { -/// Some(val) => println!("{key}: {val:?}"), -/// None => println!("{key} is not defined in the environment.") +/// Some(val) => println!("{}: {:?}", key, val), +/// None => println!("{} is not defined in the environment.", key) /// } /// ``` #[must_use] @@ -343,7 +343,7 @@ pub fn set_var, V: AsRef>(key: K, value: V) { fn _set_var(key: &OsStr, value: &OsStr) { os_imp::setenv(key, value).unwrap_or_else(|e| { - panic!("failed to set environment variable `{key:?}` to `{value:?}`: {e}") + panic!("failed to set environment variable `{:?}` to `{:?}`: {}", key, value, e) }) } @@ -385,7 +385,7 @@ pub fn remove_var>(key: K) { fn _remove_var(key: &OsStr) { os_imp::unsetenv(key) - .unwrap_or_else(|e| panic!("failed to remove environment variable `{key:?}`: {e}")) + .unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", key, e)) } /// An iterator that splits an environment variable into paths according to @@ -421,7 +421,7 @@ pub struct SplitPaths<'a> { /// println!("'{}'", path.display()); /// } /// } -/// None => println!("{key} is not defined in the environment.") +/// None => println!("{} is not defined in the environment.", key) /// } /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -684,7 +684,7 @@ pub fn temp_dir() -> PathBuf { /// match env::current_exe() { /// Ok(exe_path) => println!("Path of this executable is: {}", /// exe_path.display()), -/// Err(e) => println!("failed to get current exe path: {e}"), +/// Err(e) => println!("failed to get current exe path: {}", e), /// }; /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -755,7 +755,7 @@ pub struct ArgsOs { /// /// // Prints each argument on a separate line /// for argument in env::args() { -/// println!("{argument}"); +/// println!("{}", argument); /// } /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -790,7 +790,7 @@ pub fn args() -> Args { /// /// // Prints each argument on a separate line /// for argument in env::args_os() { -/// println!("{argument:?}"); +/// println!("{:?}", argument); /// } /// ``` #[stable(feature = "env", since = "1.0.0")] diff --git a/library/std/src/error.rs b/library/std/src/error.rs index c3cb71a5dee63..1a96b9c928289 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -96,7 +96,7 @@ pub trait Error: Debug + Display { /// fn main() { /// match get_super_error() { /// Err(e) => { - /// println!("Error: {e}"); + /// println!("Error: {}", e); /// println!("Caused by: {}", e.source().unwrap()); /// } /// _ => println!("No error"), @@ -139,7 +139,7 @@ pub trait Error: Debug + Display { /// ``` /// if let Err(e) = "xc".parse::() { /// // Print `e` itself, no need for description(). - /// eprintln!("Error: {e}"); + /// eprintln!("Error: {}", e); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -1074,7 +1074,7 @@ impl Report { /// /// let error = SuperError { source: SuperErrorSideKick }; /// let report = Report::new(error).pretty(true); - /// eprintln!("Error: {report:?}"); + /// eprintln!("Error: {:?}", report); /// ``` /// /// This example produces the following output: @@ -1135,7 +1135,7 @@ impl Report { /// let source = SuperErrorSideKick { source }; /// let error = SuperError { source }; /// let report = Report::new(error).pretty(true); - /// eprintln!("Error: {report:?}"); + /// eprintln!("Error: {:?}", report); /// ``` /// /// This example produces the following output: @@ -1210,7 +1210,7 @@ impl Report { /// let source = SuperErrorSideKick::new(); /// let error = SuperError { source }; /// let report = Report::new(error).pretty(true).show_backtrace(true); - /// eprintln!("Error: {report:?}"); + /// eprintln!("Error: {:?}", report); /// ``` /// /// This example produces something similar to the following output: @@ -1267,7 +1267,7 @@ where let sources = self.error.source().into_iter().flat_map(::chain); for cause in sources { - write!(f, ": {cause}")?; + write!(f, ": {}", cause)?; } Ok(()) @@ -1278,7 +1278,7 @@ where fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let error = &self.error; - write!(f, "{error}")?; + write!(f, "{}", error)?; if let Some(cause) = error.source() { write!(f, "\n\nCaused by:")?; @@ -1289,9 +1289,9 @@ where writeln!(f)?; let mut indented = Indented { inner: f }; if multiple { - write!(indented, "{ind: >4}: {error}")?; + write!(indented, "{: >4}: {}", ind, error)?; } else { - write!(indented, " {error}")?; + write!(indented, " {}", error)?; } } } @@ -1333,7 +1333,7 @@ impl Report> { let sources = self.error.source().into_iter().flat_map(::chain); for cause in sources { - write!(f, ": {cause}")?; + write!(f, ": {}", cause)?; } Ok(()) @@ -1344,7 +1344,7 @@ impl Report> { fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let error = &self.error; - write!(f, "{error}")?; + write!(f, "{}", error)?; if let Some(cause) = error.source() { write!(f, "\n\nCaused by:")?; @@ -1355,9 +1355,9 @@ impl Report> { writeln!(f)?; let mut indented = Indented { inner: f }; if multiple { - write!(indented, "{ind: >4}: {error}")?; + write!(indented, "{: >4}: {}", ind, error)?; } else { - write!(indented, " {error}")?; + write!(indented, " {}", error)?; } } } diff --git a/library/std/src/error/tests.rs b/library/std/src/error/tests.rs index a2a35d96ec918..eae5f43ff3cfb 100644 --- a/library/std/src/error/tests.rs +++ b/library/std/src/error/tests.rs @@ -130,7 +130,7 @@ Stack backtrace: error.backtrace = Some(trace); let report = Report::new(error).pretty(true).show_backtrace(true); - println!("Error: {report}"); + println!("Error: {}", report); assert_eq!(expected.trim_end(), report.to_string()); } @@ -155,7 +155,7 @@ Stack backtrace: let error = GenericError::new_with_source("Error with two sources", error); let report = Report::new(error).pretty(true).show_backtrace(true); - println!("Error: {report}"); + println!("Error: {}", report); assert_eq!(expected.trim_end(), report.to_string()); } @@ -355,7 +355,7 @@ Caused by: 1: The message goes on and on."; let actual = report.to_string(); - println!("{actual}"); + println!("{}", actual); assert_eq!(expected, actual); } diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index b833d0e2ca507..1678367290e51 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -1120,7 +1120,7 @@ impl fmt::Display for FromBytesWithNulError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.description())?; if let FromBytesWithNulErrorKind::InteriorNul(pos) = self.kind { - write!(f, " at byte pos {pos}")?; + write!(f, " at byte pos {}", pos)?; } Ok(()) } @@ -1134,7 +1134,7 @@ impl fmt::Display for FromVecWithNulError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.error_kind { FromBytesWithNulErrorKind::InteriorNul(pos) => { - write!(f, "data provided contains an interior nul byte at pos {pos}") + write!(f, "data provided contains an interior nul byte at pos {}", pos) } FromBytesWithNulErrorKind::NotNulTerminated => { write!(f, "data provided is not nul terminated") diff --git a/library/std/src/ffi/c_str/tests.rs b/library/std/src/ffi/c_str/tests.rs index 8d603229315c0..00ba5460821ff 100644 --- a/library/std/src/ffi/c_str/tests.rs +++ b/library/std/src/ffi/c_str/tests.rs @@ -35,7 +35,7 @@ fn build_with_zero2() { #[test] fn formatted() { let s = CString::new(&b"abc\x01\x02\n\xE2\x80\xA6\xFF"[..]).unwrap(); - assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#); + assert_eq!(format!("{:?}", s), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#); } #[test] diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index c99d9b279a928..0b65336a5a7da 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1123,7 +1123,7 @@ impl Metadata { /// let metadata = fs::metadata("foo.txt")?; /// /// if let Ok(time) = metadata.modified() { - /// println!("{time:?}"); + /// println!("{:?}", time); /// } else { /// println!("Not supported on this platform"); /// } @@ -1158,7 +1158,7 @@ impl Metadata { /// let metadata = fs::metadata("foo.txt")?; /// /// if let Ok(time) = metadata.accessed() { - /// println!("{time:?}"); + /// println!("{:?}", time); /// } else { /// println!("Not supported on this platform"); /// } @@ -1190,7 +1190,7 @@ impl Metadata { /// let metadata = fs::metadata("foo.txt")?; /// /// if let Ok(time) = metadata.created() { - /// println!("{time:?}"); + /// println!("{:?}", time); /// } else { /// println!("Not supported on this platform or filesystem"); /// } diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 6d67c396c623a..149b3e1feeaac 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -31,7 +31,7 @@ macro_rules! check { ($e:expr) => { match $e { Ok(t) => t, - Err(e) => panic!("{} failed with: {e}", stringify!($e)), + Err(e) => panic!("{} failed with: {}", stringify!($e), e), } }; } @@ -471,7 +471,7 @@ fn file_test_directoryinfo_readdir() { check!(fs::create_dir(dir)); let prefix = "foo"; for n in 0..3 { - let f = dir.join(&format!("{n}.txt")); + let f = dir.join(&format!("{}.txt", n)); let mut w = check!(File::create(&f)); let msg_str = format!("{}{}", prefix, n.to_string()); let msg = msg_str.as_bytes(); @@ -1337,7 +1337,7 @@ fn dir_entry_methods() { assert!(file.file_type().unwrap().is_file()); assert!(file.metadata().unwrap().is_file()); } - f => panic!("unknown file name: {f:?}"), + f => panic!("unknown file name: {:?}", f), } } } @@ -1348,7 +1348,7 @@ fn dir_entry_debug() { File::create(&tmpdir.join("b")).unwrap(); let mut read_dir = tmpdir.path().read_dir().unwrap(); let dir_entry = read_dir.next().unwrap().unwrap(); - let actual = format!("{dir_entry:?}"); + let actual = format!("{:?}", dir_entry); let expected = format!("DirEntry({:?})", dir_entry.0.path()); assert_eq!(actual, expected); } @@ -1417,7 +1417,7 @@ fn metadata_access_times() { || e1.kind() == ErrorKind::Unsupported && e2.kind() == ErrorKind::Unsupported => {} (a, b) => { - panic!("creation time must be always supported or not supported: {a:?} {b:?}") + panic!("creation time must be always supported or not supported: {:?} {:?}", a, b,) } } } diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index 989cec976b72f..e7eee4436249b 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -41,7 +41,7 @@ use crate::mem::MaybeUninit; /// /// let mut line = String::new(); /// let len = reader.read_line(&mut line)?; -/// println!("First line is {len} bytes long"); +/// println!("First line is {} bytes long", len); /// Ok(()) /// } /// ``` diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 4a50e647c640e..17e2b97545a94 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -457,7 +457,7 @@ impl From for Error { /// /// let not_found = ErrorKind::NotFound; /// let error = Error::from(not_found); - /// assert_eq!("entity not found", format!("{error}")); + /// assert_eq!("entity not found", format!("{}", error)); /// ``` #[inline] fn from(kind: ErrorKind) -> Error { @@ -561,7 +561,7 @@ impl Error { /// use std::io::Error; /// /// let os_error = Error::last_os_error(); - /// println!("last OS error: {os_error:?}"); + /// println!("last OS error: {:?}", os_error); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[must_use] @@ -618,7 +618,7 @@ impl Error { /// /// fn print_os_error(err: &Error) { /// if let Some(raw_os_err) = err.raw_os_error() { - /// println!("raw OS error: {raw_os_err:?}"); + /// println!("raw OS error: {:?}", raw_os_err); /// } else { /// println!("Not an OS error"); /// } @@ -657,7 +657,7 @@ impl Error { /// /// fn print_error(err: &Error) { /// if let Some(inner_err) = err.get_ref() { - /// println!("Inner error: {inner_err:?}"); + /// println!("Inner error: {:?}", inner_err); /// } else { /// println!("No inner error"); /// } @@ -731,7 +731,7 @@ impl Error { /// /// fn print_error(err: &Error) { /// if let Some(inner_err) = err.get_ref() { - /// println!("Inner error: {inner_err}"); + /// println!("Inner error: {}", inner_err); /// } else { /// println!("No inner error"); /// } @@ -770,7 +770,7 @@ impl Error { /// /// fn print_error(err: Error) { /// if let Some(inner_err) = err.into_inner() { - /// println!("Inner error: {inner_err}"); + /// println!("Inner error: {}", inner_err); /// } else { /// println!("No inner error"); /// } @@ -852,7 +852,7 @@ impl fmt::Display for Error { match self.repr.data() { ErrorData::Os(code) => { let detail = sys::os::error_string(code); - write!(fmt, "{detail} (os error {code})") + write!(fmt, "{} (os error {})", detail, code) } ErrorData::Custom(ref c) => c.error.fmt(fmt), ErrorData::Simple(kind) => write!(fmt, "{}", kind.as_str()), diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index 1a0538f861a1e..4301e941b3dce 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -161,7 +161,8 @@ impl Repr { // only run in libstd's tests, unless the user uses -Zbuild-std) debug_assert!( matches!(res.data(), ErrorData::Os(c) if c == code), - "repr(os) encoding failed for {code}" + "repr(os) encoding failed for {}", + code, ); res } diff --git a/library/std/src/io/error/tests.rs b/library/std/src/io/error/tests.rs index 6fd15fa80488b..c2c51553b208c 100644 --- a/library/std/src/io/error/tests.rs +++ b/library/std/src/io/error/tests.rs @@ -33,7 +33,7 @@ fn test_debug_error() { }}", code, kind, msg ); - assert_eq!(format!("{err:?}"), expected); + assert_eq!(format!("{:?}", err), expected); } #[test] @@ -65,8 +65,8 @@ fn test_const() { assert_eq!(E.kind(), ErrorKind::NotFound); assert_eq!(E.to_string(), "hello"); - assert!(format!("{E:?}").contains("\"hello\"")); - assert!(format!("{E:?}").contains("NotFound")); + assert!(format!("{:?}", E).contains("\"hello\"")); + assert!(format!("{:?}", E).contains("NotFound")); } #[test] @@ -101,7 +101,7 @@ fn test_simple_message_packing() { let e = &$err; // Check that the public api is right. assert_eq!(e.kind(), $kind); - assert!(format!("{e:?}").contains($msg)); + assert!(format!("{:?}", e).contains($msg)); // and we got what we expected assert_matches!( e.repr.data(), diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 6005270a75fec..3fa965d08e698 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -91,7 +91,7 @@ //! // read a line into buffer //! reader.read_line(&mut buffer)?; //! -//! println!("{buffer}"); +//! println!("{}", buffer); //! Ok(()) //! } //! ``` @@ -1035,7 +1035,7 @@ pub trait Read { /// fn main() -> io::Result<()> { /// let stdin = io::read_to_string(io::stdin())?; /// println!("Stdin was:"); -/// println!("{stdin}"); +/// println!("{}", stdin); /// Ok(()) /// } /// ``` @@ -1761,7 +1761,7 @@ pub trait Seek { /// .open("foo.txt").unwrap(); /// /// let hello = "Hello!\n"; - /// write!(f, "{hello}").unwrap(); + /// write!(f, "{}", hello).unwrap(); /// f.rewind().unwrap(); /// /// let mut buf = String::new(); @@ -1804,7 +1804,7 @@ pub trait Seek { /// let mut f = File::open("foo.txt")?; /// /// let len = f.stream_len()?; - /// println!("The file is currently {len} bytes long"); + /// println!("The file is currently {} bytes long", len); /// Ok(()) /// } /// ``` @@ -1988,7 +1988,7 @@ pub trait BufRead: Read { /// let buffer = stdin.fill_buf().unwrap(); /// /// // work with buffer - /// println!("{buffer:?}"); + /// println!("{:?}", buffer); /// /// // ensure the bytes we worked with aren't returned again later /// let length = buffer.len(); @@ -2042,7 +2042,7 @@ pub trait BufRead: Read { /// let mut line = String::new(); /// stdin.read_line(&mut line).unwrap(); /// // work with line - /// println!("{line:?}"); + /// println!("{:?}", line); /// } /// ``` #[unstable(feature = "buf_read_has_data_left", reason = "recently added", issue = "86423")] diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 50344e602a958..5414ff648d4d5 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -349,10 +349,10 @@ impl Stdin { /// let mut input = String::new(); /// match io::stdin().read_line(&mut input) { /// Ok(n) => { - /// println!("{n} bytes read"); - /// println!("{input}"); + /// println!("{} bytes read", n); + /// println!("{}", input); /// } - /// Err(error) => println!("error: {error}"), + /// Err(error) => println!("error: {}", error), /// } /// ``` /// @@ -953,7 +953,7 @@ where } if let Err(e) = global_s().write_fmt(args) { - panic!("failed printing to {label}: {e}"); + panic!("failed printing to {}: {}", label, e); } } diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 542b793f6da05..5b76259afc11d 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -64,7 +64,7 @@ mod as_keyword {} /// } /// /// assert_eq!(last, 12); -/// println!("{last}"); +/// println!("{}", last); /// ``` /// /// A break expression is normally associated with the innermost loop enclosing the @@ -72,10 +72,10 @@ mod as_keyword {} /// ///```rust /// 'outer: for i in 1..=5 { -/// println!("outer iteration (i): {i}"); +/// println!("outer iteration (i): {}", i); /// /// '_inner: for j in 1..=200 { -/// println!(" inner iteration (j): {j}"); +/// println!(" inner iteration (j): {}", j); /// if j >= 3 { /// // breaks from inner loop, lets outer loop continue. /// break; @@ -106,7 +106,7 @@ mod as_keyword {} /// }; /// // first number in Fibonacci sequence over 10: /// assert_eq!(result, 13); -/// println!("{result}"); +/// println!("{}", result); /// ``` /// /// For more details consult the [Reference on "break expression"] and the [Reference on "break and @@ -200,7 +200,7 @@ mod const_keyword {} /// if number % 2 == 0 { /// continue; /// } -/// println!("{number}"); +/// println!("{}", number); /// } ///``` /// @@ -515,7 +515,7 @@ mod fn_keyword {} /// } /// /// for i in std::iter::repeat(5) { -/// println!("turns out {i} never stops being 5"); +/// println!("turns out {} never stops being 5", i); /// break; // would loop forever otherwise /// } /// @@ -776,7 +776,7 @@ mod in_keyword {} /// let shadowing_example = true; /// let shadowing_example = 123.4; /// let shadowing_example = shadowing_example as u32; -/// let mut shadowing_example = format!("cool! {shadowing_example}"); +/// let mut shadowing_example = format!("cool! {}", shadowing_example); /// shadowing_example += " something else!"; // not shadowing /// ``` /// @@ -805,7 +805,7 @@ mod let_keyword {} /// let mut counter = 0; /// /// while counter < 10 { -/// println!("{counter}"); +/// println!("{}", counter); /// counter += 1; /// } /// ``` @@ -836,7 +836,7 @@ mod let_keyword {} /// if i == 10 { /// counter = None; /// } else { -/// println!("{i}"); +/// println!("{}", i); /// counter = Some (i + 1); /// } /// } @@ -866,7 +866,7 @@ mod while_keyword {} /// /// let mut i = 1; /// loop { -/// println!("i is {i}"); +/// println!("i is {}", i); /// if i > 100 { /// break; /// } @@ -920,8 +920,8 @@ mod loop_keyword {} /// /// let a_number = Option::Some(10); /// match a_number { -/// Some(x) if x <= 5 => println!("0 to 5 num = {x}"), -/// Some(x @ 6..=10) => println!("6 to 10 num = {x}"), +/// Some(x) if x <= 5 => println!("0 to 5 num = {}", x), +/// Some(x @ 6..=10) => println!("6 to 10 num = {}", x), /// None => panic!(), /// // all other numbers /// _ => panic!(), @@ -940,8 +940,8 @@ mod loop_keyword {} /// /// let get_inner = Outer::Double(None, Some(String::new())); /// match get_inner { -/// Outer::Double(None, Some(st)) => println!("{st}"), -/// Outer::Single(opt) => println!("{opt:?}"), +/// Outer::Double(None, Some(st)) => println!("{}", st), +/// Outer::Single(opt) => println!("{:?}", opt), /// _ => panic!(), /// } /// ``` @@ -988,7 +988,7 @@ mod mod_keyword {} /// /// ```rust /// let data = vec![1, 2, 3]; -/// let closure = move || println!("captured {data:?} by value"); +/// let closure = move || println!("captured {:?} by value", data); /// /// // data is no longer available, it is owned by the closure /// ``` @@ -1001,7 +1001,7 @@ mod mod_keyword {} /// ```rust /// fn create_fn() -> impl Fn() { /// let text = "Fn".to_owned(); -/// move || println!("This is a: {text}") +/// move || println!("This is a: {}", text) /// } /// /// let fn_plain = create_fn(); @@ -1014,7 +1014,7 @@ mod mod_keyword {} /// let data = vec![1, 2, 3]; /// /// std::thread::spawn(move || { -/// println!("captured {data:?} by value") +/// println!("captured {:?} by value", data) /// }).join().unwrap(); /// /// // data was moved to the spawned thread, so we cannot use it here @@ -1025,7 +1025,7 @@ mod mod_keyword {} /// ```rust /// let capture = "hello".to_owned(); /// let block = async move { -/// println!("rust says {capture} from async block"); +/// println!("rust says {} from async block", capture); /// }; /// ``` /// @@ -1124,7 +1124,7 @@ mod pub_keyword {} /// let maybe_name = Some(String::from("Alice")); /// // The variable 'maybe_name' is consumed here ... /// match maybe_name { -/// Some(n) => println!("Hello, {n}"), +/// Some(n) => println!("Hello, {}", n), /// _ => println!("Hello, world"), /// } /// // ... and is now unavailable. @@ -1138,7 +1138,7 @@ mod pub_keyword {} /// let maybe_name = Some(String::from("Alice")); /// // Using `ref`, the value is borrowed, not moved ... /// match maybe_name { -/// Some(ref n) => println!("Hello, {n}"), +/// Some(ref n) => println!("Hello, {}", n), /// _ => println!("Hello, world"), /// } /// // ... so it's available here! @@ -1423,7 +1423,7 @@ mod self_upper_keyword {} /// // With a strictly read-only static, references will have the same address /// assert_eq!(r1, r2); /// // A static item can be used just like a variable in many cases -/// println!("{FOO:?}"); +/// println!("{:?}", FOO); /// ``` /// /// # Mutable `static`s @@ -1675,7 +1675,7 @@ mod super_keyword {} /// # #![allow(dead_code)] /// fn debug_iter(it: I) where I::Item: std::fmt::Debug { /// for elem in it { -/// println!("{elem:#?}"); +/// println!("{:#?}", elem); /// } /// } /// @@ -2313,7 +2313,7 @@ mod dyn_keyword {} /// match u { /// IntOrFloat { i: 10 } => println!("Found exactly ten!"), /// // Matching the field `f` provides an `f32`. -/// IntOrFloat { f } => println!("Found f = {f} !"), +/// IntOrFloat { f } => println!("Found f = {} !", f), /// } /// } /// ``` @@ -2337,7 +2337,7 @@ mod dyn_keyword {} /// let i = unsafe { &mut u.i }; /// /// *i = 10; -/// println!("f = {f} and i = {i}"); +/// println!("f = {} and i = {}", f, i); /// ``` /// /// See the [Reference][union] for more informations on `union`s. diff --git a/library/std/src/net/addr/tests.rs b/library/std/src/net/addr/tests.rs index 585a17451a0b7..40f5a84bcd520 100644 --- a/library/std/src/net/addr/tests.rs +++ b/library/std/src/net/addr/tests.rs @@ -169,30 +169,30 @@ fn is_v6() { fn socket_v4_to_str() { let socket = SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 8080); - assert_eq!(format!("{socket}"), "192.168.0.1:8080"); - assert_eq!(format!("{socket:<20}"), "192.168.0.1:8080 "); - assert_eq!(format!("{socket:>20}"), " 192.168.0.1:8080"); - assert_eq!(format!("{socket:^20}"), " 192.168.0.1:8080 "); - assert_eq!(format!("{socket:.10}"), "192.168.0."); + assert_eq!(format!("{}", socket), "192.168.0.1:8080"); + assert_eq!(format!("{:<20}", socket), "192.168.0.1:8080 "); + assert_eq!(format!("{:>20}", socket), " 192.168.0.1:8080"); + assert_eq!(format!("{:^20}", socket), " 192.168.0.1:8080 "); + assert_eq!(format!("{:.10}", socket), "192.168.0."); } #[test] fn socket_v6_to_str() { let mut socket = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53, 0, 0); - assert_eq!(format!("{socket}"), "[2a02:6b8:0:1::1]:53"); - assert_eq!(format!("{socket:<24}"), "[2a02:6b8:0:1::1]:53 "); - assert_eq!(format!("{socket:>24}"), " [2a02:6b8:0:1::1]:53"); - assert_eq!(format!("{socket:^24}"), " [2a02:6b8:0:1::1]:53 "); - assert_eq!(format!("{socket:.15}"), "[2a02:6b8:0:1::"); + assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1]:53"); + assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1]:53 "); + assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1]:53"); + assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1]:53 "); + assert_eq!(format!("{:.15}", socket), "[2a02:6b8:0:1::"); socket.set_scope_id(5); - assert_eq!(format!("{socket}"), "[2a02:6b8:0:1::1%5]:53"); - assert_eq!(format!("{socket:<24}"), "[2a02:6b8:0:1::1%5]:53 "); - assert_eq!(format!("{socket:>24}"), " [2a02:6b8:0:1::1%5]:53"); - assert_eq!(format!("{socket:^24}"), " [2a02:6b8:0:1::1%5]:53 "); - assert_eq!(format!("{socket:.18}"), "[2a02:6b8:0:1::1%5"); + assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1%5]:53"); + assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1%5]:53 "); + assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1%5]:53"); + assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1%5]:53 "); + assert_eq!(format!("{:.18}", socket), "[2a02:6b8:0:1::1%5"); } #[test] diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index f5d3c4905e081..cc4e4fd4fdc77 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -595,10 +595,10 @@ impl TcpStream { /// // via platform-specific APIs such as epoll or IOCP /// wait_for_fd(); /// } - /// Err(e) => panic!("encountered IO error: {e}"), + /// Err(e) => panic!("encountered IO error: {}", e), /// }; /// }; - /// println!("bytes: {buf:?}"); + /// println!("bytes: {:?}", buf); /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { @@ -799,8 +799,8 @@ impl TcpListener { /// /// let listener = TcpListener::bind("127.0.0.1:8080").unwrap(); /// match listener.accept() { - /// Ok((_socket, addr)) => println!("new client: {addr:?}"), - /// Err(e) => println!("couldn't get client: {e:?}"), + /// Ok((_socket, addr)) => println!("new client: {:?}", addr), + /// Err(e) => println!("couldn't get client: {:?}", e), /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -991,7 +991,7 @@ impl TcpListener { /// wait_for_fd(); /// continue; /// } - /// Err(e) => panic!("encountered IO error: {e}"), + /// Err(e) => panic!("encountered IO error: {}", e), /// } /// } /// ``` diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index 8c0adcfb0ebbb..4d5cf658def0d 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -142,7 +142,8 @@ fn write_close() { e.kind() == ErrorKind::ConnectionReset || e.kind() == ErrorKind::BrokenPipe || e.kind() == ErrorKind::ConnectionAborted, - "unknown error: {e}" + "unknown error: {}", + e ); } } @@ -654,7 +655,7 @@ fn debug() { inner_name, render_inner(&listener) ); - assert_eq!(format!("{listener:?}"), compare); + assert_eq!(format!("{:?}", listener), compare); let stream = t!(TcpStream::connect(&("localhost", socket_addr.port()))); let compare = format!( @@ -664,7 +665,7 @@ fn debug() { inner_name, render_inner(&stream) ); - assert_eq!(format!("{stream:?}"), compare); + assert_eq!(format!("{:?}", stream), compare); } // FIXME: re-enabled openbsd tests once their socket timeout code @@ -831,7 +832,7 @@ fn set_nonblocking() { match stream.read(&mut buf) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), } } @@ -861,7 +862,7 @@ fn peek() { match c.peek(&mut b) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), } t!(txdone.send(())); }) diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 864e1b0f3450a..11a696e92c825 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -605,9 +605,9 @@ impl UdpSocket { /// /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); /// match socket.take_error() { - /// Ok(Some(error)) => println!("UdpSocket error: {error:?}"), + /// Ok(Some(error)) => println!("UdpSocket error: {:?}", error), /// Ok(None) => println!("No error"), - /// Err(error) => println!("UdpSocket.take_error failed: {error:?}"), + /// Err(error) => println!("UdpSocket.take_error failed: {:?}", error), /// } /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] @@ -686,8 +686,8 @@ impl UdpSocket { /// socket.connect("127.0.0.1:8080").expect("connect function failed"); /// let mut buf = [0; 10]; /// match socket.recv(&mut buf) { - /// Ok(received) => println!("received {received} bytes {:?}", &buf[..received]), - /// Err(e) => println!("recv function failed: {e:?}"), + /// Ok(received) => println!("received {} bytes {:?}", received, &buf[..received]), + /// Err(e) => println!("recv function failed: {:?}", e), /// } /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] @@ -726,8 +726,8 @@ impl UdpSocket { /// socket.connect("127.0.0.1:8080").expect("connect function failed"); /// let mut buf = [0; 10]; /// match socket.peek(&mut buf) { - /// Ok(received) => println!("received {received} bytes"), - /// Err(e) => println!("peek function failed: {e:?}"), + /// Ok(received) => println!("received {} bytes", received), + /// Err(e) => println!("peek function failed: {:?}", e), /// } /// ``` #[stable(feature = "peek", since = "1.18.0")] @@ -770,7 +770,7 @@ impl UdpSocket { /// // via platform-specific APIs such as epoll or IOCP /// wait_for_fd(); /// } - /// Err(e) => panic!("encountered IO error: {e}"), + /// Err(e) => panic!("encountered IO error: {}", e), /// } /// }; /// println!("bytes: {:?}", &buf[..num_bytes_read]); diff --git a/library/std/src/net/udp/tests.rs b/library/std/src/net/udp/tests.rs index f82904ffbbf77..a51113dd9e749 100644 --- a/library/std/src/net/udp/tests.rs +++ b/library/std/src/net/udp/tests.rs @@ -173,8 +173,8 @@ fn debug() { let udpsock = t!(UdpSocket::bind(&socket_addr)); let udpsock_inner = udpsock.0.socket().as_raw(); - let compare = format!("UdpSocket {{ addr: {socket_addr:?}, {name}: {udpsock_inner:?} }}"); - assert_eq!(format!("{udpsock:?}"), compare); + let compare = format!("UdpSocket {{ addr: {:?}, {}: {:?} }}", socket_addr, name, udpsock_inner); + assert_eq!(format!("{:?}", udpsock), compare); } // FIXME: re-enabled openbsd/netbsd tests once their socket timeout code @@ -359,7 +359,7 @@ fn set_nonblocking() { match socket.recv(&mut buf) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), } }) } diff --git a/library/std/src/os/unix/fs.rs b/library/std/src/os/unix/fs.rs index 3fc6cc44ce4c8..75d65e6d5fc03 100644 --- a/library/std/src/os/unix/fs.rs +++ b/library/std/src/os/unix/fs.rs @@ -47,7 +47,7 @@ pub trait FileExt { /// /// // We now read 8 bytes from the offset 10. /// let num_bytes_read = file.read_at(&mut buf, 10)?; - /// println!("read {num_bytes_read} bytes: {buf:?}"); + /// println!("read {} bytes: {:?}", num_bytes_read, buf); /// Ok(()) /// } /// ``` @@ -861,7 +861,7 @@ pub trait DirEntryExt2: Sealed { /// entries.sort_unstable_by(|a, b| a.file_name_ref().cmp(b.file_name_ref())); /// /// for p in entries { - /// println!("{p:?}"); + /// println!("{:?}", p); /// } /// /// Ok(()) diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index a3ef4b2d92cc4..03d59d773115e 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -86,7 +86,7 @@ impl<'a> fmt::Display for AsciiEscaped<'a> { /// let socket = match UnixListener::bind("/tmp/sock") { /// Ok(sock) => sock, /// Err(e) => { -/// println!("Couldn't bind: {e:?}"); +/// println!("Couldn't bind: {:?}", e); /// return /// } /// }; @@ -305,7 +305,7 @@ impl SocketAddr { /// let listener = match UnixListener::bind_addr(&addr) { /// Ok(sock) => sock, /// Err(err) => { - /// println!("Couldn't bind: {err:?}"); + /// println!("Couldn't bind: {:?}", err); /// return Err(err); /// } /// }; @@ -344,7 +344,7 @@ impl fmt::Debug for SocketAddr { match self.address() { AddressKind::Unnamed => write!(fmt, "(unnamed)"), AddressKind::Abstract(name) => write!(fmt, "{} (abstract)", AsciiEscaped(name)), - AddressKind::Pathname(path) => write!(fmt, "{path:?} (pathname)"), + AddressKind::Pathname(path) => write!(fmt, "{:?} (pathname)", path), } } } diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index fb1ff4b725ced..6e6f5212b4651 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -396,7 +396,7 @@ impl<'a> Iterator for Messages<'a> { /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { -/// println!("receive file descriptor: {fd}"); +/// println!("receive file descriptor: {}", fd); /// } /// } /// } @@ -568,7 +568,7 @@ impl<'a> SocketAncillary<'a> { /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {fd}"); + /// println!("receive file descriptor: {}", fd); /// } /// } /// } @@ -579,7 +579,7 @@ impl<'a> SocketAncillary<'a> { /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {fd}"); + /// println!("receive file descriptor: {}", fd); /// } /// } /// } diff --git a/library/std/src/os/unix/net/datagram.rs b/library/std/src/os/unix/net/datagram.rs index 59c91e9a82e1a..a2caccc784917 100644 --- a/library/std/src/os/unix/net/datagram.rs +++ b/library/std/src/os/unix/net/datagram.rs @@ -95,7 +95,7 @@ impl UnixDatagram { /// let sock = match UnixDatagram::bind("/path/to/the/socket") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't bind: {e:?}"); + /// println!("Couldn't bind: {:?}", e); /// return /// } /// }; @@ -127,7 +127,7 @@ impl UnixDatagram { /// let sock2 = match UnixDatagram::bind_addr(&addr) { /// Ok(sock) => sock, /// Err(err) => { - /// println!("Couldn't bind: {err:?}"); + /// println!("Couldn't bind: {:?}", err); /// return Err(err); /// } /// }; @@ -157,7 +157,7 @@ impl UnixDatagram { /// let sock = match UnixDatagram::unbound() { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't unbound: {e:?}"); + /// println!("Couldn't unbound: {:?}", e); /// return /// } /// }; @@ -180,7 +180,7 @@ impl UnixDatagram { /// let (sock1, sock2) = match UnixDatagram::pair() { /// Ok((sock1, sock2)) => (sock1, sock2), /// Err(e) => { - /// println!("Couldn't unbound: {e:?}"); + /// println!("Couldn't unbound: {:?}", e); /// return /// } /// }; @@ -210,7 +210,7 @@ impl UnixDatagram { /// match sock.connect("/path/to/the/socket") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {e:?}"); + /// println!("Couldn't connect: {:?}", e); /// return Err(e) /// } /// }; @@ -243,7 +243,7 @@ impl UnixDatagram { /// match sock.connect_addr(&addr) { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {e:?}"); + /// println!("Couldn't connect: {:?}", e); /// return Err(e) /// } /// }; @@ -367,7 +367,7 @@ impl UnixDatagram { /// let sock = UnixDatagram::unbound()?; /// let mut buf = vec![0; 10]; /// let (size, sender) = sock.recv_from(buf.as_mut_slice())?; - /// println!("received {size} bytes from {sender:?}"); + /// println!("received {} bytes from {:?}", size, sender); /// Ok(()) /// } /// ``` @@ -422,11 +422,11 @@ impl UnixDatagram { /// let mut ancillary_buffer = [0; 128]; /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// let (size, _truncated, sender) = sock.recv_vectored_with_ancillary_from(bufs, &mut ancillary)?; - /// println!("received {size}"); + /// println!("received {}", size); /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {fd}"); + /// println!("receive file descriptor: {}", fd); /// } /// } /// } @@ -479,11 +479,11 @@ impl UnixDatagram { /// let mut ancillary_buffer = [0; 128]; /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// let (size, _truncated) = sock.recv_vectored_with_ancillary(bufs, &mut ancillary)?; - /// println!("received {size}"); + /// println!("received {}", size); /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {fd}"); + /// println!("receive file descriptor: {}", fd); /// } /// } /// } @@ -893,7 +893,7 @@ impl UnixDatagram { /// fn main() -> std::io::Result<()> { /// let sock = UnixDatagram::unbound()?; /// if let Ok(Some(err)) = sock.take_error() { - /// println!("Got error: {err:?}"); + /// println!("Got error: {:?}", err); /// } /// Ok(()) /// } diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs index 8e11d32f13071..b23dd6062f682 100644 --- a/library/std/src/os/unix/net/listener.rs +++ b/library/std/src/os/unix/net/listener.rs @@ -63,7 +63,7 @@ impl UnixListener { /// let listener = match UnixListener::bind("/path/to/the/socket") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {e:?}"); + /// println!("Couldn't connect: {:?}", e); /// return /// } /// }; @@ -98,7 +98,7 @@ impl UnixListener { /// let listener2 = match UnixListener::bind_addr(&addr) { /// Ok(sock) => sock, /// Err(err) => { - /// println!("Couldn't bind: {err:?}"); + /// println!("Couldn't bind: {:?}", err); /// return Err(err); /// } /// }; @@ -136,8 +136,8 @@ impl UnixListener { /// let listener = UnixListener::bind("/path/to/the/socket")?; /// /// match listener.accept() { - /// Ok((socket, addr)) => println!("Got a client: {addr:?}"), - /// Err(e) => println!("accept function failed: {e:?}"), + /// Ok((socket, addr)) => println!("Got a client: {:?}", addr), + /// Err(e) => println!("accept function failed: {:?}", e), /// } /// Ok(()) /// } @@ -226,7 +226,7 @@ impl UnixListener { /// let listener = UnixListener::bind("/tmp/sock")?; /// /// if let Ok(Some(err)) = listener.take_error() { - /// println!("Got error: {err:?}"); + /// println!("Got error: {:?}", err); /// } /// Ok(()) /// } diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index 3943b4fed0949..583f861a92535 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -57,7 +57,7 @@ pub use ucred::UCred; /// stream.write_all(b"hello world")?; /// let mut response = String::new(); /// stream.read_to_string(&mut response)?; -/// println!("{response}"); +/// println!("{}", response); /// Ok(()) /// } /// ``` @@ -90,7 +90,7 @@ impl UnixStream { /// let socket = match UnixStream::connect("/tmp/sock") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {e:?}"); + /// println!("Couldn't connect: {:?}", e); /// return /// } /// }; @@ -123,7 +123,7 @@ impl UnixStream { /// let sock = match UnixStream::connect_addr(&addr) { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {e:?}"); + /// println!("Couldn't connect: {:?}", e); /// return Err(e) /// } /// }; @@ -155,7 +155,7 @@ impl UnixStream { /// let (sock1, sock2) = match UnixStream::pair() { /// Ok((sock1, sock2)) => (sock1, sock2), /// Err(e) => { - /// println!("Couldn't create a pair of sockets: {e:?}"); + /// println!("Couldn't create a pair of sockets: {:?}", e); /// return /// } /// }; @@ -443,7 +443,7 @@ impl UnixStream { /// fn main() -> std::io::Result<()> { /// let socket = UnixStream::connect("/tmp/sock")?; /// if let Ok(Some(err)) = socket.take_error() { - /// println!("Got error: {err:?}"); + /// println!("Got error: {:?}", err); /// } /// Ok(()) /// } @@ -530,11 +530,11 @@ impl UnixStream { /// let mut ancillary_buffer = [0; 128]; /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// let size = socket.recv_vectored_with_ancillary(bufs, &mut ancillary)?; - /// println!("received {size}"); + /// println!("received {}", size); /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {fd}"); + /// println!("receive file descriptor: {}", fd); /// } /// } /// } diff --git a/library/std/src/os/unix/net/tests.rs b/library/std/src/os/unix/net/tests.rs index aa0df61c1920d..7ad4a02611e07 100644 --- a/library/std/src/os/unix/net/tests.rs +++ b/library/std/src/os/unix/net/tests.rs @@ -29,7 +29,7 @@ macro_rules! or_panic { ($e:expr) => { match $e { Ok(e) => e, - Err(e) => panic!("{e}"), + Err(e) => panic!("{}", e), } }; } @@ -161,19 +161,19 @@ fn long_path() { ); match UnixStream::connect(&socket_path) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } match UnixListener::bind(&socket_path) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } match UnixDatagram::bind(&socket_path) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } } @@ -524,7 +524,7 @@ fn test_abstract_namespace_too_long() { jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", ) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {e}"), + Err(e) => panic!("unexpected error {}", e), Ok(_) => panic!("unexpected success"), } } @@ -564,7 +564,7 @@ fn test_unix_stream_peek() { match stream.peek(&mut buf) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error: {e}"), + Err(e) => panic!("unexpected error: {}", e), } or_panic!(txdone.send(())); diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 03de7eed6d4c8..2b9ae3210de25 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -283,7 +283,7 @@ fn default_hook(info: &PanicInfo<'_>) { let name = thread.as_ref().and_then(|t| t.name()).unwrap_or(""); let write = |err: &mut dyn crate::io::Write| { - let _ = writeln!(err, "thread '{name}' panicked at '{msg}', {location}"); + let _ = writeln!(err, "thread '{}' panicked at '{}', {}", name, msg, location); static FIRST_PANIC: AtomicBool = AtomicBool::new(true); @@ -677,7 +677,7 @@ fn rust_panic_with_hook( // Unfortunately, this does not print a backtrace, because creating // a `Backtrace` will allocate, which we must to avoid here. let panicinfo = PanicInfo::internal_constructor(message, location, can_unwind); - rtprintpanic!("{panicinfo}\npanicked after panic::always_abort(), aborting.\n"); + rtprintpanic!("{}\npanicked after panic::always_abort(), aborting.\n", panicinfo); } crate::sys::abort_internal(); } @@ -745,5 +745,5 @@ fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! { let obj = &mut msg as *mut &mut dyn BoxMeUp; __rust_start_panic(obj) }; - rtabort!("failed to initiate panic, error {code}") + rtabort!("failed to initiate panic, error {}", code) } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index bcf5c9328b79c..e544608f83c29 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -592,7 +592,7 @@ impl AsRef for Component<'_> { /// let path = Path::new("/tmp/foo/bar.txt"); /// /// for component in path.components() { -/// println!("{component:?}"); +/// println!("{:?}", component); /// } /// ``` /// diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs index c8dc768d3fc8e..6e863787b7f39 100644 --- a/library/std/src/path/tests.rs +++ b/library/std/src/path/tests.rs @@ -1586,17 +1586,17 @@ fn test_components_debug() { let mut components = path.components(); let expected = "Components([RootDir, Normal(\"tmp\")])"; - let actual = format!("{components:?}"); + let actual = format!("{:?}", components); assert_eq!(expected, actual); let _ = components.next().unwrap(); let expected = "Components([Normal(\"tmp\")])"; - let actual = format!("{components:?}"); + let actual = format!("{:?}", components); assert_eq!(expected, actual); let _ = components.next().unwrap(); let expected = "Components([])"; - let actual = format!("{components:?}"); + let actual = format!("{:?}", components); assert_eq!(expected, actual); } @@ -1608,17 +1608,17 @@ fn test_iter_debug() { let mut iter = path.iter(); let expected = "Iter([\"/\", \"tmp\"])"; - let actual = format!("{iter:?}"); + let actual = format!("{:?}", iter); assert_eq!(expected, actual); let _ = iter.next().unwrap(); let expected = "Iter([\"tmp\"])"; - let actual = format!("{iter:?}"); + let actual = format!("{:?}", iter); assert_eq!(expected, actual); let _ = iter.next().unwrap(); let expected = "Iter([])"; - let actual = format!("{iter:?}"); + let actual = format!("{:?}", iter); assert_eq!(expected, actual); } @@ -1770,7 +1770,7 @@ fn test_windows_absolute() { fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { let prefix = "my/home"; let mut paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); paths.sort(); @@ -1783,7 +1783,7 @@ fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); let mut set = BTreeSet::new(); @@ -1801,7 +1801,7 @@ fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { let prefix = "my/home"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); let mut set = BTreeSet::new(); @@ -1819,7 +1819,7 @@ fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { fn bench_path_hashset(b: &mut test::Bencher) { let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); let mut set = HashSet::new(); @@ -1837,7 +1837,7 @@ fn bench_path_hashset(b: &mut test::Bencher) { fn bench_path_hashset_miss(b: &mut test::Bencher) { let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); let mut set = HashSet::new(); diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 225a679efd221..ebb1d8971b99d 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -607,7 +607,7 @@ mod prim_pointer {} /// /// // This loop prints: 0 1 2 /// for x in array { -/// print!("{x} "); +/// print!("{} ", x); /// } /// ``` /// @@ -646,19 +646,19 @@ mod prim_pointer {} /// // This creates a slice iterator, producing references to each value. /// for item in array.into_iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// /// // The `array_into_iter` lint suggests this change for future compatibility: /// for item in array.iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// /// // You can explicitly iterate an array by value using `IntoIterator::into_iter` /// for item in IntoIterator::into_iter(array).enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// ``` /// @@ -673,13 +673,13 @@ mod prim_pointer {} /// // This iterates by reference: /// for item in array.iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// /// // This iterates by value: /// for item in array.into_iter().enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// ``` /// @@ -702,26 +702,26 @@ mod prim_pointer {} /// // This iterates by reference: /// for item in array.iter() { /// let x: &i32 = item; -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // This iterates by value: /// for item in IntoIterator::into_iter(array) { /// let x: i32 = item; -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // This iterates by value: /// for item in array { /// let x: i32 = item; -/// println!("{x}"); +/// println!("{}", x); /// } /// /// // IntoIter can also start a chain. /// // This iterates by value: /// for item in IntoIterator::into_iter(array).enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{i}] = {x}"); +/// println!("array[{}] = {}", i, x); /// } /// ``` /// diff --git a/library/std/src/process.rs b/library/std/src/process.rs index d88ab6253712a..e3fff155e4722 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -915,7 +915,7 @@ impl Command { /// .status() /// .expect("failed to execute process"); /// - /// println!("process finished with: {status}"); + /// println!("process finished with: {}", status); /// /// assert!(status.success()); /// ``` @@ -1434,7 +1434,7 @@ impl ExitStatus { /// .status() /// .expect("ls could not be executed"); /// - /// println!("ls: {status}"); + /// println!("ls: {}", status); /// status.exit_ok().expect_err("/dev/nonexistent could be listed!"); /// # } // cfg!(unix) /// ``` @@ -1459,7 +1459,7 @@ impl ExitStatus { /// if status.success() { /// println!("'projects/' directory created"); /// } else { - /// println!("failed to create 'projects/' directory: {status}"); + /// println!("failed to create 'projects/' directory: {}", status); /// } /// ``` #[must_use] @@ -1490,7 +1490,7 @@ impl ExitStatus { /// .expect("failed to execute mkdir"); /// /// match status.code() { - /// Some(code) => println!("Exited with status code: {code}"), + /// Some(code) => println!("Exited with status code: {}", code), /// None => println!("Process terminated by signal") /// } /// ``` @@ -1806,13 +1806,13 @@ impl Child { /// let mut child = Command::new("ls").spawn().unwrap(); /// /// match child.try_wait() { - /// Ok(Some(status)) => println!("exited with: {status}"), + /// Ok(Some(status)) => println!("exited with: {}", status), /// Ok(None) => { /// println!("status not ready yet, let's really wait"); /// let res = child.wait(); - /// println!("result: {res:?}"); + /// println!("result: {:?}", res); /// } - /// Err(e) => println!("error attempting to wait: {e}"), + /// Err(e) => println!("error attempting to wait: {}", e), /// } /// ``` #[stable(feature = "process_try_wait", since = "1.18.0")] @@ -1912,7 +1912,7 @@ impl Child { /// std::process::exit(match run_app() { /// Ok(_) => 0, /// Err(err) => { -/// eprintln!("error: {err:?}"); +/// eprintln!("error: {:?}", err); /// 1 /// } /// }); @@ -2071,7 +2071,7 @@ impl Termination for ! { impl Termination for Result { fn report(self) -> ExitCode { let Err(err) = self; - eprintln!("Error: {err:?}"); + eprintln!("Error: {:?}", err); ExitCode::FAILURE.report() } } diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index 4f779ab4e786c..e5cdc4737068a 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -64,7 +64,7 @@ fn signal_reported_right() { p.kill().unwrap(); match p.wait().unwrap().signal() { Some(9) => {} - result => panic!("not terminated by signal 9 (instead, {result:?})"), + result => panic!("not terminated by signal 9 (instead, {:?})", result), } } @@ -252,7 +252,8 @@ fn test_override_env() { assert!( output.contains("RUN_TEST_NEW_ENV=123"), - "didn't find RUN_TEST_NEW_ENV inside of:\n\n{output}", + "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", + output ); } @@ -264,7 +265,8 @@ fn test_add_to_env() { assert!( output.contains("RUN_TEST_NEW_ENV=123"), - "didn't find RUN_TEST_NEW_ENV inside of:\n\n{output}" + "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", + output ); } @@ -286,11 +288,13 @@ fn test_capture_env_at_spawn() { assert!( output.contains("RUN_TEST_NEW_ENV1=123"), - "didn't find RUN_TEST_NEW_ENV1 inside of:\n\n{output}" + "didn't find RUN_TEST_NEW_ENV1 inside of:\n\n{}", + output ); assert!( output.contains("RUN_TEST_NEW_ENV2=456"), - "didn't find RUN_TEST_NEW_ENV2 inside of:\n\n{output}" + "didn't find RUN_TEST_NEW_ENV2 inside of:\n\n{}", + output ); } diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index 87d01daeafc4c..ee35598bab5fe 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -19,7 +19,7 @@ //! B = 4; //! A = A + B; //! C = B; -//! println!("{A} {B} {C}"); +//! println!("{} {} {}", A, B, C); //! C = A; //! } //! } diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index e85a872396518..2e54321e127c0 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -129,7 +129,7 @@ //! //! // Unbounded receiver waiting for all senders to complete. //! while let Ok(msg) = rx.recv() { -//! println!("{msg}"); +//! println!("{}", msg); //! } //! //! println!("completed"); @@ -376,7 +376,7 @@ impl !Sync for Receiver {} /// }); /// /// for x in recv.iter() { -/// println!("Got: {x}"); +/// println!("Got: {}", x); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -419,7 +419,7 @@ pub struct Iter<'a, T: 'a> { /// thread::sleep(Duration::from_secs(2)); // block for two seconds /// /// for x in receiver.try_iter() { -/// println!("Got: {x}"); +/// println!("Got: {}", x); /// } /// ``` #[stable(feature = "receiver_try_iter", since = "1.15.0")] @@ -453,7 +453,7 @@ pub struct TryIter<'a, T: 'a> { /// }); /// /// for x in recv.into_iter() { -/// println!("Got: {x}"); +/// println!("Got: {}", x); /// } /// ``` #[stable(feature = "receiver_into_iter", since = "1.1.0")] @@ -544,16 +544,16 @@ impl !Sync for Sender {} /// let mut msg; /// /// msg = receiver.recv().unwrap(); -/// println!("message {msg} received"); +/// println!("message {} received", msg); /// /// // "Thread unblocked!" will be printed now /// /// msg = receiver.recv().unwrap(); -/// println!("message {msg} received"); +/// println!("message {} received", msg); /// /// msg = receiver.recv().unwrap(); /// -/// println!("message {msg} received"); +/// println!("message {} received", msg); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct SyncSender { @@ -996,14 +996,14 @@ impl SyncSender { /// /// let mut msg; /// msg = receiver.recv().unwrap(); - /// println!("message {msg} received"); + /// println!("message {} received", msg); /// /// msg = receiver.recv().unwrap(); - /// println!("message {msg} received"); + /// println!("message {} received", msg); /// /// // Third message may have never been sent /// match receiver.try_recv() { - /// Ok(msg) => println!("message {msg} received"), + /// Ok(msg) => println!("message {} received", msg), /// Err(_) => println!("the third message was never sent"), /// } /// ``` diff --git a/library/std/src/sync/mpsc/shared.rs b/library/std/src/sync/mpsc/shared.rs index 5616265554410..8487a5f8b50d3 100644 --- a/library/std/src/sync/mpsc/shared.rs +++ b/library/std/src/sync/mpsc/shared.rs @@ -369,7 +369,7 @@ impl Packet { match self.channels.fetch_sub(1, Ordering::SeqCst) { 1 => {} n if n > 1 => return, - n => panic!("bad number of channels left {n}"), + n => panic!("bad number of channels left {}", n), } match self.cnt.swap(DISCONNECTED, Ordering::SeqCst) { diff --git a/library/std/src/sync/mutex/tests.rs b/library/std/src/sync/mutex/tests.rs index 93900566f1194..a1b5aeddcb66a 100644 --- a/library/std/src/sync/mutex/tests.rs +++ b/library/std/src/sync/mutex/tests.rs @@ -94,7 +94,7 @@ fn test_into_inner_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().into_inner() { Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), - Ok(x) => panic!("into_inner of poisoned Mutex is Ok: {x:?}"), + Ok(x) => panic!("into_inner of poisoned Mutex is Ok: {:?}", x), } } @@ -118,7 +118,7 @@ fn test_get_mut_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().get_mut() { Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), - Ok(x) => panic!("get_mut of poisoned Mutex is Ok: {x:?}"), + Ok(x) => panic!("get_mut of poisoned Mutex is Ok: {:?}", x), } } diff --git a/library/std/src/sync/poison.rs b/library/std/src/sync/poison.rs index 07a90da449c9d..fa950331e644a 100644 --- a/library/std/src/sync/poison.rs +++ b/library/std/src/sync/poison.rs @@ -73,7 +73,7 @@ pub struct Guard { /// Ok(_) => unreachable!(), /// Err(p_err) => { /// let data = p_err.get_ref(); -/// println!("recovered: {data}"); +/// println!("recovered: {}", data); /// } /// }; /// ``` diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs index 53aa2b1e38a91..e9b74fb3ecc86 100644 --- a/library/std/src/sync/rwlock/tests.rs +++ b/library/std/src/sync/rwlock/tests.rs @@ -218,7 +218,7 @@ fn test_into_inner_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().into_inner() { Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), - Ok(x) => panic!("into_inner of poisoned RwLock is Ok: {x:?}"), + Ok(x) => panic!("into_inner of poisoned RwLock is Ok: {:?}", x), } } @@ -242,6 +242,6 @@ fn test_get_mut_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().get_mut() { Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), - Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {x:?}"), + Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {:?}", x), } } diff --git a/library/std/src/sys/sgx/abi/mod.rs b/library/std/src/sys/sgx/abi/mod.rs index 9508c38741551..5df08a4ff593c 100644 --- a/library/std/src/sys/sgx/abi/mod.rs +++ b/library/std/src/sys/sgx/abi/mod.rs @@ -95,7 +95,7 @@ extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64 pub(super) fn exit_with_code(code: isize) -> ! { if code != 0 { if let Some(mut out) = panic::SgxPanicOutput::new() { - let _ = write!(out, "Exited with status code {code}"); + let _ = write!(out, "Exited with status code {}", code); } } usercalls::exit(code != 0); diff --git a/library/std/src/sys/sgx/abi/usercalls/mod.rs b/library/std/src/sys/sgx/abi/usercalls/mod.rs index 4030355f13518..a6a659df291fc 100644 --- a/library/std/src/sys/sgx/abi/usercalls/mod.rs +++ b/library/std/src/sys/sgx/abi/usercalls/mod.rs @@ -83,7 +83,7 @@ pub fn close(fd: Fd) { fn string_from_bytebuffer(buf: &alloc::UserRef, usercall: &str, arg: &str) -> String { String::from_utf8(buf.copy_user_buffer()) - .unwrap_or_else(|_| rtabort!("Usercall {usercall}: expected {arg} to be valid UTF-8")) + .unwrap_or_else(|_| rtabort!("Usercall {}: expected {} to be valid UTF-8", usercall, arg)) } /// Usercall `bind_stream`. See the ABI documentation for more information. @@ -287,7 +287,7 @@ fn check_os_error(err: Result) -> i32 { { err } else { - rtabort!("Usercall: returned invalid error value {err}") + rtabort!("Usercall: returned invalid error value {}", err) } } diff --git a/library/std/src/sys/sgx/abi/usercalls/raw.rs b/library/std/src/sys/sgx/abi/usercalls/raw.rs index 4267b96ccd504..b0e6a6aaed7b9 100644 --- a/library/std/src/sys/sgx/abi/usercalls/raw.rs +++ b/library/std/src/sys/sgx/abi/usercalls/raw.rs @@ -132,7 +132,7 @@ impl RegisterArgument for Option> { impl ReturnValue for ! { fn from_registers(call: &'static str, _regs: (Register, Register)) -> Self { - rtabort!("Usercall {call}: did not expect to be re-entered"); + rtabort!("Usercall {}: did not expect to be re-entered", call); } } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index feb0b62dcd1f7..d14990c6877af 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -501,7 +501,7 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { type Error = io::Error; fn try_from((host, port): (&'a str, u16)) -> io::Result { - LookupHost::new(format!("{host}:{port}")) + LookupHost::new(format!("{}:{}", host, port)) } } diff --git a/library/std/src/sys/sgx/os.rs b/library/std/src/sys/sgx/os.rs index 5da0257f35de5..5f8b8def7c670 100644 --- a/library/std/src/sys/sgx/os.rs +++ b/library/std/src/sys/sgx/os.rs @@ -22,7 +22,7 @@ pub fn error_string(errno: i32) -> String { if errno == RESULT_SUCCESS { "operation successful".into() } else if ((Error::UserRangeStart as _)..=(Error::UserRangeEnd as _)).contains(&errno) { - format!("user-specified error {errno:08x}") + format!("user-specified error {:08x}", errno) } else { decode_error_kind(errno).as_str().into() } diff --git a/library/std/src/sys/sgx/stdio.rs b/library/std/src/sys/sgx/stdio.rs index 2e680e740fde3..8ccf043b5b57f 100644 --- a/library/std/src/sys/sgx/stdio.rs +++ b/library/std/src/sys/sgx/stdio.rs @@ -83,6 +83,6 @@ pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) { } let buf = unsafe { slice::from_raw_parts(m as *const u8, s as _) }; if let Ok(s) = str::from_utf8(&buf[..buf.iter().position(|&b| b == 0).unwrap_or(buf.len())]) { - eprint!("{s}"); + eprint!("{}", s); } } diff --git a/library/std/src/sys/solid/mod.rs b/library/std/src/sys/solid/mod.rs index 049460755d65a..2082c9401535e 100644 --- a/library/std/src/sys/solid/mod.rs +++ b/library/std/src/sys/solid/mod.rs @@ -87,7 +87,7 @@ pub fn hashmap_random_keys() -> (u64, u64) { unsafe { let mut out = crate::mem::MaybeUninit::<[u64; 2]>::uninit(); let result = abi::SOLID_RNG_SampleRandomBytes(out.as_mut_ptr() as *mut u8, 16); - assert_eq!(result, 0, "SOLID_RNG_SampleRandomBytes failed: {result}"); + assert_eq!(result, 0, "SOLID_RNG_SampleRandomBytes failed: {}", result); let [x1, x2] = out.assume_init(); (x1, x2) } diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index faeda5a854d9f..a43407bd0f865 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -157,7 +157,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { }; Err(io::Error::new( io::ErrorKind::Uncategorized, - &format!("failed to lookup address information: {msg}")[..], + &format!("failed to lookup address information: {}", msg)[..], )) } } diff --git a/library/std/src/sys/solid/os.rs b/library/std/src/sys/solid/os.rs index 127cca3accad9..22239e1fa8ebc 100644 --- a/library/std/src/sys/solid/os.rs +++ b/library/std/src/sys/solid/os.rs @@ -26,7 +26,7 @@ pub fn errno() -> i32 { } pub fn error_string(errno: i32) -> String { - if let Some(name) = error::error_name(errno) { name.to_owned() } else { format!("{errno}") } + if let Some(name) = error::error_name(errno) { name.to_owned() } else { format!("{}", errno) } } pub fn getcwd() -> io::Result { diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index e6fd9a0c827e2..61c15ecd85de3 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -54,7 +54,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { Err(io::Error::new( io::ErrorKind::Uncategorized, - &format!("failed to lookup address information: {detail}")[..], + &format!("failed to lookup address information: {}", detail)[..], )) } diff --git a/library/std/src/sys/unix/os_str/tests.rs b/library/std/src/sys/unix/os_str/tests.rs index 213277f01f2a6..3796737815573 100644 --- a/library/std/src/sys/unix/os_str/tests.rs +++ b/library/std/src/sys/unix/os_str/tests.rs @@ -4,7 +4,7 @@ use super::*; fn slice_debug_output() { let input = Slice::from_u8_slice(b"\xF0hello,\tworld"); let expected = r#""\xF0hello,\tworld""#; - let output = format!("{input:?}"); + let output = format!("{:?}", input); assert_eq!(output, expected); } diff --git a/library/std/src/sys/unix/process/process_fuchsia.rs b/library/std/src/sys/unix/process/process_fuchsia.rs index e3347ab12a730..09bfd9680f5b2 100644 --- a/library/std/src/sys/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/unix/process/process_fuchsia.rs @@ -211,7 +211,7 @@ impl Process { return Ok(None); } _ => { - panic!("Failed to wait on process handle: {status}"); + panic!("Failed to wait on process handle: {}", status); } } zx_cvt(zx_object_get_info( diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 9c477e5addc44..07a0339c066bc 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -120,7 +120,7 @@ impl Command { Err(ref e) if e.kind() == ErrorKind::Interrupted => {} Err(e) => { assert!(p.wait().is_ok(), "wait() should either return Ok or panic"); - panic!("the CLOEXEC pipe failed: {e:?}") + panic!("the CLOEXEC pipe failed: {:?}", e) } Ok(..) => { // pipe I/O up to PIPE_BUF bytes should be atomic @@ -682,15 +682,15 @@ impl From for ExitStatus { impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { - write!(f, "exit status: {code}") + write!(f, "exit status: {}", code) } else if let Some(signal) = self.signal() { if self.core_dumped() { - write!(f, "signal: {signal} (core dumped)") + write!(f, "signal: {} (core dumped)", signal) } else { - write!(f, "signal: {signal}") + write!(f, "signal: {}", signal) } } else if let Some(signal) = self.stopped_signal() { - write!(f, "stopped (not terminated) by signal: {signal}") + write!(f, "stopped (not terminated) by signal: {}", signal) } else if self.continued() { write!(f, "continued (WIFCONTINUED)") } else { diff --git a/library/std/src/sys/unix/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs index 016bc20ec0a47..56ed6cfeb6a6b 100644 --- a/library/std/src/sys/unix/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -239,10 +239,10 @@ impl From for ExitStatus { impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { - write!(f, "exit code: {code}") + write!(f, "exit code: {}", code) } else { let signal = self.signal().unwrap(); - write!(f, "signal: {signal}") + write!(f, "signal: {}", signal) } } } diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs index 17e8efbe097ce..7a3f6b0d95a09 100644 --- a/library/std/src/sys/unix/rand.rs +++ b/library/std/src/sys/unix/rand.rs @@ -82,7 +82,7 @@ mod imp { } else if err == libc::EAGAIN { return false; } else { - panic!("unexpected getrandom error: {err}"); + panic!("unexpected getrandom error: {}", err); } } else { read += result as usize; diff --git a/library/std/src/sys/windows/os.rs b/library/std/src/sys/windows/os.rs index 450bceae00081..5f8556c3bc376 100644 --- a/library/std/src/sys/windows/os.rs +++ b/library/std/src/sys/windows/os.rs @@ -64,7 +64,7 @@ pub fn error_string(mut errnum: i32) -> String { if res == 0 { // Sometimes FormatMessageW can fail e.g., system doesn't like langId, let fm_err = errno(); - return format!("OS Error {errnum} (FormatMessageW() returned error {fm_err})"); + return format!("OS Error {} (FormatMessageW() returned error {})", errnum, fm_err); } match String::from_utf16(&buf[..res]) { diff --git a/library/std/src/sys/windows/process/tests.rs b/library/std/src/sys/windows/process/tests.rs index d8c9beb0c1975..d18c3d855bcce 100644 --- a/library/std/src/sys/windows/process/tests.rs +++ b/library/std/src/sys/windows/process/tests.rs @@ -121,7 +121,9 @@ fn windows_env_unicode_case() { assert_eq!( env::var(key).ok(), value.map(|s| s.to_string_lossy().into_owned()), - "command environment mismatch: {a} {b}", + "command environment mismatch: {} {}", + a, + b ); } } diff --git a/library/std/src/sys/windows/thread_parker.rs b/library/std/src/sys/windows/thread_parker.rs index 5888ee8e34bfb..5a8011a958808 100644 --- a/library/std/src/sys/windows/thread_parker.rs +++ b/library/std/src/sys/windows/thread_parker.rs @@ -230,7 +230,7 @@ fn keyed_event_handle() -> c::HANDLE { 0, ) { c::STATUS_SUCCESS => {} - r => panic!("Unable to create keyed event handle: error {r}"), + r => panic!("Unable to create keyed event handle: error {}", r), } } match HANDLE.compare_exchange(INVALID, handle as usize, Relaxed, Relaxed) { diff --git a/library/std/src/sys_common/backtrace.rs b/library/std/src/sys_common/backtrace.rs index 31164afdc7b54..b0b55592f6f37 100644 --- a/library/std/src/sys_common/backtrace.rs +++ b/library/std/src/sys_common/backtrace.rs @@ -174,7 +174,7 @@ pub fn output_filename( if let Some(cwd) = cwd { if let Ok(stripped) = file.strip_prefix(&cwd) { if let Some(s) = stripped.to_str() { - return write!(fmt, ".{}{s}", path::MAIN_SEPARATOR); + return write!(fmt, ".{}{}", path::MAIN_SEPARATOR, s); } } } diff --git a/library/std/src/sys_common/net/tests.rs b/library/std/src/sys_common/net/tests.rs index ac75d9ebfc855..7d45621e09ae4 100644 --- a/library/std/src/sys_common/net/tests.rs +++ b/library/std/src/sys_common/net/tests.rs @@ -6,7 +6,7 @@ fn no_lookup_host_duplicates() { let mut addrs = HashMap::new(); let lh = match LookupHost::try_from(("localhost", 0)) { Ok(lh) => lh, - Err(e) => panic!("couldn't resolve `localhost': {e}"), + Err(e) => panic!("couldn't resolve `localhost': {}", e), }; for sa in lh { *addrs.entry(sa).or_insert(0) += 1; diff --git a/library/std/src/sys_common/thread_parker/generic.rs b/library/std/src/sys_common/thread_parker/generic.rs index ffb61200e15f9..d99e901bb5f83 100644 --- a/library/std/src/sys_common/thread_parker/generic.rs +++ b/library/std/src/sys_common/thread_parker/generic.rs @@ -84,7 +84,7 @@ impl Parker { match self.state.swap(EMPTY, SeqCst) { NOTIFIED => {} // got a notification, hurray! PARKED => {} // no notification, alas - n => panic!("inconsistent park_timeout state: {n}"), + n => panic!("inconsistent park_timeout state: {}", n), } } diff --git a/library/std/src/sys_common/wtf8.rs b/library/std/src/sys_common/wtf8.rs index 10ef6662115c1..7a6e6246357d1 100644 --- a/library/std/src/sys_common/wtf8.rs +++ b/library/std/src/sys_common/wtf8.rs @@ -830,7 +830,7 @@ pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { #[inline(never)] pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! { assert!(begin <= end); - panic!("index {begin} and/or {end} in `{s:?}` do not lie on character boundary"); + panic!("index {} and/or {} in `{:?}` do not lie on character boundary", begin, end, s); } /// Iterator for the code points of a WTF-8 string. diff --git a/library/std/src/sys_common/wtf8/tests.rs b/library/std/src/sys_common/wtf8/tests.rs index 931996791fbe5..1bafbaa693922 100644 --- a/library/std/src/sys_common/wtf8/tests.rs +++ b/library/std/src/sys_common/wtf8/tests.rs @@ -266,7 +266,7 @@ fn wtf8buf_extend() { fn wtf8buf_show() { let mut string = Wtf8Buf::from_str("a\té \u{7f}💩\r"); string.push(CodePoint::from_u32(0xD800).unwrap()); - assert_eq!(format!("{string:?}"), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{d800}\""); + assert_eq!(format!("{:?}", string), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{d800}\""); } #[test] @@ -278,7 +278,7 @@ fn wtf8buf_as_slice() { fn wtf8buf_show_str() { let text = "a\té 💩\r"; let string = Wtf8Buf::from_str(text); - assert_eq!(format!("{text:?}"), format!("{string:?}")); + assert_eq!(format!("{:?}", text), format!("{:?}", string)); } #[test] diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index ae292caaed994..74b29454b94a4 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -613,7 +613,7 @@ impl Builder { /// /// let receiver = thread::spawn(move || { /// let value = rx.recv().expect("Unable to receive from channel"); -/// println!("{value}"); +/// println!("{}", value); /// }); /// /// sender.join().expect("The sender thread has panicked"); @@ -633,7 +633,7 @@ impl Builder { /// }); /// /// let result = computation.join().unwrap(); -/// println!("{result}"); +/// println!("{}", result); /// ``` /// /// [`channels`]: crate::sync::mpsc @@ -979,7 +979,7 @@ pub fn park_timeout_ms(ms: u32) { /// if elapsed >= timeout { /// break; /// } -/// println!("restarting park_timeout after {elapsed:?}"); +/// println!("restarting park_timeout after {:?}", elapsed); /// timeout_remaining = timeout - elapsed; /// } /// ``` diff --git a/library/std/src/thread/scoped.rs b/library/std/src/thread/scoped.rs index 07e113f3b6222..c4847b529a361 100644 --- a/library/std/src/thread/scoped.rs +++ b/library/std/src/thread/scoped.rs @@ -22,7 +22,7 @@ pub struct Scope<'scope, 'env: 'scope> { /// std::thread::scope(|s| { /// s.spawn(|| { /// let a = String::from("abcd"); - /// s.spawn(|| println!("{a:?}")); // might run after `a` is dropped + /// s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped /// }); /// }); /// ``` diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 2f8eb557b4f74..df8a726e64ecb 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -191,7 +191,7 @@ pub struct Instant(time::Instant); /// } /// Err(e) => { /// // an error occurred! -/// println!("Error: {e:?}"); +/// println!("Error: {:?}", e); /// } /// } /// } @@ -513,7 +513,7 @@ impl SystemTime { /// let new_sys_time = SystemTime::now(); /// let difference = new_sys_time.duration_since(sys_time) /// .expect("Clock may have gone backwards"); - /// println!("{difference:?}"); + /// println!("{:?}", difference); /// ``` #[stable(feature = "time2", since = "1.8.0")] pub fn duration_since(&self, earlier: SystemTime) -> Result { diff --git a/library/std/src/time/tests.rs b/library/std/src/time/tests.rs index d710a574465ce..d1a69ff8697c6 100644 --- a/library/std/src/time/tests.rs +++ b/library/std/src/time/tests.rs @@ -55,10 +55,10 @@ fn instant_elapsed() { fn instant_math() { let a = Instant::now(); let b = Instant::now(); - println!("a: {a:?}"); - println!("b: {b:?}"); + println!("a: {:?}", a); + println!("b: {:?}", b); let dur = b.duration_since(a); - println!("dur: {dur:?}"); + println!("dur: {:?}", dur); assert_almost_eq!(b - dur, a); assert_almost_eq!(a + dur, b); diff --git a/library/test/src/cli.rs b/library/test/src/cli.rs index 000f5fa3f5860..b39701a3d4288 100644 --- a/library/test/src/cli.rs +++ b/library/test/src/cli.rs @@ -149,7 +149,7 @@ fn optgroups() -> getopts::Options { } fn usage(binary: &str, options: &getopts::Options) { - let message = format!("Usage: {binary} [OPTIONS] [FILTERS...]"); + let message = format!("Usage: {} [OPTIONS] [FILTERS...]", binary); println!( r#"{usage} @@ -360,7 +360,7 @@ fn get_shuffle_seed(matches: &getopts::Matches, allow_unstable: bool) -> OptPart shuffle_seed = match env::var("RUST_TEST_SHUFFLE_SEED") { Ok(val) => match val.parse::() { Ok(n) => Some(n), - Err(_) => panic!("RUST_TEST_SHUFFLE_SEED is `{val}`, should be a number."), + Err(_) => panic!("RUST_TEST_SHUFFLE_SEED is `{}`, should be a number.", val), }, Err(_) => None, }; diff --git a/library/test/src/console.rs b/library/test/src/console.rs index c7e8507113e0c..22fcd77dccc52 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -114,11 +114,11 @@ impl ConsoleTestState { match *result { TestResult::TrOk => "ok".to_owned(), TestResult::TrFailed => "failed".to_owned(), - TestResult::TrFailedMsg(ref msg) => format!("failed: {msg}"), + TestResult::TrFailedMsg(ref msg) => format!("failed: {}", msg), TestResult::TrIgnored => { #[cfg(not(bootstrap))] if let Some(msg) = ignore_message { - format!("ignored, {msg}") + format!("ignored, {}", msg) } else { "ignored".to_owned() } @@ -132,7 +132,7 @@ impl ConsoleTestState { ) })?; if let Some(exec_time) = exec_time { - self.write_log(|| format!(" <{exec_time}>"))?; + self.write_log(|| format!(" <{}>", exec_time))?; } self.write_log(|| "\n") } @@ -171,14 +171,14 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Res } }; - writeln!(output, "{name}: {fntype}")?; - st.write_log(|| format!("{fntype} {name}\n"))?; + writeln!(output, "{}: {}", name, fntype)?; + st.write_log(|| format!("{} {}\n", fntype, name))?; } fn plural(count: u32, s: &str) -> String { match count { - 1 => format!("1 {s}"), - n => format!("{n} {s}s"), + 1 => format!("{} {}", 1, s), + n => format!("{} {}s", n, s), } } @@ -218,7 +218,7 @@ fn handle_test_result(st: &mut ConsoleTestState, completed_test: CompletedTest) TestResult::TrFailedMsg(msg) => { st.failed += 1; let mut stdout = stdout; - stdout.extend_from_slice(format!("note: {msg}").as_bytes()); + stdout.extend_from_slice(format!("note: {}", msg).as_bytes()); st.failures.push((test, stdout)); } TestResult::TrTimedFail => { diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index e6fb4f5707b35..54e9860ab5487 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -97,7 +97,7 @@ impl OutputFormatter for JunitFormatter { test_name, duration.as_secs_f64() ))?; - self.write_message(&*format!(""))?; + self.write_message(&*format!("", m))?; self.write_message("")?; } diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index f55d390aa5621..041df5216d7b3 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -96,7 +96,7 @@ impl PrettyFormatter { exec_time: Option<&time::TestExecTime>, ) -> io::Result<()> { if let (Some(opts), Some(time)) = (self.time_options, exec_time) { - let time_str = format!(" <{time}>"); + let time_str = format!(" <{}>", time); let color = if self.use_color { if opts.is_critical(desc, time) { @@ -124,7 +124,7 @@ impl PrettyFormatter { inputs: &Vec<(TestDesc, Vec)>, results_type: &str, ) -> io::Result<()> { - let results_out_str = format!("\n{results_type}:\n"); + let results_out_str = format!("\n{}:\n", results_type); self.write_plain(&results_out_str)?; @@ -147,7 +147,7 @@ impl PrettyFormatter { self.write_plain(&results_out_str)?; results.sort(); for name in &results { - self.write_plain(&format!(" {name}\n"))?; + self.write_plain(&format!(" {}\n", name))?; } Ok(()) } @@ -167,9 +167,9 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); if let Some(test_mode) = desc.test_mode() { - self.write_plain(&format!("test {name} - {test_mode} ... "))?; + self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; } else { - self.write_plain(&format!("test {name} ... "))?; + self.write_plain(&format!("test {} ... ", name))?; } Ok(()) @@ -180,11 +180,11 @@ impl OutputFormatter for PrettyFormatter { fn write_run_start(&mut self, test_count: usize, shuffle_seed: Option) -> io::Result<()> { let noun = if test_count != 1 { "tests" } else { "test" }; let shuffle_seed_msg = if let Some(shuffle_seed) = shuffle_seed { - format!(" (shuffle seed: {shuffle_seed})") + format!(" (shuffle seed: {})", shuffle_seed) } else { String::new() }; - self.write_plain(&format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) + self.write_plain(&format!("\nrunning {} {}{}\n", test_count, noun, shuffle_seed_msg)) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { @@ -266,7 +266,7 @@ impl OutputFormatter for PrettyFormatter { self.write_plain(&s)?; if let Some(ref exec_time) = state.exec_time { - let time_str = format!("; finished in {exec_time}"); + let time_str = format!("; finished in {}", exec_time); self.write_plain(&time_str)?; } diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index fb40f86b42e19..12aca7cd9a42d 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -122,7 +122,7 @@ impl TerseFormatter { self.write_plain("\nsuccesses:\n")?; successes.sort(); for name in &successes { - self.write_plain(&format!(" {name}\n"))?; + self.write_plain(&format!(" {}\n", name))?; } Ok(()) } @@ -148,7 +148,7 @@ impl TerseFormatter { self.write_plain("\nfailures:\n")?; failures.sort(); for name in &failures { - self.write_plain(&format!(" {name}\n"))?; + self.write_plain(&format!(" {}\n", name))?; } Ok(()) } @@ -156,9 +156,9 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); if let Some(test_mode) = desc.test_mode() { - self.write_plain(&format!("test {name} - {test_mode} ... "))?; + self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; } else { - self.write_plain(&format!("test {name} ... "))?; + self.write_plain(&format!("test {} ... ", name))?; } Ok(()) @@ -170,11 +170,11 @@ impl OutputFormatter for TerseFormatter { self.total_test_count = test_count; let noun = if test_count != 1 { "tests" } else { "test" }; let shuffle_seed_msg = if let Some(shuffle_seed) = shuffle_seed { - format!(" (shuffle seed: {shuffle_seed})") + format!(" (shuffle seed: {})", shuffle_seed) } else { String::new() }; - self.write_plain(&format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) + self.write_plain(&format!("\nrunning {} {}{}\n", test_count, noun, shuffle_seed_msg)) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { @@ -247,7 +247,7 @@ impl OutputFormatter for TerseFormatter { self.write_plain(&s)?; if let Some(ref exec_time) = state.exec_time { - let time_str = format!("; finished in {exec_time}"); + let time_str = format!("; finished in {}", exec_time); self.write_plain(&time_str)?; } diff --git a/library/test/src/helpers/concurrency.rs b/library/test/src/helpers/concurrency.rs index eb211157371b5..e25f524ec0566 100644 --- a/library/test/src/helpers/concurrency.rs +++ b/library/test/src/helpers/concurrency.rs @@ -6,7 +6,7 @@ pub fn get_concurrency() -> usize { if let Ok(value) = env::var("RUST_TEST_THREADS") { match value.parse::().ok() { Some(n) => n.get(), - _ => panic!("RUST_TEST_THREADS is `{value}`, should be a positive integer."), + _ => panic!("RUST_TEST_THREADS is `{}`, should be a positive integer.", value), } } else { thread::available_parallelism().map(|n| n.get()).unwrap_or(1) diff --git a/library/test/src/helpers/exit_code.rs b/library/test/src/helpers/exit_code.rs index f762f88819da5..50bb260762a70 100644 --- a/library/test/src/helpers/exit_code.rs +++ b/library/test/src/helpers/exit_code.rs @@ -13,7 +13,7 @@ pub fn get_exit_code(status: ExitStatus) -> Result { match status.code() { Some(code) => Ok(code), None => match status.signal() { - Some(signal) => Err(format!("child process exited with signal {signal}")), + Some(signal) => Err(format!("child process exited with signal {}", signal)), None => Err("child process exited with unknown signal".into()), }, } diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 088e3a23ea4d9..8fc2b4ed748c2 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -99,7 +99,7 @@ pub fn test_main(args: &[String], tests: Vec, options: Option o, Some(Err(msg)) => { - eprintln!("error: {msg}"); + eprintln!("error: {}", msg); process::exit(ERROR_EXIT_CODE); } None => return, @@ -109,7 +109,7 @@ pub fn test_main(args: &[String], tests: Vec, options: Option, options: Option {} Ok(false) => process::exit(ERROR_EXIT_CODE), Err(e) => { - eprintln!("error: io error when listing tests: {e:?}"); + eprintln!("error: io error when listing tests: {:?}", e); process::exit(ERROR_EXIT_CODE); } } @@ -153,7 +153,7 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) { .filter(|test| test.desc.name.as_slice() == name) .map(make_owned_test) .next() - .unwrap_or_else(|| panic!("couldn't find a test with the provided name '{name}'")); + .unwrap_or_else(|| panic!("couldn't find a test with the provided name '{}'", name)); let TestDescAndFn { desc, testfn } = test; let testfn = match testfn { StaticTestFn(f) => f, @@ -524,7 +524,7 @@ pub fn run_test( Arc::get_mut(&mut runtest).unwrap().get_mut().unwrap().take().unwrap()(); None } - Err(e) => panic!("failed to spawn thread to run test: {e}"), + Err(e) => panic!("failed to spawn thread to run test: {}", e), } } else { runtest(); @@ -678,7 +678,7 @@ fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box state = SeekIfEnd(0), ';' => (), - _ => return Err(format!("unrecognized format option {cur}")), + _ => return Err(format!("unrecognized format option {}", cur)), } } PushParam => { diff --git a/library/test/src/term/terminfo/parm/tests.rs b/library/test/src/term/terminfo/parm/tests.rs index c738f3ba04fce..256d1aaf446d9 100644 --- a/library/test/src/term/terminfo/parm/tests.rs +++ b/library/test/src/term/terminfo/parm/tests.rs @@ -78,15 +78,15 @@ fn test_push_bad_param() { fn test_comparison_ops() { let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])]; for &(op, bs) in v.iter() { - let s = format!("%{{1}}%{{2}}%{op}%d"); + let s = format!("%{{1}}%{{2}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), "{}", res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[0]]); - let s = format!("%{{1}}%{{1}}%{op}%d"); + let s = format!("%{{1}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), "{}", res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[1]]); - let s = format!("%{{2}}%{{1}}%{op}%d"); + let s = format!("%{{2}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), "{}", res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[2]]); diff --git a/library/test/src/term/terminfo/parser/compiled.rs b/library/test/src/term/terminfo/parser/compiled.rs index 5d40b7988b52d..b24f3f8b05e70 100644 --- a/library/test/src/term/terminfo/parser/compiled.rs +++ b/library/test/src/term/terminfo/parser/compiled.rs @@ -198,7 +198,7 @@ pub(crate) fn parse(file: &mut dyn io::Read, longnames: bool) -> Result false, 0o01036 => true, - _ => return Err(format!("invalid magic number, found {magic:o}")), + _ => return Err(format!("invalid magic number, found {:o}", magic)), }; // According to the spec, these fields must be >= -1 where -1 means that the feature is not diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs index 7f44d6e3d0f12..8c216a1e0e70e 100644 --- a/library/test/src/test_result.rs +++ b/library/test/src/test_result.rs @@ -89,7 +89,7 @@ pub fn get_result_from_exit_code( let result = match code { TR_OK => TestResult::TrOk, TR_FAILED => TestResult::TrFailed, - _ => TestResult::TrFailedMsg(format!("got unexpected return code {code}")), + _ => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)), }; // If test is already failed (or allowed to fail), do not change the result. diff --git a/src/doc/rustdoc/src/how-to-write-documentation.md b/src/doc/rustdoc/src/how-to-write-documentation.md index 38fd1db5c21e8..f89495cca3a31 100644 --- a/src/doc/rustdoc/src/how-to-write-documentation.md +++ b/src/doc/rustdoc/src/how-to-write-documentation.md @@ -126,7 +126,7 @@ use std::env; // Prints each argument on a separate line for argument in env::args() { - println!("{argument}"); + println!("{}", argument); } ``` diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md index 735521e667c91..457851b0cc7a4 100644 --- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md +++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md @@ -240,7 +240,7 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { fn main() { let answer = do_twice(add_one, 5); - println!("The answer is: {answer}"); + println!("The answer is: {}", answer); println!("With CFI enabled, you should not see the next answer"); let f: fn(i32) -> i32 = unsafe { @@ -250,7 +250,7 @@ fn main() { }; let next_answer = do_twice(f, 5); - println!("The next answer is: {next_answer}"); + println!("The next answer is: {}", next_answer); } ``` Fig. 1. Modified example from the [Advanced Functions and @@ -303,14 +303,14 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { fn main() { let answer = do_twice(add_one, 5); - println!("The answer is: {answer}"); + println!("The answer is: {}", answer); println!("With CFI enabled, you should not see the next answer"); let f: fn(i32) -> i32 = unsafe { mem::transmute::<*const u8, fn(i32) -> i32>(add_two as *const u8) }; let next_answer = do_twice(f, 5); - println!("The next answer is: {next_answer}"); + println!("The next answer is: {}", next_answer); } ``` Fig. 4. Another modified example from the [Advanced Functions and diff --git a/src/doc/unstable-book/src/language-features/box-patterns.md b/src/doc/unstable-book/src/language-features/box-patterns.md index 584f4295cba0f..bf0819ec920b7 100644 --- a/src/doc/unstable-book/src/language-features/box-patterns.md +++ b/src/doc/unstable-book/src/language-features/box-patterns.md @@ -18,10 +18,10 @@ fn main() { let b = Some(Box::new(5)); match b { Some(box n) if n < 0 => { - println!("Box contains negative number {n}"); + println!("Box contains negative number {}", n); }, Some(box n) if n >= 0 => { - println!("Box contains non-negative number {n}"); + println!("Box contains non-negative number {}", n); }, None => { println!("No box"); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2c61b7468dcc8..4fb7e8fe7f7f1 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -829,7 +829,7 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib .values .insert(a as _, Argument { name, type_: *ty, is_const: true }); } else { - panic!("unexpected non const in position {pos}"); + panic!("unexpected non const in position {}", pos); } } _ => panic!("invalid arg index"), diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 728b7720f739d..51df7313e8637 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -197,7 +197,7 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> { .to_string(); let uext = UnusedExterns { lint_level, unused_extern_names }; let unused_extern_json = serde_json::to_string(&uext).unwrap(); - eprintln!("{unused_extern_json}"); + eprintln!("{}", unused_extern_json); } } @@ -430,7 +430,7 @@ fn run_test( // We used to check if the output contained "error[{}]: " but since we added the // colored output, we can't anymore because of the color escape characters before // the ":". - lang_string.error_codes.retain(|err| !out.contains(&format!("error[{err}]"))); + lang_string.error_codes.retain(|err| !out.contains(&format!("error[{}]", err))); if !lang_string.error_codes.is_empty() { return Err(TestFailure::MissingErrorCodes(lang_string.error_codes)); @@ -510,7 +510,7 @@ crate fn make_test( // Next, any attributes that came from the crate root via #![doc(test(attr(...)))]. for attr in &opts.attrs { - prog.push_str(&format!("#![{attr}]\n")); + prog.push_str(&format!("#![{}]\n", attr)); line_offset += 1; } @@ -645,7 +645,7 @@ crate fn make_test( // parse the source, but only has false positives, not false // negatives. if s.contains(crate_name) { - prog.push_str(&format!("extern crate r#{crate_name};\n")); + prog.push_str(&format!("extern crate r#{};\n", crate_name)); line_offset += 1; } } @@ -659,7 +659,7 @@ crate fn make_test( // Give each doctest main function a unique name. // This is for example needed for the tooling around `-C instrument-coverage`. let inner_fn_name = if let Some(test_id) = test_id { - format!("_doctest_main_{test_id}") + format!("_doctest_main_{}", test_id) } else { "_inner".into() }; @@ -667,14 +667,15 @@ crate fn make_test( let (main_pre, main_post) = if returns_result { ( format!( - "fn main() {{ {inner_attr}fn {inner_fn_name}() -> Result<(), impl core::fmt::Debug> {{\n", + "fn main() {{ {}fn {}() -> Result<(), impl core::fmt::Debug> {{\n", + inner_attr, inner_fn_name ), - format!("\n}} {inner_fn_name}().unwrap() }}"), + format!("\n}} {}().unwrap() }}", inner_fn_name), ) } else if test_id.is_some() { ( - format!("fn main() {{ {inner_attr}fn {inner_fn_name}() {{\n",), - format!("\n}} {inner_fn_name}() }}"), + format!("fn main() {{ {}fn {}() {{\n", inner_attr, inner_fn_name), + format!("\n}} {}() }}", inner_fn_name), ) } else { ("fn main() {\n".into(), "\n}".into()) @@ -692,7 +693,7 @@ crate fn make_test( prog.extend([&main_pre, everything_else, &main_post].iter().cloned()); } - debug!("final doctest:\n{prog}"); + debug!("final doctest:\n{}", prog); (prog, line_offset, supports_color) } @@ -760,9 +761,9 @@ fn partition_source(s: &str) -> (String, String, String) { } } - debug!("before:\n{before}"); - debug!("crates:\n{crates}"); - debug!("after:\n{after}"); + debug!("before:\n{}", before); + debug!("crates:\n{}", crates); + debug!("after:\n{}", after); (before, after, crates) } @@ -937,7 +938,7 @@ impl Tester for Collector { ) }; - debug!("creating test {name}: {test}"); + debug!("creating test {}: {}", name, test); self.tests.push(test::TestDescAndFn { desc: test::TestDesc { name: test::DynTestName(name), @@ -991,19 +992,19 @@ impl Tester for Collector { eprint!("Some expected error codes were not found: {:?}", codes); } TestFailure::ExecutionError(err) => { - eprint!("Couldn't run the test: {err}"); + eprint!("Couldn't run the test: {}", err); if err.kind() == io::ErrorKind::PermissionDenied { eprint!(" - maybe your tempdir is mounted with noexec?"); } } TestFailure::ExecutionFailure(out) => { let reason = if let Some(code) = out.status.code() { - format!("exit code {code}") + format!("exit code {}", code) } else { String::from("terminated by signal") }; - eprintln!("Test executable failed ({reason})."); + eprintln!("Test executable failed ({}).", reason); // FIXME(#12309): An unfortunate side-effect of capturing the test // executable's output is that the relative ordering between the test's @@ -1021,11 +1022,11 @@ impl Tester for Collector { eprintln!(); if !stdout.is_empty() { - eprintln!("stdout:\n{stdout}"); + eprintln!("stdout:\n{}", stdout); } if !stderr.is_empty() { - eprintln!("stderr:\n{stderr}"); + eprintln!("stderr:\n{}", stderr); } } } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 3a3d61b1e67cc..f2856690d257a 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1314,7 +1314,7 @@ crate fn markdown_links(md: &str) -> Vec { for ev in iter { if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 { - debug!("found link: {dest}"); + debug!("found link: {}", dest); let span = span_for_link(&dest, ev.1); links.borrow_mut().push(MarkdownLink { kind, link: dest.into_string(), range: span }); } diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index a1f92afad46a6..906b8f8a24570 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -51,7 +51,7 @@ crate fn render>( let mut css = String::new(); for name in &options.markdown_css { - let s = format!("\n"); + let s = format!("\n", name); css.push_str(&s) } diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs b/src/test/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs deleted file mode 100644 index ed94c27cf05ca..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass - -#![feature(macro_metavar_expr)] - -macro_rules! nested { - ( $a:ident ) => { - macro_rules! $a { - ( $$( $b:ident ),* ) => { - $$( - macro_rules! $b { - ( $$$$( $c:ident ),* ) => { - $$$$( - fn $c() -> &'static str { stringify!($c) } - ),* - }; - } - )* - }; - } - }; -} - -fn main() { - nested!(a); - a!(b); - b!(c); - assert_eq!(c(), "c"); -} diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs b/src/test/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs deleted file mode 100644 index d05cd1b31bc12..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs +++ /dev/null @@ -1,148 +0,0 @@ -// run-pass - -#![feature(macro_metavar_expr)] - -/// Count the number of idents in a macro repetition. -macro_rules! count_idents { - ( $( $i:ident ),* ) => { - ${count(i)} - }; -} - -/// Count the number of idents in a 2-dimensional macro repetition. -macro_rules! count_idents_2 { - ( $( [ $( $i:ident ),* ] ),* ) => { - ${count(i)} - }; -} - -/// Mostly counts the number of OUTER-MOST repetitions -macro_rules! count_depth_limits { - ( $( { $( [ $( $outer:ident : ( $( $inner:ident )* ) )* ] )* } )* ) => { - ( - ( - ${count(inner)}, - ${count(inner, 0)}, - ${count(inner, 1)}, - ${count(inner, 2)}, - ${count(inner, 3)}, - ), - ( - ${count(outer)}, - ${count(outer, 0)}, - ${count(outer, 1)}, - ${count(outer, 2)}, - ), - ) - }; -} - -/// Produce (index, length) pairs for literals in a macro repetition. -/// The literal is not included in the output, so this macro uses the -/// `ignore` meta-variable expression to create a non-expanding -/// repetition binding. -macro_rules! enumerate_literals { - ( $( ($l:stmt) ),* ) => { - [$( ${ignore(l)} (${index()}, ${length()}) ),*] - }; -} - -/// Produce index and length tuples for literals in a 2-dimensional -/// macro repetition. -macro_rules! enumerate_literals_2 { - ( $( [ $( ($l:literal) ),* ] ),* ) => { - [ - $( - $( - ( - ${index(1)}, - ${length(1)}, - ${index(0)}, - ${length(0)}, - $l - ), - )* - )* - ] - }; -} - -/// Generate macros that count idents and then add a constant number -/// to the count. -/// -/// This macro uses dollar escaping to make it unambiguous as to which -/// macro the repetition belongs to. -macro_rules! make_count_adders { - ( $( $i:ident, $b:literal );* ) => { - $( - macro_rules! $i { - ( $$( $$j:ident ),* ) => { - $b + $${count(j)} - }; - } - )* - }; -} - -make_count_adders! { plus_one, 1; plus_five, 5 } - -/// Generate a macro that allows selection of a particular literal -/// from a sequence of inputs by their identifier. -/// -/// This macro uses dollar escaping to make it unambiguous as to which -/// macro the repetition belongs to, and to allow expansion of an -/// identifier the name of which is not known in the definition -/// of `make_picker`. -macro_rules! make_picker { - ( $m:ident => $( $i:ident ),* ; $p:ident ) => { - macro_rules! $m { - ( $( $$ $i:literal ),* ) => { - $$ $p - }; - } - }; -} - -make_picker!(first => a, b; a); - -make_picker!(second => a, b; b); - -fn main() { - assert_eq!(count_idents!(a, b, c), 3); - assert_eq!(count_idents_2!([a, b, c], [d, e], [f]), 6); - assert_eq!( - count_depth_limits! { - { - [ A: (a b c) D: (d e f) ] - [ G: (g h) I: (i j k l m) ] - [ N: (n) ] - } - { - [ O: (o) P: (p q) R: (r s) ] - [ T: (t u v w x y z) ] - } - }, - ((26, 2, 5, 9, 26), (9, 2, 5, 9)) - ); - assert_eq!(enumerate_literals![("foo"), ("bar")], [(0, 2), (1, 2)]); - assert_eq!( - enumerate_literals_2![ - [("foo"), ("bar"), ("baz")], - [("qux"), ("quux"), ("quuz"), ("xyzzy")] - ], - [ - (0, 2, 0, 3, "foo"), - (0, 2, 1, 3, "bar"), - (0, 2, 2, 3, "baz"), - - (1, 2, 0, 4, "qux"), - (1, 2, 1, 4, "quux"), - (1, 2, 2, 4, "quuz"), - (1, 2, 3, 4, "xyzzy"), - ] - ); - assert_eq!(plus_one!(a, b, c), 4); - assert_eq!(plus_five!(a, b), 7); - assert_eq!(first!(1, 2), 1); - assert_eq!(second!(1, 2), 2); -} diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs deleted file mode 100644 index cff6f29a15386..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs +++ /dev/null @@ -1,9 +0,0 @@ -macro_rules! count { - ( $( $e:stmt ),* ) => { - ${ count(e) } - //~^ ERROR meta-variable expressions are unstable - }; -} - -fn main() { -} diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr deleted file mode 100644 index f573194479314..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:3:10 - | -LL | ${ count(e) } - | ^^^^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` 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/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs b/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs deleted file mode 100644 index fdf16442d2aa5..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs +++ /dev/null @@ -1,165 +0,0 @@ -#![feature(macro_metavar_expr)] - -// `curly` = Right hand side curly brackets -// `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function" -// `round` = Left hand side round brackets - -macro_rules! curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { ${ count(i) } }; -} - -macro_rules! curly__no_rhs_dollar__no_round { - ( $i:ident ) => { ${ count(i) } }; - //~^ ERROR `count` can not be placed inside the inner-most repetition -} - -macro_rules! curly__rhs_dollar__round { - ( $( $i:ident ),* ) => { ${ count($i) } }; - //~^ ERROR expected identifier, found `$` - //~| ERROR expected expression, found `$` -} - -macro_rules! curly__rhs_dollar__no_round { - ( $i:ident ) => { ${ count($i) } }; - //~^ ERROR expected identifier, found `$` - //~| ERROR expected expression, found `$` -} - -macro_rules! no_curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { count(i) }; - //~^ ERROR cannot find function `count` in this scope - //~| ERROR cannot find value `i` in this scope -} - -macro_rules! no_curly__no_rhs_dollar__no_round { - ( $i:ident ) => { count(i) }; - //~^ ERROR cannot find function `count` in this scope - //~| ERROR cannot find value `i` in this scope -} - -macro_rules! no_curly__rhs_dollar__round { - ( $( $i:ident ),* ) => { count($i) }; - //~^ ERROR variable 'i' is still repeating at this depth -} - -macro_rules! no_curly__rhs_dollar__no_round { - ( $i:ident ) => { count($i) }; - //~^ ERROR cannot find function `count` in this scope -} - -// Other scenarios - -macro_rules! dollar_dollar_in_the_lhs { - ( $$ $a:ident ) => { - //~^ ERROR unexpected token: $ - }; -} - -macro_rules! extra_garbage_after_metavar { - ( $( $i:ident ),* ) => { - ${count() a b c} - //~^ ERROR unexpected token: a - //~| ERROR expected expression, found `$` - ${count(i a b c)} - //~^ ERROR unexpected token: a - ${count(i, 1 a b c)} - //~^ ERROR unexpected token: a - ${count(i) a b c} - //~^ ERROR unexpected token: a - - ${ignore(i) a b c} - //~^ ERROR unexpected token: a - ${ignore(i a b c)} - //~^ ERROR unexpected token: a - - ${index() a b c} - //~^ ERROR unexpected token: a - ${index(1 a b c)} - //~^ ERROR unexpected token: a - - ${index() a b c} - //~^ ERROR unexpected token: a - ${index(1 a b c)} - //~^ ERROR unexpected token: a - }; -} - -const IDX: usize = 1; -macro_rules! metavar_depth_is_not_literal { - ( $( $i:ident ),* ) => { ${ index(IDX) } }; - //~^ ERROR meta-variable expression depth must be a literal - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_in_the_lhs { - ( ${ length() } ) => { - //~^ ERROR unexpected token: { - //~| ERROR expected one of: `*`, `+`, or `?` - }; -} - -macro_rules! metavar_token_without_ident { - ( $( $i:ident ),* ) => { ${ ignore() } }; - //~^ ERROR expected identifier - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_with_literal_suffix { - ( $( $i:ident ),* ) => { ${ index(1u32) } }; - //~^ ERROR only unsuffixes integer literals are supported in meta-variable expressions - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_without_parens { - ( $( $i:ident ),* ) => { ${ count{i} } }; - //~^ ERROR meta-variable expression parameter must be wrapped in parentheses - //~| ERROR expected expression, found `$` -} - -macro_rules! open_brackets_without_tokens { - ( $( $i:ident ),* ) => { ${ {} } }; - //~^ ERROR expected expression, found `$` - //~| ERROR expected identifier -} - -macro_rules! unknown_count_ident { - ( $( $i:ident )* ) => { - ${count(foo)} - //~^ ERROR variable `foo` is not recognized in meta-variable expression - }; -} - -macro_rules! unknown_ignore_ident { - ( $( $i:ident )* ) => { - ${ignore(bar)} - //~^ ERROR variable `bar` is not recognized in meta-variable expression - }; -} - -macro_rules! unknown_metavar { - ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - //~^ ERROR unrecognized meta-variable expression - //~| ERROR expected expression -} - -fn main() { - curly__no_rhs_dollar__round!(a, b, c); - curly__no_rhs_dollar__no_round!(a); - curly__rhs_dollar__round!(a, b, c); - curly__rhs_dollar__no_round!(a); - no_curly__no_rhs_dollar__round!(a, b, c); - no_curly__no_rhs_dollar__no_round!(a); - no_curly__rhs_dollar__round!(a, b, c); - no_curly__rhs_dollar__no_round!(a); - //~^ ERROR cannot find value `a` in this scope - - extra_garbage_after_metavar!(a); - metavar_depth_is_not_literal!(a); - metavar_token_without_ident!(a); - metavar_with_literal_suffix!(a); - metavar_without_parens!(a); - open_brackets_without_tokens!(a); - unknown_count_ident!(a); - unknown_ignore_ident!(a); - unknown_metavar!(a); -} diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr b/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr deleted file mode 100644 index 0188938a30e8d..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr +++ /dev/null @@ -1,385 +0,0 @@ -error: expected identifier, found `$` - --> $DIR/syntax-errors.rs:17:33 - | -LL | ( $( $i:ident ),* ) => { ${ count($i) } }; - | ^^^^^ - help: try removing `$` - -error: expected identifier, found `$` - --> $DIR/syntax-errors.rs:23:26 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^^^^^ - help: try removing `$` - -error: unexpected token: $ - --> $DIR/syntax-errors.rs:53:8 - | -LL | ( $$ $a:ident ) => { - | ^ - -note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:53:8 - | -LL | ( $$ $a:ident ) => { - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:60:19 - | -LL | ${count() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:60:19 - | -LL | ${count() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:63:19 - | -LL | ${count(i a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:63:19 - | -LL | ${count(i a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:65:22 - | -LL | ${count(i, 1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:65:22 - | -LL | ${count(i, 1 a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:67:20 - | -LL | ${count(i) a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:67:20 - | -LL | ${count(i) a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:70:21 - | -LL | ${ignore(i) a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:70:21 - | -LL | ${ignore(i) a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:72:20 - | -LL | ${ignore(i a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:72:20 - | -LL | ${ignore(i a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:75:19 - | -LL | ${index() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:75:19 - | -LL | ${index() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:77:19 - | -LL | ${index(1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:77:19 - | -LL | ${index(1 a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:80:19 - | -LL | ${index() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:80:19 - | -LL | ${index() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:82:19 - | -LL | ${index(1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:82:19 - | -LL | ${index(1 a b c)} - | ^ - -error: meta-variable expression depth must be a literal - --> $DIR/syntax-errors.rs:89:33 - | -LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; - | ^^^^^ - -error: unexpected token: { - --> $DIR/syntax-errors.rs:95:8 - | -LL | ( ${ length() } ) => { - | ^^^^^^^^^^^^ - -note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:95:8 - | -LL | ( ${ length() } ) => { - | ^^^^^^^^^^^^ - -error: expected one of: `*`, `+`, or `?` - --> $DIR/syntax-errors.rs:95:8 - | -LL | ( ${ length() } ) => { - | ^^^^^^^^^^^^ - -error: expected identifier - --> $DIR/syntax-errors.rs:102:33 - | -LL | ( $( $i:ident ),* ) => { ${ ignore() } }; - | ^^^^^^ - -error: only unsuffixes integer literals are supported in meta-variable expressions - --> $DIR/syntax-errors.rs:108:33 - | -LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; - | ^^^^^ - -error: meta-variable expression parameter must be wrapped in parentheses - --> $DIR/syntax-errors.rs:114:33 - | -LL | ( $( $i:ident ),* ) => { ${ count{i} } }; - | ^^^^^ - -error: expected identifier - --> $DIR/syntax-errors.rs:120:31 - | -LL | ( $( $i:ident ),* ) => { ${ {} } }; - | ^^^^^^ - -error: unrecognized meta-variable expression - --> $DIR/syntax-errors.rs:140:33 - | -LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and length - -error: `count` can not be placed inside the inner-most repetition - --> $DIR/syntax-errors.rs:12:24 - | -LL | ( $i:ident ) => { ${ count(i) } }; - | ^^^^^^^^^^^^ - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:17:30 - | -LL | ( $( $i:ident ),* ) => { ${ count($i) } }; - | ^ expected expression -... -LL | curly__rhs_dollar__round!(a, b, c); - | ---------------------------------- in this macro invocation - | - = note: this error originates in the macro `curly__rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:23:23 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^ expected expression -... -LL | curly__rhs_dollar__no_round!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: variable 'i' is still repeating at this depth - --> $DIR/syntax-errors.rs:41:36 - | -LL | ( $( $i:ident ),* ) => { count($i) }; - | ^^ - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:60:9 - | -LL | ${count() a b c} - | ^ expected expression -... -LL | extra_garbage_after_metavar!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `extra_garbage_after_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:89:30 - | -LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; - | ^ expected expression -... -LL | metavar_depth_is_not_literal!(a); - | -------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_depth_is_not_literal` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:102:30 - | -LL | ( $( $i:ident ),* ) => { ${ ignore() } }; - | ^ expected expression -... -LL | metavar_token_without_ident!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_token_without_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:108:30 - | -LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; - | ^ expected expression -... -LL | metavar_with_literal_suffix!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_with_literal_suffix` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:114:30 - | -LL | ( $( $i:ident ),* ) => { ${ count{i} } }; - | ^ expected expression -... -LL | metavar_without_parens!(a); - | -------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_without_parens` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:120:30 - | -LL | ( $( $i:ident ),* ) => { ${ {} } }; - | ^ expected expression -... -LL | open_brackets_without_tokens!(a); - | -------------------------------- in this macro invocation - | - = note: this error originates in the macro `open_brackets_without_tokens` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: variable `foo` is not recognized in meta-variable expression - --> $DIR/syntax-errors.rs:127:17 - | -LL | ${count(foo)} - | ^^^ - -error: variable `bar` is not recognized in meta-variable expression - --> $DIR/syntax-errors.rs:134:18 - | -LL | ${ignore(bar)} - | ^^^ - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:140:30 - | -LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - | ^ expected expression -... -LL | unknown_metavar!(a); - | ------------------- in this macro invocation - | - = note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:29:30 - | -LL | ( $( $i:ident ),* ) => { count(i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__no_rhs_dollar__round!(a, b, c); - | ---------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:29:36 - | -LL | ( $( $i:ident ),* ) => { count(i) }; - | ^ not found in this scope -... -LL | no_curly__no_rhs_dollar__round!(a, b, c); - | ---------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:35:23 - | -LL | ( $i:ident ) => { count(i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__no_rhs_dollar__no_round!(a); - | ------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:35:29 - | -LL | ( $i:ident ) => { count(i) }; - | ^ not found in this scope -... -LL | no_curly__no_rhs_dollar__no_round!(a); - | ------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:46:23 - | -LL | ( $i:ident ) => { count($i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__rhs_dollar__no_round!(a); - | ---------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `a` in this scope - --> $DIR/syntax-errors.rs:153:37 - | -LL | no_curly__rhs_dollar__no_round!(a); - | ^ not found in this scope - -error: aborting due to 40 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/src/tools/tidy/src/bins.rs b/src/tools/tidy/src/bins.rs index 503df53704793..1d5ec5c31c67f 100644 --- a/src/tools/tidy/src/bins.rs +++ b/src/tools/tidy/src/bins.rs @@ -117,7 +117,7 @@ mod os_impl { .stderr(Stdio::null()) .output() .unwrap_or_else(|e| { - panic!("could not run git ls-files: {e}"); + panic!("could not run git ls-files: {}", e); }); let path_bytes = rel_path.as_os_str().as_bytes(); if output.status.success() && output.stdout.starts_with(path_bytes) { diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index d6e36c2e7db40..52429fee46150 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -340,8 +340,8 @@ fn check_exceptions( } Some(pkg_license) => { if pkg_license.as_str() != *license { - println!("dependency exception `{name}` license has changed"); - println!(" previously `{license}` now `{pkg_license}`"); + println!("dependency exception `{}` license has changed", name); + println!(" previously `{}` now `{}`", license, pkg_license); println!(" update EXCEPTIONS for the new license"); *bad = true; } @@ -418,7 +418,7 @@ fn check_dependencies( if !unapproved.is_empty() { tidy_error!(bad, "Dependencies not explicitly permitted:"); for dep in unapproved { - println!("* {dep}"); + println!("* {}", dep); } } } @@ -501,7 +501,7 @@ fn deps_of<'a>(metadata: &'a Metadata, pkg_id: &'a PackageId) -> Vec<&'a Package .nodes .iter() .find(|n| &n.id == pkg_id) - .unwrap_or_else(|| panic!("could not find `{pkg_id}` in resolve")); + .unwrap_or_else(|| panic!("could not find `{}` in resolve", pkg_id)); node.deps .iter() .map(|dep| { @@ -516,8 +516,8 @@ fn deps_of<'a>(metadata: &'a Metadata, pkg_id: &'a PackageId) -> Vec<&'a Package fn pkg_from_name<'a>(metadata: &'a Metadata, name: &'static str) -> &'a Package { let mut i = metadata.packages.iter().filter(|p| p.name == name); let result = - i.next().unwrap_or_else(|| panic!("could not find package `{name}` in package list")); - assert!(i.next().is_none(), "more than one package found for `{name}`"); + i.next().unwrap_or_else(|| panic!("could not find package `{}` in package list", name)); + assert!(i.next().is_none(), "more than one package found for `{}`", name); result } @@ -545,7 +545,7 @@ fn normal_deps_of_r<'a>( .nodes .iter() .find(|n| &n.id == pkg_id) - .unwrap_or_else(|| panic!("could not find `{pkg_id}` in resolve")); + .unwrap_or_else(|| panic!("could not find `{}` in resolve", pkg_id)); for dep in &node.deps { normal_deps_of_r(resolve, &dep.pkg, result); } diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 281773b0569c5..f6be550283a21 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -260,7 +260,7 @@ pub fn check(paths: &[&Path], bad: &mut bool) { for (err_code, error_status) in &error_codes { if !error_status.has_test && !EXEMPTED_FROM_TEST.contains(&err_code.as_str()) { - errors.push(format!("Error code {err_code} needs to have at least one UI test!")); + errors.push(format!("Error code {} needs to have at least one UI test!", err_code)); } else if error_status.has_test && EXEMPTED_FROM_TEST.contains(&err_code.as_str()) { errors.push(format!( "Error code {} has a UI test, it shouldn't be listed into EXEMPTED_FROM_TEST!", @@ -309,7 +309,7 @@ pub fn check(paths: &[&Path], bad: &mut bool) { } errors.sort(); for err in &errors { - eprintln!("{err}"); + eprintln!("{}", err); } println!("Found {} error(s) in error codes", errors.len()); if !errors.is_empty() { diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 2f22c081a54b5..9b6037c6a4ba7 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -157,7 +157,7 @@ pub fn check( .collect::>(); for &(name, _) in gate_untested.iter() { - println!("Expected a gate test for the feature '{name}'."); + println!("Expected a gate test for the feature '{}'.", name); println!( "Hint: create a failing test file named 'feature-gate-{}.rs'\ \n in the 'ui' test suite, with its failures due to\ @@ -186,7 +186,7 @@ pub fn check( lines.sort(); for line in lines { - println!("* {line}"); + println!("* {}", line); } } else { println!("* {} features", features.len()); @@ -221,7 +221,7 @@ fn find_attr_val<'a>(line: &'a str, attr: &str) -> Option<&'a str> { "issue" => &*ISSUE, "feature" => &*FEATURE, "since" => &*SINCE, - _ => unimplemented!("{attr} not handled"), + _ => unimplemented!("{} not handled", attr), }; r.captures(line).and_then(|c| c.get(1)).map(|m| m.as_str()) @@ -231,7 +231,7 @@ fn test_filen_gate(filen_underscore: &str, features: &mut Features) -> bool { let prefix = "feature_gate_"; if filen_underscore.starts_with(prefix) { for (n, f) in features.iter_mut() { - // Equivalent to filen_underscore == format!("feature_gate_{n}") + // Equivalent to filen_underscore == format!("feature_gate_{}", n) if &filen_underscore[prefix.len()..] == n { f.has_gate_test = true; return true; diff --git a/src/tools/tidy/src/primitive_docs.rs b/src/tools/tidy/src/primitive_docs.rs index f3200e0afd71a..8476650d9b5f7 100644 --- a/src/tools/tidy/src/primitive_docs.rs +++ b/src/tools/tidy/src/primitive_docs.rs @@ -8,10 +8,10 @@ pub fn check(library_path: &Path, bad: &mut bool) { let std_name = "std/src/primitive_docs.rs"; let core_name = "core/src/primitive_docs.rs"; let std_contents = std::fs::read_to_string(library_path.join(std_name)) - .unwrap_or_else(|e| panic!("failed to read library/{std_name}: {e}")); + .unwrap_or_else(|e| panic!("failed to read library/{}: {}", std_name, e)); let core_contents = std::fs::read_to_string(library_path.join(core_name)) - .unwrap_or_else(|e| panic!("failed to read library/{core_name}: {e}")); + .unwrap_or_else(|e| panic!("failed to read library/{}: {}", core_name, e)); if std_contents != core_contents { - tidy_error!(bad, "library/{core_name} and library/{std_name} have different contents"); + tidy_error!(bad, "library/{} and library/{} have different contents", core_name, std_name); } } diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 9861cba410df2..c197acd4828a1 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -153,9 +153,9 @@ fn contains_ignore_directive(can_contain: bool, contents: &str, check: &str) -> return Directive::Deny; } // Update `can_contain` when changing this - if contents.contains(&format!("// ignore-tidy-{check}")) - || contents.contains(&format!("# ignore-tidy-{check}")) - || contents.contains(&format!("/* ignore-tidy-{check} */")) + if contents.contains(&format!("// ignore-tidy-{}", check)) + || contents.contains(&format!("# ignore-tidy-{}", check)) + || contents.contains(&format!("/* ignore-tidy-{} */", check)) { Directive::Ignore(false) } else { @@ -294,7 +294,7 @@ pub fn check(path: &Path, bad: &mut bool) { suppressible_tidy_err!( err, skip_line_length, - &format!("line longer than {max_columns} chars") + &format!("line longer than {} chars", max_columns) ); } if !is_style_file && line.contains('\t') { @@ -381,7 +381,7 @@ pub fn check(path: &Path, bad: &mut bool) { n => suppressible_tidy_err!( err, skip_trailing_newlines, - &format!("too many trailing newlines ({n})") + &format!("too many trailing newlines ({})", n) ), }; if lines > LINES { diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index 723684bfa4cda..8e1749196d2ec 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -20,7 +20,7 @@ fn iter_header<'a>(contents: &'a str, it: &mut dyn FnMut(Option<&'a str>, &'a st let lncfg = &ln[open_brace + 1..close_brace]; it(Some(lncfg), ln[(close_brace + 1)..].trim_start()); } else { - panic!("malformed condition directive: expected `//[foo]`, found `{ln}`") + panic!("malformed condition directive: expected `//[foo]`, found `{}`", ln) } } else if ln.starts_with(COMMENT) { it(None, ln[COMMENT.len()..].trim_start()); @@ -61,7 +61,7 @@ pub fn check(path: &Path, bad: &mut bool) { let info = header_map.entry(cfg).or_insert(RevisionInfo::default()); info.target_arch.replace(arch); } else { - eprintln!("{file}: seems to have a malformed --target value"); + eprintln!("{}: seems to have a malformed --target value", file); *bad = true; } } diff --git a/src/tools/unicode-table-generator/src/main.rs b/src/tools/unicode-table-generator/src/main.rs index 4720ee7020f89..218e9668df4ae 100644 --- a/src/tools/unicode-table-generator/src/main.rs +++ b/src/tools/unicode-table-generator/src/main.rs @@ -277,7 +277,7 @@ fn main() { for (name, contents) in modules { table_file.push_str("#[rustfmt::skip]\n"); - table_file.push_str(&format!("pub mod {name} {{\n")); + table_file.push_str(&format!("pub mod {} {{\n", name)); for line in contents.lines() { if !line.trim().is_empty() { table_file.push_str(" "); @@ -290,7 +290,7 @@ fn main() { std::fs::write(&write_location, format!("{}\n", table_file.trim_end())).unwrap(); - println!("Total table sizes: {total_bytes} bytes"); + println!("Total table sizes: {} bytes", total_bytes); } fn version() -> String { @@ -308,7 +308,7 @@ fn version() -> String { readme[start..end].split('.').map(|v| v.parse::().expect(&v)).collect::>(); let [major, minor, micro] = [version[0], version[1], version[2]]; - out.push_str(&format!("({major}, {minor}, {micro});\n")); + out.push_str(&format!("({}, {}, {});\n", major, minor, micro)); out } @@ -322,7 +322,7 @@ fn fmt_list(values: impl IntoIterator) -> String { } else { out.push_str(line.trim_end()); out.push('\n'); - line = format!(" {piece}"); + line = format!(" {}", piece); } } out.push_str(line.trim_end()); @@ -335,7 +335,7 @@ fn generate_tests(data_path: &str, ranges: &[(&str, Vec>)]) -> String s.push_str("#![allow(incomplete_features, unused)]\n"); s.push_str("#![feature(const_generics)]\n\n"); s.push_str("\n#[allow(unused)]\nuse std::hint;\n"); - s.push_str(&format!("#[path = \"{data_path}\"]\n")); + s.push_str(&format!("#[path = \"{}\"]\n", data_path)); s.push_str("mod unicode_data;\n\n"); s.push_str("\nfn main() {\n"); diff --git a/src/tools/unicode-table-generator/src/unicode_download.rs b/src/tools/unicode-table-generator/src/unicode_download.rs index 9b2e0a25891c7..fa57f650ac082 100644 --- a/src/tools/unicode-table-generator/src/unicode_download.rs +++ b/src/tools/unicode-table-generator/src/unicode_download.rs @@ -13,12 +13,13 @@ pub fn fetch_latest() { let directory = Path::new(UNICODE_DIRECTORY); if directory.exists() { eprintln!( - "Not refetching unicode data, already exists, please delete {directory:?} to regenerate", + "Not refetching unicode data, already exists, please delete {:?} to regenerate", + directory ); return; } if let Err(e) = std::fs::create_dir_all(directory) { - panic!("Failed to create {UNICODE_DIRECTORY:?}: {e}"); + panic!("Failed to create {:?}: {}", UNICODE_DIRECTORY, e); } let output = Command::new("curl").arg(URL_PREFIX.to_owned() + README).output().unwrap(); if !output.status.success() { diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 5a0477b4b941e..e10f72a47b2c4 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -67,7 +67,7 @@ fn generate_unstable_book_files(src: &Path, out: &Path, features: &Features) { t!(fs::create_dir_all(&out)); for feature_name in &unstable_features - &unstable_section_file_names { let feature_name_underscore = feature_name.replace('-', "_"); - let file_name = format!("{feature_name}.md"); + let file_name = format!("{}.md", feature_name); let out_file_path = out.join(&file_name); let feature = &features[&feature_name_underscore]; diff --git a/src/tools/x/src/main.rs b/src/tools/x/src/main.rs index 8c47559b36939..6c0311433d676 100644 --- a/src/tools/x/src/main.rs +++ b/src/tools/x/src/main.rs @@ -58,7 +58,7 @@ fn main() { let current = match env::current_dir() { Ok(dir) => dir, Err(err) => { - eprintln!("Failed to get current directory: {err}"); + eprintln!("Failed to get current directory: {}", err); process::exit(1); } };