Skip to content

Commit

Permalink
A handful of random string-related improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Oct 10, 2018
1 parent b1a137d commit a01a994
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/build_helper/lib.rs
Expand Up @@ -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,
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/librustc_errors/diagnostic.rs
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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)> {
Expand Down Expand Up @@ -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)> {
Expand Down

0 comments on commit a01a994

Please sign in to comment.