|
1 | 1 | use clippy_utils::consts::is_zero_integer_const; |
2 | 2 | use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; |
3 | 3 | use clippy_utils::is_else_clause; |
4 | | -use clippy_utils::source::{HasSession, indent_of, reindent_multiline, snippet}; |
| 4 | +use clippy_utils::source::{indent_of, reindent_multiline, snippet}; |
5 | 5 | use rustc_errors::Applicability; |
6 | 6 | use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; |
7 | 7 | use rustc_lint::{LateContext, LateLintPass}; |
@@ -92,30 +92,30 @@ impl LateLintPass<'_> for IfNotElse { |
92 | 92 | } |
93 | 93 | } |
94 | 94 |
|
95 | | -fn make_sugg<'a>( |
96 | | - sess: &impl HasSession, |
97 | | - cond_kind: &'a ExprKind<'a>, |
| 95 | +fn make_sugg( |
| 96 | + cx: &LateContext<'_>, |
| 97 | + cond_kind: &ExprKind<'_>, |
98 | 98 | cond_inner: Span, |
99 | 99 | els_span: Span, |
100 | | - default: &'a str, |
| 100 | + default: &str, |
101 | 101 | indent_relative_to: Option<Span>, |
102 | 102 | ) -> String { |
103 | | - let cond_inner_snip = snippet(sess, cond_inner, default); |
104 | | - let els_snip = snippet(sess, els_span, default); |
105 | | - let indent = indent_relative_to.and_then(|s| indent_of(sess, s)); |
| 103 | + let cond_inner_snip = snippet(cx, cond_inner, default); |
| 104 | + let els_snip = snippet(cx, els_span, default); |
| 105 | + let indent = indent_relative_to.and_then(|s| indent_of(cx, s)); |
106 | 106 |
|
107 | 107 | let suggestion = match cond_kind { |
108 | 108 | ExprKind::Unary(UnOp::Not, cond_rest) => { |
109 | 109 | format!( |
110 | 110 | "if {} {} else {}", |
111 | | - snippet(sess, cond_rest.span, default), |
| 111 | + snippet(cx, cond_rest.span, default), |
112 | 112 | els_snip, |
113 | 113 | cond_inner_snip |
114 | 114 | ) |
115 | 115 | }, |
116 | 116 | ExprKind::Binary(_, lhs, rhs) => { |
117 | | - let lhs_snip = snippet(sess, lhs.span, default); |
118 | | - let rhs_snip = snippet(sess, rhs.span, default); |
| 117 | + let lhs_snip = snippet(cx, lhs.span, default); |
| 118 | + let rhs_snip = snippet(cx, rhs.span, default); |
119 | 119 |
|
120 | 120 | format!("if {lhs_snip} == {rhs_snip} {els_snip} else {cond_inner_snip}") |
121 | 121 | }, |
|
0 commit comments