Skip to content

Commit f6b8876

Browse files
committed
use String::from() instead of format!() macro to construct Strings.
1 parent e8aef7c commit f6b8876

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
12541254
Some(Node::MacroDef(_)) => {
12551255
format!("macro {}{}", path_str(), id_str)
12561256
}
1257-
Some(Node::Crate) => format!("root_crate"),
1257+
Some(Node::Crate) => String::from("root_crate"),
12581258
None => format!("unknown node{}", id_str),
12591259
}
12601260
}

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
788788

789789
let what_was_dropped = match self.describe_place(place) {
790790
Some(name) => format!("`{}`", name.as_str()),
791-
None => format!("temporary value"),
791+
None => String::from("temporary value"),
792792
};
793793

794794
let label = match self.describe_place(&borrow.borrowed_place) {
@@ -1028,7 +1028,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
10281028

10291029
match category {
10301030
ConstraintCategory::Return => {
1031-
err.span_note(constraint_span, &format!("closure is returned here"));
1031+
err.span_note(constraint_span, "closure is returned here");
10321032
}
10331033
ConstraintCategory::CallArgument => {
10341034
fr_name.highlight_region_name(&mut err);

src/librustc_mir/interpret/validity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
408408
),
409409
_ =>
410410
return validation_failure!(
411-
format!("non-integer enum discriminant"), path
411+
String::from("non-integer enum discriminant"), path
412412
),
413413
}
414414
};

src/librustc_mir/util/borrowck_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
575575
OGN = o
576576
);
577577
err.span_label(mutate_span, format!("cannot {}", action));
578-
err.span_label(match_span, format!("value is immutable in match guard"));
578+
err.span_label(match_span, String::from("value is immutable in match guard"));
579579

580580
self.cancel_if_wrong_origin(err, o)
581581
}

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
687687
"proc_macro_hygiene",
688688
self.span,
689689
GateIssue::Language,
690-
&format!("procedural macros cannot expand to macro definitions"),
690+
"procedural macros cannot expand to macro definitions",
691691
);
692692
}
693693
visit::walk_item(self, i);

src/tools/compiletest/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ fn make_test_name(
766766
.join(&testpaths.file.file_name().unwrap());
767767
let mode_suffix = match config.compare_mode {
768768
Some(ref mode) => format!(" ({})", mode.to_str()),
769-
None => format!(""),
769+
None => String::new(),
770770
};
771771
test::DynTestName(format!(
772772
"[{}{}] {}{}",

0 commit comments

Comments
 (0)