未验证 提交 8255f9e7 编写于 作者: G Guillaume Gomez 提交者: GitHub

Rollup merge of #53418 - ekse:suggestions-applicability, r=estebank

Mark some suggestions as MachineApplicable

I think the following suggestions should be safe to mark as `MachineApplicable`.

r? @estebank
......@@ -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();
}
}
......
......@@ -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);
}
......
......@@ -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};
......@@ -407,11 +407,12 @@ pub fn report_method_error(&self,
}
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));
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册