@@ -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 } )
@@ -336,10 +336,18 @@ fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) {
336336 // TODO: I feel like it's likely we can use `Cow` instead but this will require quite a bit of
337337 // refactoring
338338 // NOTE: This will likely have false positives, like `allow = 1`
339- (
340- Pat :: OwnedMultiStr ( vec ! [ ident. to_string( ) , "#" . to_owned( ) ] ) ,
341- Pat :: Str ( "" ) ,
342- )
339+ let ident_string = ident. to_string ( ) ;
340+ if matches ! ( attr. style, AttrStyle :: Outer ) {
341+ (
342+ Pat :: OwnedMultiStr ( vec ! [ "#[" . to_owned( ) + & ident_string, ident_string] ) ,
343+ Pat :: Str ( "" ) ,
344+ )
345+ } else {
346+ (
347+ Pat :: OwnedMultiStr ( vec ! [ "#![" . to_owned( ) + & ident_string, ident_string] ) ,
348+ Pat :: Str ( "" ) ,
349+ )
350+ }
343351 } else {
344352 ( Pat :: Str ( "#" ) , Pat :: Str ( "]" ) )
345353 }
0 commit comments