Skip to content

Commit 66e2dfe

Browse files
committed
Auto 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
2 parents 6b1ff19 + e665715 commit 66e2dfe

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/librustc_borrowck/borrowck/unused.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc::hir::{self, HirId};
1313
use rustc::lint::builtin::UNUSED_MUT;
1414
use rustc::ty;
1515
use rustc::util::nodemap::{FxHashMap, FxHashSet};
16+
use errors::Applicability;
1617
use std::slice;
1718
use syntax::ptr::P;
1819

@@ -83,7 +84,11 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
8384
hir_id,
8485
span,
8586
"variable does not need to be mutable")
86-
.span_suggestion_short(mut_span, "remove this `mut`", "".to_owned())
87+
.span_suggestion_short_with_applicability(
88+
mut_span,
89+
"remove this `mut`",
90+
"".to_owned(),
91+
Applicability::MachineApplicable)
8792
.emit();
8893
}
8994
}

src/librustc_mir/borrow_check/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc::mir::{Terminator, TerminatorKind};
2424
use rustc::ty::query::Providers;
2525
use rustc::ty::{self, ParamEnv, TyCtxt, Ty};
2626

27-
use rustc_errors::{Diagnostic, DiagnosticBuilder, Level};
27+
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, Level};
2828
use rustc_data_structures::graph::dominators::Dominators;
2929
use rustc_data_structures::fx::FxHashSet;
3030
use rustc_data_structures::indexed_set::IdxSetBuf;
@@ -324,7 +324,11 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
324324
span,
325325
"variable does not need to be mutable",
326326
);
327-
err.span_suggestion_short(mut_span, "remove this `mut`", "".to_owned());
327+
err.span_suggestion_short_with_applicability(
328+
mut_span,
329+
"remove this `mut`",
330+
"".to_owned(),
331+
Applicability::MachineApplicable);
328332

329333
err.buffer(&mut mbcx.errors_buffer);
330334
}

src/librustc_typeck/check/method/suggest.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use util::nodemap::FxHashSet;
2424

2525
use syntax::ast;
2626
use syntax::util::lev_distance::find_best_match_for_name;
27-
use errors::DiagnosticBuilder;
27+
use errors::{Applicability, DiagnosticBuilder};
2828
use syntax_pos::{Span, FileName};
2929

3030

@@ -406,11 +406,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
406406
}
407407
if static_sources.len() == 1 {
408408
if let Some(expr) = rcvr_expr {
409-
err.span_suggestion(expr.span.to(span),
409+
err.span_suggestion_with_applicability(expr.span.to(span),
410410
"use associated function syntax instead",
411411
format!("{}::{}",
412412
self.ty_to_string(actual),
413-
item_name));
413+
item_name),
414+
Applicability::MachineApplicable);
414415
} else {
415416
err.help(&format!("try with `{}::{}`",
416417
self.ty_to_string(actual), item_name));

src/librustc_typeck/check_unused.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use lint;
1212
use rustc::ty::TyCtxt;
1313

14+
use errors::Applicability;
1415
use syntax::ast;
1516
use syntax_pos::Span;
1617

@@ -138,7 +139,11 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
138139
let id = tcx.hir.hir_to_node_id(hir_id);
139140
let msg = "unused extern crate";
140141
tcx.struct_span_lint_node(lint, id, span, msg)
141-
.span_suggestion_short(span, "remove it", "".to_string())
142+
.span_suggestion_short_with_applicability(
143+
span,
144+
"remove it",
145+
"".to_string(),
146+
Applicability::MachineApplicable)
142147
.emit();
143148
continue;
144149
}

0 commit comments

Comments
 (0)