Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use String::from() instead of format!() macro to construct Strings. #55522

Merged
merged 1 commit into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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