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