Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark some suggestions as MachineApplicable #53418

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc_borrowck/borrowck/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};


Expand Down Expand Up @@ -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));
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_typeck/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use lint;
use rustc::ty::TyCtxt;

use errors::Applicability;
use syntax::ast;
use syntax_pos::Span;

Expand Down Expand Up @@ -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;
}
Expand Down