@@ -63,8 +63,8 @@ fn span_matches_pat(sess: &Session, span: Span, start_pat: Pat, end_pat: Pat) ->
6363 Pat :: Num => start_str. as_bytes ( ) . first ( ) . map_or ( false , u8:: is_ascii_digit) ,
6464 } && match end_pat {
6565 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) ) ,
6868 Pat :: Sym ( sym) => end_str. ends_with ( sym. as_str ( ) ) ,
6969 Pat :: Num => end_str. as_bytes ( ) . last ( ) . map_or ( false , u8:: is_ascii_hexdigit) ,
7070 } )
@@ -333,26 +333,32 @@ fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) {
333333 match attr. kind {
334334 AttrKind :: Normal ( ..) => {
335335 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
338336 // 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+ }
343349 } else {
344350 ( Pat :: Str ( "#" ) , Pat :: Str ( "]" ) )
345351 }
346352 } ,
347353 AttrKind :: DocComment ( _kind @ CommentKind :: Line , ..) => {
348- if matches ! ( attr. style, AttrStyle :: Outer ) {
354+ if attr. style == AttrStyle :: Outer {
349355 ( Pat :: Str ( "///" ) , Pat :: Str ( "" ) )
350356 } else {
351357 ( Pat :: Str ( "//!" ) , Pat :: Str ( "" ) )
352358 }
353359 } ,
354360 AttrKind :: DocComment ( _kind @ CommentKind :: Block , ..) => {
355- if matches ! ( attr. style, AttrStyle :: Outer ) {
361+ if attr. style == AttrStyle :: Outer {
356362 ( Pat :: Str ( "/**" ) , Pat :: Str ( "*/" ) )
357363 } else {
358364 ( Pat :: Str ( "/*!" ) , Pat :: Str ( "*/" ) )
0 commit comments