]> git.lizzy.rs Git - rust.git/commitdiff
rustc/infer: use to_owned instead of to_string with string literals
authorljedrz <ljedrz@gmail.com>
Fri, 28 Sep 2018 15:28:47 +0000 (17:28 +0200)
committerljedrz <ljedrz@gmail.com>
Sat, 29 Sep 2018 12:57:40 +0000 (14:57 +0200)
src/librustc/infer/error_reporting/need_type_info.rs
src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs
src/librustc/infer/lexical_region_resolve/graphviz.rs

index 505b1bc032d2021b9dbe6457c07b8015b460c049..efb316243fad036933d94c2cee3436074323fb9f 100644 (file)
@@ -100,7 +100,7 @@ pub fn need_type_info_err(&self,
         let mut labels = vec![(
             span,
             if &name == "_" {
-                "cannot infer type".to_string()
+                "cannot infer type".to_owned()
             } else {
                 format!("cannot infer type for `{}`", name)
             },
@@ -138,7 +138,7 @@ pub fn need_type_info_err(&self,
             // ```
             labels.clear();
             labels.push(
-                (pattern.span, "consider giving this closure parameter a type".to_string()));
+                (pattern.span, "consider giving this closure parameter a type".to_owned()));
         } else if let Some(pattern) = local_visitor.found_local_pattern {
             if let Some(simple_ident) = pattern.simple_ident() {
                 match pattern.span.compiler_desugaring_kind() {
@@ -146,12 +146,12 @@ pub fn need_type_info_err(&self,
                                          format!("consider giving `{}` a type", simple_ident))),
                     Some(CompilerDesugaringKind::ForLoop) => labels.push((
                         pattern.span,
-                        "the element type for this iterator is not specified".to_string(),
+                        "the element type for this iterator is not specified".to_owned(),
                     )),
                     _ => {}
                 }
             } else {
-                labels.push((pattern.span, "consider giving the pattern a type".to_string()));
+                labels.push((pattern.span, "consider giving the pattern a type".to_owned()));
             }
         }
 
index 97b1978cb2eb2223af8e437504a15ee63945b470..1f84c73a715833fae46ac4cd09fea46b17f8bd1b 100644 (file)
@@ -113,12 +113,12 @@ pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
             (None, None) => {
                 let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id {
                     (
-                        "this type is declared with multiple lifetimes...".to_string(),
-                        "...but data with one lifetime flows into the other here".to_string()
+                        "this type is declared with multiple lifetimes...".to_owned(),
+                        "...but data with one lifetime flows into the other here".to_owned()
                     )
                 } else {
                     (
-                        "these two types are declared with different lifetimes...".to_string(),
+                        "these two types are declared with different lifetimes...".to_owned(),
                         format!(
                             "...but data{} flows{} here",
                             span_label_var1,
@@ -133,7 +133,7 @@ pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
                 ty_sub.span,
                 ret_span,
                 "this parameter and the return type are declared \
-                 with different lifetimes...".to_string()
+                 with different lifetimes...".to_owned()
                 ,
                 format!("...but data{} is returned here", span_label_var1),
             ),
@@ -141,7 +141,7 @@ pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
                 ty_sup.span,
                 ret_span,
                 "this parameter and the return type are declared \
-                 with different lifetimes...".to_string()
+                 with different lifetimes...".to_owned()
                 ,
                 format!("...but data{} is returned here", span_label_var1),
             ),
index e4705df2eea13fc4fe9a65b459b8fa73c4e550bf..48ec3210fe72787988158e9dc47fdac03a544793 100644 (file)
@@ -198,7 +198,7 @@ fn edge_label(&self, e: &Edge) -> dot::LabelText {
         match *e {
             Edge::Constraint(ref c) =>
                 dot::LabelText::label(format!("{:?}", self.map.get(c).unwrap())),
-            Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_string()),
+            Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_owned()),
         }
     }
 }