Skip to content

Commit c7ff933

Browse files
author
Alexander Regueiro
committed
Fixed build for latest nightly
1 parent 1742229 commit c7ff933

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

clippy_lints/src/map_unit_fn.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc::hir;
22
use rustc::lint::*;
33
use rustc::ty;
4+
use rustc_errors::{Applicability};
45
use syntax::codemap::Span;
56
use utils::{in_macro, iter_input_pats, match_type, method_chain_args, snippet, span_lint_and_then};
67
use utils::paths;
@@ -210,25 +211,31 @@ fn lint_map_unit_fn(cx: &LateContext, stmt: &hir::Stmt, expr: &hir::Expr, map_ar
210211
snippet(cx, fn_arg.span, "_"));
211212

212213
span_lint_and_then(cx, lint, expr.span, &msg, |db| {
213-
db.span_approximate_suggestion(stmt.span, "try this", suggestion);
214+
db.span_suggestion_with_applicability(stmt.span,
215+
"try this",
216+
suggestion,
217+
Applicability::Unspecified);
214218
});
215219
} else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) {
216220
let msg = suggestion_msg("closure", map_type);
217221

218222
span_lint_and_then(cx, lint, expr.span, &msg, |db| {
219223
if let Some(reduced_expr_span) = reduce_unit_expression(cx, closure_expr) {
220224
let suggestion = format!("if let {0}({1}) = {2} {{ {3} }}",
221-
variant,
222-
snippet(cx, binding.pat.span, "_"),
223-
snippet(cx, var_arg.span, "_"),
224-
snippet(cx, reduced_expr_span, "_"));
225+
variant,
226+
snippet(cx, binding.pat.span, "_"),
227+
snippet(cx, var_arg.span, "_"),
228+
snippet(cx, reduced_expr_span, "_"));
225229
db.span_suggestion(stmt.span, "try this", suggestion);
226230
} else {
227231
let suggestion = format!("if let {0}({1}) = {2} {{ ... }}",
228-
variant,
229-
snippet(cx, binding.pat.span, "_"),
230-
snippet(cx, var_arg.span, "_"));
231-
db.span_approximate_suggestion(stmt.span, "try this", suggestion);
232+
variant,
233+
snippet(cx, binding.pat.span, "_"),
234+
snippet(cx, var_arg.span, "_"));
235+
db.span_suggestion_with_applicability(stmt.span,
236+
"try this",
237+
suggestion,
238+
Applicability::Unspecified);
232239
}
233240
});
234241
}

clippy_lints/src/utils/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::lint::{LateContext, Level, Lint, LintContext};
99
use rustc::session::Session;
1010
use rustc::traits;
1111
use rustc::ty::{self, Ty, TyCtxt, layout::{self, IntegerExt}};
12-
use rustc_errors;
12+
use rustc_errors::{Applicability, CodeSuggestion, Substitution, SubstitutionPart};
1313
use std::borrow::Cow;
1414
use std::env;
1515
use std::mem;
@@ -645,12 +645,12 @@ pub fn multispan_sugg<I>(db: &mut DiagnosticBuilder, help_msg: String, sugg: I)
645645
where
646646
I: IntoIterator<Item = (Span, String)>,
647647
{
648-
let sugg = rustc_errors::CodeSuggestion {
648+
let sugg = CodeSuggestion {
649649
substitutions: vec![
650-
rustc_errors::Substitution {
650+
Substitution {
651651
parts: sugg.into_iter()
652652
.map(|(span, snippet)| {
653-
rustc_errors::SubstitutionPart {
653+
SubstitutionPart {
654654
snippet,
655655
span,
656656
}
@@ -660,7 +660,7 @@ where
660660
],
661661
msg: help_msg,
662662
show_code_when_inline: true,
663-
approximate: false,
663+
applicability: Applicability::Unspecified,
664664
};
665665
db.suggestions.push(sugg);
666666
}

0 commit comments

Comments
 (0)