]> git.lizzy.rs Git - rust.git/commitdiff
Allocate fewer Strings at a time
authorashtneoi <ashtneoi@gmail.com>
Tue, 14 Aug 2018 05:01:54 +0000 (22:01 -0700)
committerashtneoi <ashtneoi@gmail.com>
Wed, 15 Aug 2018 22:14:21 +0000 (15:14 -0700)
src/librustc_mir/borrow_check/move_errors.rs

index 5112ae9e8d2f791ca7496017b9bdcb80a32a6088..d6c875bab44f935f7c8be9da1f0bb1ec1a45290a 100644 (file)
@@ -383,7 +383,7 @@ fn add_move_error_suggestions(
         err: &mut DiagnosticBuilder<'a>,
         binds_to: &[Local],
     ) {
-        let mut suggestions: Vec<(Span, String, String)> = Vec::new();
+        let mut suggestions: Vec<(Span, &str, String)> = Vec::new();
         for local in binds_to {
             let bind_to = &self.mir.local_decls[*local];
             if let Some(
@@ -411,7 +411,7 @@ fn add_move_error_suggestions(
                     }
                     suggestions.push((
                         pat_span,
-                        format!("consider removing the `{}`", to_remove),
+                        to_remove,
                         suggestion.to_owned(),
                     ));
                 }
@@ -419,8 +419,12 @@ fn add_move_error_suggestions(
         }
         suggestions.sort_unstable_by_key(|&(span, _, _)| span);
         suggestions.dedup_by_key(|&mut (span, _, _)| span);
-        for (span, msg, suggestion) in suggestions {
-            err.span_suggestion(span, &msg, suggestion);
+        for (span, to_remove, suggestion) in suggestions {
+            err.span_suggestion(
+                span,
+                &format!("consider removing the `{}`", to_remove),
+                suggestion
+            );
         }
     }