@@ -63,8 +63,8 @@ fn span_matches_pat(sess: &Session, span: Span, start_pat: Pat, end_pat: Pat) ->
63
63
Pat :: Num => start_str. as_bytes ( ) . first ( ) . map_or ( false , u8:: is_ascii_digit) ,
64
64
} && match end_pat {
65
65
Pat :: Str ( text) => end_str. ends_with ( text) ,
66
- Pat :: MultiStr ( texts) => texts. iter ( ) . any ( |s| start_str . ends_with ( s) ) ,
67
- Pat :: OwnedMultiStr ( texts) => texts. iter ( ) . any ( |s| start_str . starts_with ( s) ) ,
66
+ Pat :: MultiStr ( texts) => texts. iter ( ) . any ( |s| end_str . ends_with ( s) ) ,
67
+ Pat :: OwnedMultiStr ( texts) => texts. iter ( ) . any ( |s| end_str . ends_with ( s) ) ,
68
68
Pat :: Sym ( sym) => end_str. ends_with ( sym. as_str ( ) ) ,
69
69
Pat :: Num => end_str. as_bytes ( ) . last ( ) . map_or ( false , u8:: is_ascii_hexdigit) ,
70
70
} )
@@ -333,26 +333,32 @@ fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) {
333
333
match attr. kind {
334
334
AttrKind :: Normal ( ..) => {
335
335
if let Some ( ident) = attr. ident ( ) {
336
- // TODO: I feel like it's likely we can use `Cow` instead but this will require quite a bit of
337
- // refactoring
338
336
// NOTE: This will likely have false positives, like `allow = 1`
339
- (
340
- Pat :: OwnedMultiStr ( vec ! [ ident. to_string( ) , "#" . to_owned( ) ] ) ,
341
- Pat :: Str ( "" ) ,
342
- )
337
+ let ident_string = ident. to_string ( ) ;
338
+ if attr. style == AttrStyle :: Outer {
339
+ (
340
+ Pat :: OwnedMultiStr ( vec ! [ "#[" . to_owned( ) + & ident_string, ident_string] ) ,
341
+ Pat :: Str ( "" ) ,
342
+ )
343
+ } else {
344
+ (
345
+ Pat :: OwnedMultiStr ( vec ! [ "#![" . to_owned( ) + & ident_string, ident_string] ) ,
346
+ Pat :: Str ( "" ) ,
347
+ )
348
+ }
343
349
} else {
344
350
( Pat :: Str ( "#" ) , Pat :: Str ( "]" ) )
345
351
}
346
352
} ,
347
353
AttrKind :: DocComment ( _kind @ CommentKind :: Line , ..) => {
348
- if matches ! ( attr. style, AttrStyle :: Outer ) {
354
+ if attr. style == AttrStyle :: Outer {
349
355
( Pat :: Str ( "///" ) , Pat :: Str ( "" ) )
350
356
} else {
351
357
( Pat :: Str ( "//!" ) , Pat :: Str ( "" ) )
352
358
}
353
359
} ,
354
360
AttrKind :: DocComment ( _kind @ CommentKind :: Block , ..) => {
355
- if matches ! ( attr. style, AttrStyle :: Outer ) {
361
+ if attr. style == AttrStyle :: Outer {
356
362
( Pat :: Str ( "/**" ) , Pat :: Str ( "*/" ) )
357
363
} else {
358
364
( Pat :: Str ( "/*!" ) , Pat :: Str ( "*/" ) )
0 commit comments