From f6b8876d45841a2b3b082376d3a5d265851208d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 31 Oct 2018 00:10:10 +0100 Subject: [PATCH] use String::from() instead of format!() macro to construct Strings. --- src/librustc/hir/map/mod.rs | 2 +- src/librustc_mir/borrow_check/error_reporting.rs | 4 ++-- src/librustc_mir/interpret/validity.rs | 2 +- src/librustc_mir/util/borrowck_errors.rs | 2 +- src/libsyntax/ext/expand.rs | 2 +- src/tools/compiletest/src/main.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 7a20146130d94..f5f8e3512a0ea 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -1254,7 +1254,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { Some(Node::MacroDef(_)) => { format!("macro {}{}", path_str(), id_str) } - Some(Node::Crate) => format!("root_crate"), + Some(Node::Crate) => String::from("root_crate"), None => format!("unknown node{}", id_str), } } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index b2b92a6f85784..3c4d8e09fc166 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -788,7 +788,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let what_was_dropped = match self.describe_place(place) { Some(name) => format!("`{}`", name.as_str()), - None => format!("temporary value"), + None => String::from("temporary value"), }; let label = match self.describe_place(&borrow.borrowed_place) { @@ -1028,7 +1028,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { match category { ConstraintCategory::Return => { - err.span_note(constraint_span, &format!("closure is returned here")); + err.span_note(constraint_span, "closure is returned here"); } ConstraintCategory::CallArgument => { fr_name.highlight_region_name(&mut err); diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 9d86e737dd5b6..15d0a9166a678 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -408,7 +408,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> ), _ => return validation_failure!( - format!("non-integer enum discriminant"), path + String::from("non-integer enum discriminant"), path ), } }; diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 1715086686c42..ae0483e3c140c 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -575,7 +575,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { OGN = o ); err.span_label(mutate_span, format!("cannot {}", action)); - err.span_label(match_span, format!("value is immutable in match guard")); + err.span_label(match_span, String::from("value is immutable in match guard")); self.cancel_if_wrong_origin(err, o) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 33b651e1b3854..ce326b728df45 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -687,7 +687,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { "proc_macro_hygiene", self.span, GateIssue::Language, - &format!("procedural macros cannot expand to macro definitions"), + "procedural macros cannot expand to macro definitions", ); } visit::walk_item(self, i); diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index ca30a4dd95d0e..f63950b448a14 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -766,7 +766,7 @@ fn make_test_name( .join(&testpaths.file.file_name().unwrap()); let mode_suffix = match config.compare_mode { Some(ref mode) => format!(" ({})", mode.to_str()), - None => format!(""), + None => String::new(), }; test::DynTestName(format!( "[{}{}] {}{}",