@@ -11,7 +11,6 @@ use rustc_middle::lint::in_external_macro;
1111use rustc_semver:: RustcVersion ;
1212use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
1313use rustc_span:: symbol:: sym;
14- use rustc_span:: Span ;
1514use std:: ops:: ControlFlow ;
1615
1716declare_clippy_lint ! {
@@ -66,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualLetElse {
6665 if !in_external_macro( cx. sess( ) , stmt. span) ;
6766 if let StmtKind :: Local ( local) = stmt. kind;
6867 if let Some ( init) = local. init;
69- if !from_different_macros ( init. span, stmt. span) ;
68+ if init. span. ctxt ( ) == stmt. span. ctxt ( ) ;
7069 if let Some ( if_let_or_match) = IfLetOrMatch :: parse( cx, init) ;
7170 then {
7271 if_let_or_match
@@ -184,23 +183,6 @@ fn expr_diverges(cx: &LateContext<'_>, expr: &'_ Expr<'_>) -> bool {
184183 does_diverge
185184}
186185
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-
204186fn pat_allowed_for_else ( cx : & LateContext < ' _ > , pat : & ' _ Pat < ' _ > ) -> bool {
205187 // Check whether the pattern contains any bindings, as the
206188 // binding might potentially be used in the body.
0 commit comments