diff options
Diffstat (limited to 'compiler/rustc_target/src')
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 832eeec3e8b..6dd245b047c 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -108,6 +108,15 @@ pub enum LldFlavor { } impl LldFlavor { + pub fn as_str(&self) -> &'static str { + match self { + LldFlavor::Wasm => "wasm", + LldFlavor::Ld64 => "darwin", + LldFlavor::Ld => "gnu", + LldFlavor::Link => "link", + } + } + fn from_str(s: &str) -> Option<Self> { Some(match s { "darwin" => LldFlavor::Ld64, @@ -121,13 +130,7 @@ impl LldFlavor { impl ToJson for LldFlavor { fn to_json(&self) -> Json { - match *self { - LldFlavor::Ld64 => "darwin", - LldFlavor::Ld => "gnu", - LldFlavor::Link => "link", - LldFlavor::Wasm => "wasm", - } - .to_json() + self.as_str().to_json() } } |
