Skip to content

Commit 9d7774c

Browse files
committed
review comments: remove unnecessary &str to String conversions
1 parent d92355c commit 9d7774c

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/librustc/infer/error_reporting/mod.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
898898

899899
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
900900
// ^^^^^^
901-
values.0.push(sig1.unsafety.prefix_str().to_string(), sig1.unsafety != sig2.unsafety);
902-
values.1.push(sig2.unsafety.prefix_str().to_string(), sig1.unsafety != sig2.unsafety);
901+
values.0.push(sig1.unsafety.prefix_str(), sig1.unsafety != sig2.unsafety);
902+
values.1.push(sig2.unsafety.prefix_str(), sig1.unsafety != sig2.unsafety);
903903

904904
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
905905
// ^^^^^^^^^^
@@ -918,8 +918,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
918918

919919
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
920920
// ^^^
921-
values.0.push_normal("fn(".to_string());
922-
values.1.push_normal("fn(".to_string());
921+
values.0.push_normal("fn(");
922+
values.1.push_normal("fn(");
923923

924924
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
925925
// ^^^^^
@@ -936,46 +936,46 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
936936
for (i, l) in sig1.inputs().iter().enumerate() {
937937
values.0.push_highlighted(l.to_string());
938938
if i != len1 - 1 {
939-
values.0.push_highlighted(", ".to_string());
939+
values.0.push_highlighted(", ");
940940
}
941941
}
942942
for (i, r) in sig2.inputs().iter().enumerate() {
943943
values.1.push_highlighted(r.to_string());
944944
if i != len2 - 1 {
945-
values.1.push_highlighted(", ".to_string());
945+
values.1.push_highlighted(", ");
946946
}
947947
}
948948
}
949949

950950
if sig1.c_variadic {
951951
if len1 > 0 {
952-
values.0.push_normal(", ".to_string());
952+
values.0.push_normal(", ");
953953
}
954-
values.0.push("...".to_string(), !sig2.c_variadic);
954+
values.0.push("...", !sig2.c_variadic);
955955
}
956956
if sig2.c_variadic {
957957
if len2 > 0 {
958-
values.1.push_normal(", ".to_string());
958+
values.1.push_normal(", ");
959959
}
960-
values.1.push("...".to_string(), !sig1.c_variadic);
960+
values.1.push("...", !sig1.c_variadic);
961961
}
962962

963963
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
964964
// ^
965-
values.0.push_normal(")".to_string());
966-
values.1.push_normal(")".to_string());
965+
values.0.push_normal(")");
966+
values.1.push_normal(")");
967967

968968
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
969969
// ^^^^^^^^
970970
let output1 = sig1.output();
971971
let output2 = sig2.output();
972972
let (x1, x2) = self.cmp(output1, output2);
973973
if !output1.is_unit() {
974-
values.0.push_normal(" -> ".to_string());
974+
values.0.push_normal(" -> ");
975975
(values.0).0.extend(x1.0);
976976
}
977977
if !output2.is_unit() {
978-
values.1.push_normal(" -> ".to_string());
978+
values.1.push_normal(" -> ");
979979
(values.1).0.extend(x2.0);
980980
}
981981
values
@@ -1240,8 +1240,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12401240
// When encountering tuples of the same size, highlight only the differing types
12411241
(&ty::Tuple(substs1), &ty::Tuple(substs2)) if substs1.len() == substs2.len() => {
12421242
let mut values = (
1243-
DiagnosticStyledString::normal("(".to_string()),
1244-
DiagnosticStyledString::normal("(".to_string()),
1243+
DiagnosticStyledString::normal("("),
1244+
DiagnosticStyledString::normal("("),
12451245
);
12461246
let len = substs1.len();
12471247
for (i, (left, right)) in substs1.types().zip(substs2.types()).enumerate() {
@@ -1251,11 +1251,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12511251
self.push_comma(&mut values.0, &mut values.1, len, i);
12521252
}
12531253
if len == 1 { // Keep the output for single element tuples as `(ty,)`.
1254-
values.0.push_normal(",".to_string());
1255-
values.1.push_normal(",".to_string());
1254+
values.0.push_normal(",");
1255+
values.1.push_normal(",");
12561256
}
1257-
values.0.push_normal(")".to_string());
1258-
values.1.push_normal(")".to_string());
1257+
values.0.push_normal(")");
1258+
values.1.push_normal(")");
12591259
values
12601260
}
12611261

src/librustc_errors/diagnostic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ impl DiagnosticStyledString {
5454
}
5555
pub fn push<S: Into<String>>(&mut self, t: S, highlight: bool) {
5656
if highlight {
57-
self.0.push(StringPart::Highlighted(t.into()));
57+
self.push_highlighted(t);
5858
} else {
59-
self.0.push(StringPart::Normal(t.into()));
59+
self.push_normal(t);
6060
}
6161
}
6262
pub fn normal<S: Into<String>>(t: S) -> DiagnosticStyledString {

0 commit comments

Comments
 (0)