|
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}; |
@@ -91,30 +91,30 @@ impl LateLintPass<'_> for IfNotElse { |
91 | 91 | } |
92 | 92 | } |
93 | 93 |
|
94 | | -fn make_sugg<'a>( |
95 | | - sess: &impl HasSession, |
96 | | - cond_kind: &'a ExprKind<'a>, |
| 94 | +fn make_sugg( |
| 95 | + cx: &LateContext<'_>, |
| 96 | + cond_kind: &ExprKind<'_>, |
97 | 97 | cond_inner: Span, |
98 | 98 | els_span: Span, |
99 | | - default: &'a str, |
| 99 | + default: &str, |
100 | 100 | indent_relative_to: Option<Span>, |
101 | 101 | ) -> String { |
102 | | - let cond_inner_snip = snippet(sess, cond_inner, default); |
103 | | - let els_snip = snippet(sess, els_span, default); |
104 | | - let indent = indent_relative_to.and_then(|s| indent_of(sess, s)); |
| 102 | + let cond_inner_snip = snippet(cx, cond_inner, default); |
| 103 | + let els_snip = snippet(cx, els_span, default); |
| 104 | + let indent = indent_relative_to.and_then(|s| indent_of(cx, s)); |
105 | 105 |
|
106 | 106 | let suggestion = match cond_kind { |
107 | 107 | ExprKind::Unary(UnOp::Not, cond_rest) => { |
108 | 108 | format!( |
109 | 109 | "if {} {} else {}", |
110 | | - snippet(sess, cond_rest.span, default), |
| 110 | + snippet(cx, cond_rest.span, default), |
111 | 111 | els_snip, |
112 | 112 | cond_inner_snip |
113 | 113 | ) |
114 | 114 | }, |
115 | 115 | ExprKind::Binary(_, lhs, rhs) => { |
116 | | - let lhs_snip = snippet(sess, lhs.span, default); |
117 | | - let rhs_snip = snippet(sess, rhs.span, default); |
| 116 | + let lhs_snip = snippet(cx, lhs.span, default); |
| 117 | + let rhs_snip = snippet(cx, rhs.span, default); |
118 | 118 |
|
119 | 119 | format!("if {lhs_snip} == {rhs_snip} {els_snip} else {cond_inner_snip}") |
120 | 120 | }, |
|
0 commit comments