File tree Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -618,29 +618,23 @@ fn get_body_search_span(cx: &LateContext<'_>) -> Option<Span> {
618618 let mut maybe_global_var = false ;
619619 for ( _, node) in map. parent_iter ( body. hir_id ) {
620620 match node {
621- Node :: Expr ( e) => {
622- span = e. span ;
623- // Note: setting this to `false` is to making sure a "in-function defined"
624- // const/static variable not mistakenly processed as global variable,
625- // since global var doesn't have an `Expr` parent as its parent???
626- maybe_global_var = false ;
627- }
628- Node :: Block ( _)
629- | Node :: Arm ( _)
630- | Node :: Stmt ( _)
631- | Node :: Local ( _) => ( ) ,
632- Node :: Item ( hir:: Item { kind, span : item_span, .. } ) => {
633- if matches ! ( kind, hir:: ItemKind :: Const ( ..) | ItemKind :: Static ( ..) ) {
634- maybe_global_var = true ;
635- } else if maybe_global_var && let hir:: ItemKind :: Mod ( _) = kind {
636- span = * item_span;
637- } else {
638- break ;
639- }
640- }
621+ Node :: Expr ( e) => span = e. span ,
622+ Node :: Block ( _) | Node :: Arm ( _) | Node :: Stmt ( _) | Node :: Local ( _) => ( ) ,
623+ Node :: Item ( hir:: Item {
624+ kind : hir:: ItemKind :: Const ( ..) | ItemKind :: Static ( ..) ,
625+ ..
626+ } ) => maybe_global_var = true ,
627+ Node :: Item ( hir:: Item {
628+ kind : hir:: ItemKind :: Mod ( _) ,
629+ span : item_span,
630+ ..
631+ } ) => {
632+ span = * item_span;
633+ break ;
634+ } ,
641635 Node :: Crate ( mod_) if maybe_global_var => {
642636 span = mod_. spans . inner_span ;
643- }
637+ } ,
644638 _ => break ,
645639 }
646640 }
You can’t perform that action at this time.
0 commit comments