From 831e3d58b32ad64329f0c84ac93b7b97c7d6c268 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Wed, 12 Aug 2020 15:33:07 +0300 Subject: Replace String with &'static str --- crates/ra_hir_ty/src/diagnostics.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 0b3e16ae7..56acd3bbf 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -33,8 +33,8 @@ pub struct NoSuchField { } impl Diagnostic for NoSuchField { - fn name(&self) -> String { - "no-such-field".to_string() + fn name(&self) -> &'static str { + "no-such-field" } fn message(&self) -> String { @@ -68,8 +68,8 @@ pub struct MissingFields { } impl Diagnostic for MissingFields { - fn name(&self) -> String { - "missing-structure-fields".to_string() + fn name(&self) -> &'static str { + "missing-structure-fields" } fn message(&self) -> String { let mut buf = String::from("Missing structure fields:\n"); @@ -104,8 +104,8 @@ pub struct MissingPatFields { } impl Diagnostic for MissingPatFields { - fn name(&self) -> String { - "missing-pat-fields".to_string() + fn name(&self) -> &'static str { + "missing-pat-fields" } fn message(&self) -> String { let mut buf = String::from("Missing structure fields:\n"); @@ -130,8 +130,8 @@ pub struct MissingMatchArms { } impl Diagnostic for MissingMatchArms { - fn name(&self) -> String { - "missing-match-arm".to_string() + fn name(&self) -> &'static str { + "missing-match-arm" } fn message(&self) -> String { String::from("Missing match arm") @@ -151,8 +151,8 @@ pub struct MissingOkInTailExpr { } impl Diagnostic for MissingOkInTailExpr { - fn name(&self) -> String { - "missing-ok-in-tail-expr".to_string() + fn name(&self) -> &'static str { + "missing-ok-in-tail-expr" } fn message(&self) -> String { "wrap return expression in Ok".to_string() @@ -182,8 +182,8 @@ pub struct BreakOutsideOfLoop { } impl Diagnostic for BreakOutsideOfLoop { - fn name(&self) -> String { - "break-outside-of-loop".to_string() + fn name(&self) -> &'static str { + "break-outside-of-loop" } fn message(&self) -> String { "break outside of loop".to_string() @@ -213,8 +213,8 @@ pub struct MissingUnsafe { } impl Diagnostic for MissingUnsafe { - fn name(&self) -> String { - "missing-unsafe".to_string() + fn name(&self) -> &'static str { + "missing-unsafe" } fn message(&self) -> String { format!("This operation is unsafe and requires an unsafe function or block") @@ -246,8 +246,8 @@ pub struct MismatchedArgCount { } impl Diagnostic for MismatchedArgCount { - fn name(&self) -> String { - "mismatched-arg-count".to_string() + fn name(&self) -> &'static str { + "mismatched-arg-count" } fn message(&self) -> String { let s = if self.expected == 1 { "" } else { "s" }; -- cgit v1.2.3