]> git.lizzy.rs Git - rust.git/commitdiff
Mark some suggestions as MachineApplicable
authorSébastien Duquette <ekse.0x@gmail.com>
Thu, 16 Aug 2018 02:59:56 +0000 (22:59 -0400)
committerSébastien Duquette <ekse.0x@gmail.com>
Thu, 16 Aug 2018 02:59:56 +0000 (22:59 -0400)
src/librustc_borrowck/borrowck/unused.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check_unused.rs

index 475ff0b744349abfb01cd4ef6f959705fe0f864f..e29842100412ca25a254879ebee5a257dde24bad 100644 (file)
@@ -13,6 +13,7 @@
 use rustc::lint::builtin::UNUSED_MUT;
 use rustc::ty;
 use rustc::util::nodemap::{FxHashMap, FxHashSet};
+use errors::Applicability;
 use std::slice;
 use syntax::ptr::P;
 
@@ -83,7 +84,11 @@ fn check_unused_mut_pat(&self, pats: &[P<hir::Pat>]) {
                                      hir_id,
                                      span,
                                      "variable does not need to be mutable")
-                .span_suggestion_short(mut_span, "remove this `mut`", "".to_owned())
+                .span_suggestion_short_with_applicability(
+                    mut_span,
+                    "remove this `mut`",
+                    "".to_owned(),
+                    Applicability::MachineApplicable)
                 .emit();
         }
     }
index f96b9b8082fa799d2aee174bd92565d7b2cf0c1b..e4e2aca0ebf0c54f9be1dc54233ddaf5225097cb 100644 (file)
@@ -24,7 +24,7 @@
 use rustc::ty::query::Providers;
 use rustc::ty::{self, ParamEnv, TyCtxt, Ty};
 
-use rustc_errors::{Diagnostic, DiagnosticBuilder, Level};
+use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, Level};
 use rustc_data_structures::graph::dominators::Dominators;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::indexed_set::IdxSetBuf;
@@ -324,7 +324,11 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
                 span,
                 "variable does not need to be mutable",
             );
-            err.span_suggestion_short(mut_span, "remove this `mut`", "".to_owned());
+            err.span_suggestion_short_with_applicability(
+                mut_span,
+                "remove this `mut`",
+                "".to_owned(),
+                Applicability::MachineApplicable);
 
             err.buffer(&mut mbcx.errors_buffer);
         }
index 0fbdecffb8be813a3f7bdd32e52e7d40b24e961d..1c78421b9a28b1e2652367954d2cfd81e8b4faf7 100644 (file)
@@ -24,7 +24,7 @@
 
 use syntax::ast;
 use syntax::util::lev_distance::find_best_match_for_name;
-use errors::DiagnosticBuilder;
+use errors::{Applicability, DiagnosticBuilder};
 use syntax_pos::{Span, FileName};
 
 
@@ -406,11 +406,12 @@ macro_rules! report_function {
                 }
                 if static_sources.len() == 1 {
                     if let Some(expr) = rcvr_expr {
-                        err.span_suggestion(expr.span.to(span),
+                        err.span_suggestion_with_applicability(expr.span.to(span),
                                             "use associated function syntax instead",
                                             format!("{}::{}",
                                                     self.ty_to_string(actual),
-                                                    item_name));
+                                                    item_name),
+                                            Applicability::MachineApplicable);
                     } else {
                         err.help(&format!("try with `{}::{}`",
                                           self.ty_to_string(actual), item_name));
index 1a57dfd745e3ac23c6342d74224d84567ece1e46..e60139ed48d992d48747cf1c70bc0ffdbabbf360 100644 (file)
@@ -11,6 +11,7 @@
 use lint;
 use rustc::ty::TyCtxt;
 
+use errors::Applicability;
 use syntax::ast;
 use syntax_pos::Span;
 
@@ -138,7 +139,11 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
             let id = tcx.hir.hir_to_node_id(hir_id);
             let msg = "unused extern crate";
             tcx.struct_span_lint_node(lint, id, span, msg)
-                .span_suggestion_short(span, "remove it", "".to_string())
+                .span_suggestion_short_with_applicability(
+                    span,
+                    "remove it",
+                    "".to_string(),
+                    Applicability::MachineApplicable)
                 .emit();
             continue;
         }