]> git.lizzy.rs Git - rust.git/commitdiff
Attach Applicability to multipart_suggestion and span_suggestions
authorVitaly _Vi Shukela <vi0oss@gmail.com>
Sat, 15 Sep 2018 12:03:02 +0000 (15:03 +0300)
committerVitaly _Vi Shukela <vi0oss@gmail.com>
Sun, 16 Sep 2018 18:43:06 +0000 (21:43 +0300)
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/op.rs
src/libsyntax_ext/format.rs

index 2c3abb47cff567cc05c401c89c1f84696c16e316..75b9d28316008b9cef30d818c82a4b0dfd2eac9a 100644 (file)
@@ -801,7 +801,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                             .span_to_snippet(trait_m.generics.span)
                             .ok()?;
 
-                        err.multipart_suggestion(
+                        err.multipart_suggestion_with_applicability(
                             "try changing the `impl Trait` argument to a generic parameter",
                             vec![
                                 // replace `impl Trait` with `T`
@@ -811,6 +811,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                 // of the generics, but it works for the common case
                                 (generics_span, new_generics),
                             ],
+                            Applicability::Unspecified,
                         );
                         Some(())
                     })();
@@ -872,7 +873,7 @@ fn nested_visit_map<'this>(
                             .span_to_snippet(bounds)
                             .ok()?;
 
-                        err.multipart_suggestion(
+                        err.multipart_suggestion_with_applicability(
                             "try removing the generic parameter and using `impl Trait` instead",
                             vec![
                                 // delete generic parameters
@@ -880,6 +881,7 @@ fn nested_visit_map<'this>(
                                 // replace param usage with `impl Trait`
                                 (span, format!("impl {}", bounds)),
                             ],
+                            Applicability::Unspecified,
                         );
                         Some(())
                     })();
index 4e22ead8db987a0514b885a992a43eac35332084..13f3bdbb10f079f0e62c34ed9d55cb5f9d6bfed9 100644 (file)
@@ -132,9 +132,11 @@ pub fn demand_coerce_diag(&self,
                 let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr));
                 let suggestions = compatible_variants.iter()
                     .map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
-                err.span_suggestions(expr.span,
+                err.span_suggestions_with_applicability(expr.span,
                                      "try using a variant of the expected type",
-                                     suggestions);
+                                     suggestions,
+                                     Applicability::Unspecified,
+                                     );
             }
         }
 
index a678981cf011b4e6d26f2fd1a6b36b2abadd9cfe..f029ae2d954e06b25cc9262b05d30ddb3bbd46ee 100644 (file)
@@ -464,10 +464,12 @@ fn check_str_addition(
                     is_assign,
                 ) {
                     (Ok(l), Ok(r), false) => {
-                        err.multipart_suggestion(msg, vec![
+                        err.multipart_suggestion_with_applicability(msg, vec![
                             (lhs_expr.span, format!("{}.to_owned()", l)),
                             (rhs_expr.span, format!("&{}", r)),
-                        ]);
+                        ],
+                        Applicability::Unspecified,
+                        );
                     }
                     _ => {
                         err.help(msg);
index efe9c2cefdebe93b3e1e4f646e2b2093061ae5b3..b4ad777e6d7b88b583aa9e08f8a20c40031917fb 100644 (file)
@@ -996,9 +996,10 @@ macro_rules! check_foreign {
                         ));
                     }
                     if suggestions.len() > 0 {
-                        diag.multipart_suggestion(
+                        diag.multipart_suggestion_with_applicability(
                             "format specifiers use curly braces",
                             suggestions,
+                            Applicability::Unspecified,
                         );
                     }
                 }};