|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_sugg; |
2 | 2 | use clippy_utils::source::snippet_with_applicability; |
3 | 3 | use rustc_errors::Applicability; |
4 | | -use rustc_hir::*; |
| 4 | +use rustc_hir::{Expr, ExprKind, LangItem, Mutability, QPath}; |
5 | 5 | use rustc_lint::{LateContext, LateLintPass}; |
6 | 6 | use rustc_session::declare_lint_pass; |
7 | 7 |
|
@@ -38,29 +38,30 @@ impl LateLintPass<'_> for AsSliceInsteadOfReferenceFullRange { |
38 | 38 | && let ExprKind::Struct(qpath, _, _) = indexing.kind |
39 | 39 | && let QPath::LangItem(LangItem::RangeFull, _) = qpath |
40 | 40 | { |
41 | | - let snippet = snippet_with_applicability(cx, name.span, "..", &mut Applicability::Unspecified); |
| 41 | + let mut app = Applicability::MachineApplicable; |
| 42 | + let snippet = snippet_with_applicability(cx, name.span, "..", &mut app); |
42 | 43 |
|
43 | 44 | match mutability { |
44 | 45 | Mutability::Not => { |
45 | 46 | span_lint_and_sugg( |
46 | 47 | cx, |
47 | 48 | AS_SLICE_INSTEAD_OF_REFERENCE_FULL_RANGE, |
48 | 49 | expr.span, |
49 | | - format!("Use `.as_slice()` instead of full range slice"), |
| 50 | + "Use `.as_slice()` instead of full range slice", |
50 | 51 | "try", |
51 | 52 | format!("{snippet}.as_slice()"), |
52 | | - Applicability::Unspecified, |
| 53 | + app, |
53 | 54 | ); |
54 | 55 | }, |
55 | 56 | Mutability::Mut => { |
56 | 57 | span_lint_and_sugg( |
57 | 58 | cx, |
58 | 59 | AS_SLICE_INSTEAD_OF_REFERENCE_FULL_RANGE, |
59 | 60 | expr.span, |
60 | | - format!("Use `.as_mut_slice()` instead of full range slice"), |
| 61 | + "Use `.as_mut_slice()` instead of full range slice", |
61 | 62 | "try", |
62 | 63 | format!("{snippet}.as_mut_slice()"), |
63 | | - Applicability::Unspecified, |
| 64 | + app, |
64 | 65 | ); |
65 | 66 | }, |
66 | 67 | } |
|
0 commit comments