about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-10-09 14:30:14 +0200
committerljedrz <ljedrz@gmail.com>2018-10-10 10:39:18 +0200
commita01a99423168ffd3ef3003c328056dc09804f1ce (patch)
treedd71748279ec6aaf5b767a16276a28560431b413 /src
parentb1a137d0159543d5a295ce86a9b7475c486efeac (diff)
downloadrust-a01a99423168ffd3ef3003c328056dc09804f1ce.tar.gz
rust-a01a99423168ffd3ef3003c328056dc09804f1ce.zip
A handful of random string-related improvements
Diffstat (limited to 'src')
-rw-r--r--src/build_helper/lib.rs12
-rw-r--r--src/librustc_errors/diagnostic.rs8
2 files changed, 10 insertions, 10 deletions
diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs
index ec94f57861d..5d174719ab2 100644
--- a/src/build_helper/lib.rs
+++ b/src/build_helper/lib.rs
@@ -91,13 +91,13 @@ pub fn try_run_suppressed(cmd: &mut Command) -> bool {
     output.status.success()
 }
 
-pub fn gnu_target(target: &str) -> String {
+pub fn gnu_target(target: &str) -> &str {
     match target {
-        "i686-pc-windows-msvc" => "i686-pc-win32".to_string(),
-        "x86_64-pc-windows-msvc" => "x86_64-pc-win32".to_string(),
-        "i686-pc-windows-gnu" => "i686-w64-mingw32".to_string(),
-        "x86_64-pc-windows-gnu" => "x86_64-w64-mingw32".to_string(),
-        s => s.to_string(),
+        "i686-pc-windows-msvc" => "i686-pc-win32",
+        "x86_64-pc-windows-msvc" => "x86_64-pc-win32",
+        "i686-pc-windows-gnu" => "i686-w64-mingw32",
+        "x86_64-pc-windows-gnu" => "x86_64-w64-mingw32",
+        s => s,
     }
 }
 
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index 2799f2cc81f..870eeadc081 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -76,9 +76,9 @@ pub enum StringPart {
 }
 
 impl StringPart {
-    pub fn content(&self) -> String {
+    pub fn content(&self) -> &str {
         match self {
-            &StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s.to_owned()
+            &StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s
         }
     }
 }
@@ -398,7 +398,7 @@ impl Diagnostic {
     }
 
     pub fn message(&self) -> String {
-        self.message.iter().map(|i| i.0.to_owned()).collect::<String>()
+        self.message.iter().map(|i| i.0.as_str()).collect::<String>()
     }
 
     pub fn styled_message(&self) -> &Vec<(String, Style)> {
@@ -448,7 +448,7 @@ impl Diagnostic {
 
 impl SubDiagnostic {
     pub fn message(&self) -> String {
-        self.message.iter().map(|i| i.0.to_owned()).collect::<String>()
+        self.message.iter().map(|i| i.0.as_str()).collect::<String>()
     }
 
     pub fn styled_message(&self) -> &Vec<(String, Style)> {