@@ -24,11 +24,16 @@ use rustc_session::Session;
24
24
use rustc_span:: { Span , Symbol } ;
25
25
use rustc_target:: spec:: abi:: Abi ;
26
26
27
+ /// The search pattern to look for. Used by `span_matches_pat`
27
28
#[ derive( Clone , Copy ) ]
28
29
pub enum Pat {
30
+ /// A single string.
29
31
Str ( & ' static str ) ,
32
+ /// Any of the given strings.
30
33
MultiStr ( & ' static [ & ' static str ] ) ,
34
+ /// The string representation of the symbol.
31
35
Sym ( Symbol ) ,
36
+ /// Any decimal or hexadecimal digit depending on the location.
32
37
Num ,
33
38
}
34
39
@@ -108,9 +113,9 @@ fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
108
113
ExprKind :: Box ( e) => ( Pat :: Str ( "box" ) , expr_search_pat ( tcx, e) . 1 ) ,
109
114
ExprKind :: ConstBlock ( _) => ( Pat :: Str ( "const" ) , Pat :: Str ( "}" ) ) ,
110
115
ExprKind :: Tup ( [ ] ) => ( Pat :: Str ( ")" ) , Pat :: Str ( "(" ) ) ,
111
- ExprKind :: Unary ( UnOp :: Deref , _ ) => ( Pat :: Str ( "*" ) , expr_search_pat ( tcx, e) . 1 ) ,
112
- ExprKind :: Unary ( UnOp :: Not , _ ) => ( Pat :: Str ( "!" ) , expr_search_pat ( tcx, e) . 1 ) ,
113
- ExprKind :: Unary ( UnOp :: Neg , _ ) => ( Pat :: Str ( "-" ) , expr_search_pat ( tcx, e) . 1 ) ,
116
+ ExprKind :: Unary ( UnOp :: Deref , e ) => ( Pat :: Str ( "*" ) , expr_search_pat ( tcx, e) . 1 ) ,
117
+ ExprKind :: Unary ( UnOp :: Not , e ) => ( Pat :: Str ( "!" ) , expr_search_pat ( tcx, e) . 1 ) ,
118
+ ExprKind :: Unary ( UnOp :: Neg , e ) => ( Pat :: Str ( "-" ) , expr_search_pat ( tcx, e) . 1 ) ,
114
119
ExprKind :: Lit ( ref lit) => lit_search_pat ( & lit. node ) ,
115
120
ExprKind :: Array ( _) | ExprKind :: Repeat ( ..) => ( Pat :: Str ( "[" ) , Pat :: Str ( "]" ) ) ,
116
121
ExprKind :: Call ( e, [ ] ) | ExprKind :: MethodCall ( _, [ e] , _) => ( expr_search_pat ( tcx, e) . 0 , Pat :: Str ( "(" ) ) ,
@@ -154,6 +159,7 @@ fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
154
159
ExprKind :: Continue ( Destination { label : None , .. } ) => ( Pat :: Str ( "continue" ) , Pat :: Str ( "continue" ) ) ,
155
160
ExprKind :: Continue ( Destination { label : Some ( name) , .. } ) => ( Pat :: Str ( "continue" ) , Pat :: Sym ( name. ident . name ) ) ,
156
161
ExprKind :: Ret ( None ) => ( Pat :: Str ( "return" ) , Pat :: Str ( "return" ) ) ,
162
+ ExprKind :: Ret ( Some ( e) ) => ( Pat :: Str ( "return" ) , expr_search_pat ( tcx, e) . 1 ) ,
157
163
ExprKind :: Struct ( path, _, _) => ( qpath_search_pat ( path) . 0 , Pat :: Str ( "}" ) ) ,
158
164
ExprKind :: Yield ( e, YieldSource :: Yield ) => ( Pat :: Str ( "yield" ) , expr_search_pat ( tcx, e) . 1 ) ,
159
165
_ => ( Pat :: Str ( "" ) , Pat :: Str ( "" ) ) ,
0 commit comments