|
1 | 1 | use rustc::hir; |
2 | 2 | use rustc::lint::*; |
3 | 3 | use rustc::ty; |
| 4 | +use rustc_errors::{Applicability}; |
4 | 5 | use syntax::codemap::Span; |
5 | 6 | use utils::{in_macro, iter_input_pats, match_type, method_chain_args, snippet, span_lint_and_then}; |
6 | 7 | use utils::paths; |
@@ -210,25 +211,31 @@ fn lint_map_unit_fn(cx: &LateContext, stmt: &hir::Stmt, expr: &hir::Expr, map_ar |
210 | 211 | snippet(cx, fn_arg.span, "_")); |
211 | 212 |
|
212 | 213 | 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); |
214 | 218 | }); |
215 | 219 | } else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) { |
216 | 220 | let msg = suggestion_msg("closure", map_type); |
217 | 221 |
|
218 | 222 | span_lint_and_then(cx, lint, expr.span, &msg, |db| { |
219 | 223 | if let Some(reduced_expr_span) = reduce_unit_expression(cx, closure_expr) { |
220 | 224 | 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, "_")); |
225 | 229 | db.span_suggestion(stmt.span, "try this", suggestion); |
226 | 230 | } else { |
227 | 231 | 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); |
232 | 239 | } |
233 | 240 | }); |
234 | 241 | } |
|
0 commit comments