diff options
| author | Sébastien Duquette <ekse.0x@gmail.com> | 2018-08-15 22:59:56 -0400 |
|---|---|---|
| committer | Sébastien Duquette <ekse.0x@gmail.com> | 2018-08-15 22:59:56 -0400 |
| commit | e6657154c4f0359fc67730d3e9aa0eb1a4a4e108 (patch) | |
| tree | 7b28b4552dfe9b12b2cf964cfdcfbc63bf43f8e4 | |
| parent | d679b57a3a234a75926f1ffc5fe088c7ad97daf0 (diff) | |
| download | rust-e6657154c4f0359fc67730d3e9aa0eb1a4a4e108.tar.gz rust-e6657154c4f0359fc67730d3e9aa0eb1a4a4e108.zip | |
Mark some suggestions as MachineApplicable
| -rw-r--r-- | src/librustc_borrowck/borrowck/unused.rs | 7 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/mod.rs | 8 | ||||
| -rw-r--r-- | src/librustc_typeck/check/method/suggest.rs | 7 | ||||
| -rw-r--r-- | src/librustc_typeck/check_unused.rs | 7 |
4 files changed, 22 insertions, 7 deletions
diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 475ff0b7443..e2984210041 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -13,6 +13,7 @@ use rustc::hir::{self, HirId}; 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 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { 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(); } } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index f96b9b8082f..e4e2aca0ebf 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -24,7 +24,7 @@ use rustc::mir::{Terminator, TerminatorKind}; 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); } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 0fbdecffb8b..1c78421b9a2 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -24,7 +24,7 @@ use util::nodemap::FxHashSet; 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 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } 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)); diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 1a57dfd745e..e60139ed48d 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -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; } |
