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