Skip to content

Commit

Permalink
use String::from() instead of format!() macro to construct Strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Oct 30, 2018
1 parent e8aef7c commit f6b8876
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/util/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
"[{}{}] {}{}",
Expand Down

0 comments on commit f6b8876

Please sign in to comment.