@@ -11,7 +11,6 @@ use rustc_middle::lint::in_external_macro;
11
11
use rustc_semver:: RustcVersion ;
12
12
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
13
13
use rustc_span:: symbol:: sym;
14
- use rustc_span:: Span ;
15
14
use std:: ops:: ControlFlow ;
16
15
17
16
declare_clippy_lint ! {
@@ -66,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualLetElse {
66
65
if !in_external_macro( cx. sess( ) , stmt. span) ;
67
66
if let StmtKind :: Local ( local) = stmt. kind;
68
67
if let Some ( init) = local. init;
69
- if !from_different_macros ( init. span, stmt. span) ;
68
+ if init. span. ctxt ( ) == stmt. span. ctxt ( ) ;
70
69
if let Some ( if_let_or_match) = IfLetOrMatch :: parse( cx, init) ;
71
70
then {
72
71
if_let_or_match
@@ -184,23 +183,6 @@ fn expr_diverges(cx: &LateContext<'_>, expr: &'_ Expr<'_>) -> bool {
184
183
does_diverge
185
184
}
186
185
187
- /// Returns true if the two spans come from different macro sites,
188
- /// or one comes from an invocation and the other is not from a macro at all.
189
- fn from_different_macros ( span_a : Span , span_b : Span ) -> bool {
190
- // This pre-check is a speed up so that we don't build outer_expn_data unless needed.
191
- match ( span_a. from_expansion ( ) , span_b. from_expansion ( ) ) {
192
- ( false , false ) => return false ,
193
- ( true , false ) | ( false , true ) => return true ,
194
- // We need to determine if both are from the same macro
195
- ( true , true ) => ( ) ,
196
- }
197
- let data_for_comparison = |sp : Span | {
198
- let expn_data = sp. ctxt ( ) . outer_expn_data ( ) ;
199
- ( expn_data. kind , expn_data. call_site )
200
- } ;
201
- data_for_comparison ( span_a) != data_for_comparison ( span_b)
202
- }
203
-
204
186
fn pat_allowed_for_else ( cx : & LateContext < ' _ > , pat : & ' _ Pat < ' _ > ) -> bool {
205
187
// Check whether the pattern contains any bindings, as the
206
188
// binding might potentially be used in the body.
0 commit comments