about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-11-23 18:36:33 -0800
committerEsteban Küber <esteban@kuber.com.ar>2019-11-23 18:45:18 -0800
commit9d7774c64fcbe9f535f649b51add9a701f459526 (patch)
treedbe8a6c9aacd51fd1ce2076f9c0d93f29bd5d5b9 /src
parentd92355c1db65035e508020e746c141c79dfdbd99 (diff)
review comments: remove unnecessary `&str` to `String` conversions
Diffstat (limited to 'src')
-rw-r--r--src/librustc/infer/error_reporting/mod.rs40
-rw-r--r--src/librustc_errors/diagnostic.rs4
2 files changed, 22 insertions, 22 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index 7d7e7da1def..f8f69936021 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -898,8 +898,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
 
         // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
         // ^^^^^^
-        values.0.push(sig1.unsafety.prefix_str().to_string(), sig1.unsafety != sig2.unsafety);
-        values.1.push(sig2.unsafety.prefix_str().to_string(), sig1.unsafety != sig2.unsafety);
+        values.0.push(sig1.unsafety.prefix_str(), sig1.unsafety != sig2.unsafety);
+        values.1.push(sig2.unsafety.prefix_str(), sig1.unsafety != sig2.unsafety);
 
         // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
         //        ^^^^^^^^^^
@@ -918,8 +918,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
 
         // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
         //                           ^^^
-        values.0.push_normal("fn(".to_string());
-        values.1.push_normal("fn(".to_string());
+        values.0.push_normal("fn(");
+        values.1.push_normal("fn(");
 
         // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
         //                              ^^^^^
@@ -936,34 +936,34 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
             for (i, l) in sig1.inputs().iter().enumerate() {
                 values.0.push_highlighted(l.to_string());
                 if i != len1 - 1 {
-                    values.0.push_highlighted(", ".to_string());
+                    values.0.push_highlighted(", ");
                 }
             }
             for (i, r) in sig2.inputs().iter().enumerate() {
                 values.1.push_highlighted(r.to_string());
                 if i != len2 - 1 {
-                    values.1.push_highlighted(", ".to_string());
+                    values.1.push_highlighted(", ");
                 }
             }
         }
 
         if sig1.c_variadic {
             if len1 > 0 {
-                values.0.push_normal(", ".to_string());
+                values.0.push_normal(", ");
             }
-            values.0.push("...".to_string(), !sig2.c_variadic);
+            values.0.push("...", !sig2.c_variadic);
         }
         if sig2.c_variadic {
             if len2 > 0 {
-                values.1.push_normal(", ".to_string());
+                values.1.push_normal(", ");
             }
-            values.1.push("...".to_string(), !sig1.c_variadic);
+            values.1.push("...", !sig1.c_variadic);
         }
 
         // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
         //                                   ^
-        values.0.push_normal(")".to_string());
-        values.1.push_normal(")".to_string());
+        values.0.push_normal(")");
+        values.1.push_normal(")");
 
         // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
         //                                     ^^^^^^^^
@@ -971,11 +971,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         let output2 = sig2.output();
         let (x1, x2) = self.cmp(output1, output2);
         if !output1.is_unit() {
-            values.0.push_normal(" -> ".to_string());
+            values.0.push_normal(" -> ");
             (values.0).0.extend(x1.0);
         }
         if !output2.is_unit() {
-            values.1.push_normal(" -> ".to_string());
+            values.1.push_normal(" -> ");
             (values.1).0.extend(x2.0);
         }
         values
@@ -1240,8 +1240,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
             // When encountering tuples of the same size, highlight only the differing types
             (&ty::Tuple(substs1), &ty::Tuple(substs2)) if substs1.len() == substs2.len() => {
                 let mut values = (
-                    DiagnosticStyledString::normal("(".to_string()),
-                    DiagnosticStyledString::normal("(".to_string()),
+                    DiagnosticStyledString::normal("("),
+                    DiagnosticStyledString::normal("("),
                 );
                 let len = substs1.len();
                 for (i, (left, right)) in substs1.types().zip(substs2.types()).enumerate() {
@@ -1251,11 +1251,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                     self.push_comma(&mut values.0, &mut values.1, len, i);
                 }
                 if len == 1 { // Keep the output for single element tuples as `(ty,)`.
-                    values.0.push_normal(",".to_string());
-                    values.1.push_normal(",".to_string());
+                    values.0.push_normal(",");
+                    values.1.push_normal(",");
                 }
-                values.0.push_normal(")".to_string());
-                values.1.push_normal(")".to_string());
+                values.0.push_normal(")");
+                values.1.push_normal(")");
                 values
             }
 
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index 530844ceee1..abec979054e 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -54,9 +54,9 @@ impl DiagnosticStyledString {
     }
     pub fn push<S: Into<String>>(&mut self, t: S, highlight: bool) {
         if highlight {
-            self.0.push(StringPart::Highlighted(t.into()));
+            self.push_highlighted(t);
         } else {
-            self.0.push(StringPart::Normal(t.into()));
+            self.push_normal(t);
         }
     }
     pub fn normal<S: Into<String>>(t: S) -> DiagnosticStyledString {