@@ -56,39 +56,6 @@ pub enum DescendPreference {
5656 None ,
5757}
5858
59- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
60- pub enum MacroInputKind {
61- Root ,
62- Bang ,
63- AttrInput ,
64- AttrTarget ,
65- Derive ,
66- DeriveHelper ,
67- // Include,
68- }
69- impl MacroInputKind {
70- pub fn is_tt ( self ) -> bool {
71- matches ! (
72- self ,
73- MacroInputKind :: AttrInput
74- | MacroInputKind :: Bang
75- | MacroInputKind :: DeriveHelper
76- | MacroInputKind :: Derive
77- )
78- }
79- }
80-
81- impl ops:: BitOr for MacroInputKind {
82- type Output = Self ;
83-
84- fn bitor ( self , rhs : Self ) -> Self :: Output {
85- match self {
86- Self :: Root => rhs,
87- _ => self ,
88- }
89- }
90- }
91-
9259#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
9360pub enum PathResolution {
9461 /// An item
@@ -586,7 +553,7 @@ impl<'db> SemanticsImpl<'db> {
586553 string : & ast:: String ,
587554 ) -> Option < Vec < ( TextRange , Option < PathResolution > ) > > {
588555 let quote = string. open_quote_text_range ( ) ?;
589- self . descend_into_macros_ng_b ( string. syntax ( ) . clone ( ) , |kind , token| {
556+ self . descend_into_macros_ng_b ( string. syntax ( ) . clone ( ) , |token| {
590557 ( || {
591558 let token = token. value ;
592559 let string = ast:: String :: cast ( token) ?;
@@ -613,7 +580,7 @@ impl<'db> SemanticsImpl<'db> {
613580 ) -> Option < ( TextRange , Option < PathResolution > ) > {
614581 let original_string = ast:: String :: cast ( original_token. clone ( ) ) ?;
615582 let quote = original_string. open_quote_text_range ( ) ?;
616- self . descend_into_macros_ng_b ( original_token. clone ( ) , |kind , token| {
583+ self . descend_into_macros_ng_b ( original_token. clone ( ) , |token| {
617584 ( || {
618585 let token = token. value ;
619586 self . resolve_offset_in_format_args (
@@ -656,7 +623,7 @@ impl<'db> SemanticsImpl<'db> {
656623
657624 if first == last {
658625 // node is just the token, so descend the token
659- self . descend_into_macros_impl ( first, & mut |_kind , InFile { value, .. } | {
626+ self . descend_into_macros_impl ( first, & mut |InFile { value, .. } | {
660627 if let Some ( node) = value
661628 . parent_ancestors ( )
662629 . take_while ( |it| it. text_range ( ) == value. text_range ( ) )
@@ -669,15 +636,15 @@ impl<'db> SemanticsImpl<'db> {
669636 } else {
670637 // Descend first and last token, then zip them to look for the node they belong to
671638 let mut scratch: SmallVec < [ _ ; 1 ] > = smallvec ! [ ] ;
672- self . descend_into_macros_impl ( first, & mut |_kind , token| {
639+ self . descend_into_macros_impl ( first, & mut |token| {
673640 scratch. push ( token) ;
674641 CONTINUE_NO_BREAKS
675642 } ) ;
676643
677644 let mut scratch = scratch. into_iter ( ) ;
678645 self . descend_into_macros_impl (
679646 last,
680- & mut |_kind , InFile { value : last, file_id : last_fid } | {
647+ & mut |InFile { value : last, file_id : last_fid } | {
681648 if let Some ( InFile { value : first, file_id : first_fid } ) = scratch. next ( ) {
682649 if first_fid == last_fid {
683650 if let Some ( p) = first. parent ( ) {
@@ -727,7 +694,7 @@ impl<'db> SemanticsImpl<'db> {
727694 let mut res = smallvec ! [ ] ;
728695 self . descend_into_macros_impl :: < Infallible > (
729696 token. clone ( ) ,
730- & mut |kind , InFile { value, .. } | {
697+ & mut |InFile { value, .. } | {
731698 let is_a_match = match mode {
732699 // Dp::SameText(text) => value.text() == text,
733700 Dp :: SameKind ( preferred_kind) => {
@@ -753,20 +720,20 @@ impl<'db> SemanticsImpl<'db> {
753720 pub fn descend_into_macros_ng (
754721 & self ,
755722 token : SyntaxToken ,
756- mut cb : impl FnMut ( MacroInputKind , InFile < SyntaxToken > ) ,
723+ mut cb : impl FnMut ( InFile < SyntaxToken > ) ,
757724 ) {
758- self . descend_into_macros_impl ( token. clone ( ) , & mut |kind , t| {
759- cb ( kind , t) ;
725+ self . descend_into_macros_impl ( token. clone ( ) , & mut |t| {
726+ cb ( t) ;
760727 CONTINUE_NO_BREAKS
761728 } ) ;
762729 }
763730
764731 pub fn descend_into_macros_ng_b < T > (
765732 & self ,
766733 token : SyntaxToken ,
767- mut cb : impl FnMut ( MacroInputKind , InFile < SyntaxToken > ) -> ControlFlow < T > ,
734+ mut cb : impl FnMut ( InFile < SyntaxToken > ) -> ControlFlow < T > ,
768735 ) -> Option < T > {
769- self . descend_into_macros_impl ( token. clone ( ) , & mut |kind , t| cb ( kind , t) )
736+ self . descend_into_macros_impl ( token. clone ( ) , & mut |t| cb ( t) )
770737 }
771738
772739 /// Descends the token into expansions, returning the tokens that matches the input
@@ -776,7 +743,7 @@ impl<'db> SemanticsImpl<'db> {
776743 let text = token. text ( ) ;
777744 let kind = token. kind ( ) ;
778745
779- self . descend_into_macros_ng ( token. clone ( ) , |m_kind , InFile { value, file_id } | {
746+ self . descend_into_macros_ng ( token. clone ( ) , |InFile { value, file_id : _ } | {
780747 let mapped_kind = value. kind ( ) ;
781748 let any_ident_match = || kind. is_any_identifier ( ) && value. kind ( ) . is_any_identifier ( ) ;
782749 let matches = ( kind == mapped_kind || any_ident_match ( ) ) && text == value. text ( ) ;
@@ -796,7 +763,7 @@ impl<'db> SemanticsImpl<'db> {
796763 let text = token. text ( ) ;
797764 let kind = token. kind ( ) ;
798765
799- self . descend_into_macros_ng_b ( token. clone ( ) , |m_kind , InFile { value, file_id } | {
766+ self . descend_into_macros_ng_b ( token. clone ( ) , |InFile { value, file_id : _ } | {
800767 let mapped_kind = value. kind ( ) ;
801768 let any_ident_match = || kind. is_any_identifier ( ) && value. kind ( ) . is_any_identifier ( ) ;
802769 let matches = ( kind == mapped_kind || any_ident_match ( ) ) && text == value. text ( ) ;
@@ -812,7 +779,7 @@ impl<'db> SemanticsImpl<'db> {
812779 fn descend_into_macros_impl < T > (
813780 & self ,
814781 token : SyntaxToken ,
815- f : & mut dyn FnMut ( MacroInputKind , InFile < SyntaxToken > ) -> ControlFlow < T > ,
782+ f : & mut dyn FnMut ( InFile < SyntaxToken > ) -> ControlFlow < T > ,
816783 ) -> Option < T > {
817784 let _p = tracing:: info_span!( "descend_into_macros_impl" ) . entered ( ) ;
818785 let ( sa, span, file_id) =
@@ -832,11 +799,10 @@ impl<'db> SemanticsImpl<'db> {
832799 // These are tracked to know which macro calls we still have to look into
833800 // the tokens themselves aren't that interesting as the span that is being used to map
834801 // things down never changes.
835- let mut stack: Vec < ( _ , _ , SmallVec < [ _ ; 2 ] > ) > =
836- vec ! [ ( file_id, MacroInputKind :: Root , smallvec![ token] ) ] ;
802+ let mut stack: Vec < ( _ , SmallVec < [ _ ; 2 ] > ) > = vec ! [ ( file_id, smallvec![ token] ) ] ;
837803
838804 // Process the expansion of a call, pushing all tokens with our span in the expansion back onto our stack
839- let process_expansion_for_token = |stack : & mut Vec < _ > , macro_file, remap_kind | {
805+ let process_expansion_for_token = |stack : & mut Vec < _ > , macro_file| {
840806 let InMacroFile { file_id, value : mapped_tokens } = self . with_ctx ( |ctx| {
841807 Some (
842808 ctx. cache
@@ -858,7 +824,7 @@ impl<'db> SemanticsImpl<'db> {
858824 // we have found a mapping for the token if the vec is non-empty
859825 let res = mapped_tokens. is_empty ( ) . not ( ) . then_some ( ( ) ) ;
860826 // requeue the tokens we got from mapping our current token down
861- stack. push ( ( HirFileId :: from ( file_id) , remap_kind , mapped_tokens) ) ;
827+ stack. push ( ( HirFileId :: from ( file_id) , mapped_tokens) ) ;
862828 res
863829 } ;
864830
@@ -868,7 +834,7 @@ impl<'db> SemanticsImpl<'db> {
868834 tokens. retain ( |t : & mut SyntaxToken | !range. contains_range ( t. text_range ( ) ) )
869835 } ;
870836
871- while let Some ( ( expansion, remap_kind , ref mut tokens) ) = stack. pop ( ) {
837+ while let Some ( ( expansion, ref mut tokens) ) = stack. pop ( ) {
872838 while let Some ( token) = tokens. pop ( ) {
873839 let was_not_remapped = ( || {
874840 // First expand into attribute invocations
@@ -909,11 +875,7 @@ impl<'db> SemanticsImpl<'db> {
909875 . unwrap_or_else ( || text_range. start ( ) ) ;
910876 let text_range = TextRange :: new ( start, text_range. end ( ) ) ;
911877 filter_duplicates ( tokens, text_range) ;
912- return process_expansion_for_token (
913- & mut stack,
914- file_id,
915- remap_kind | MacroInputKind :: AttrTarget ,
916- ) ;
878+ return process_expansion_for_token ( & mut stack, file_id) ;
917879 }
918880
919881 // Then check for token trees, that means we are either in a function-like macro or
@@ -952,20 +914,11 @@ impl<'db> SemanticsImpl<'db> {
952914 let text_range = tt. syntax ( ) . text_range ( ) ;
953915 filter_duplicates ( tokens, text_range) ;
954916
955- process_expansion_for_token (
956- & mut stack,
957- file_id,
958- remap_kind | MacroInputKind :: Bang ,
959- )
960- . or ( file_id
917+ process_expansion_for_token ( & mut stack, file_id) . or ( file_id
961918 . eager_arg ( self . db . upcast ( ) )
962919 . and_then ( |arg| {
963920 // also descend into eager expansions
964- process_expansion_for_token (
965- & mut stack,
966- arg. as_macro_file ( ) ,
967- remap_kind | MacroInputKind :: Bang ,
968- )
921+ process_expansion_for_token ( & mut stack, arg. as_macro_file ( ) )
969922 } ) )
970923 }
971924 // derive or derive helper
@@ -997,9 +950,7 @@ impl<'db> SemanticsImpl<'db> {
997950 !text_range. contains_range ( t. text_range ( ) )
998951 } ) ;
999952 return process_expansion_for_token (
1000- & mut stack,
1001- file_id,
1002- remap_kind | MacroInputKind :: Derive ,
953+ & mut stack, file_id,
1003954 ) ;
1004955 }
1005956 None => Some ( adt) ,
@@ -1043,7 +994,6 @@ impl<'db> SemanticsImpl<'db> {
1043994 res = res. or ( process_expansion_for_token (
1044995 & mut stack,
1045996 derive. as_macro_file ( ) ,
1046- remap_kind | MacroInputKind :: DeriveHelper ,
1047997 ) ) ;
1048998 }
1049999 res
@@ -1053,7 +1003,7 @@ impl<'db> SemanticsImpl<'db> {
10531003 . is_none ( ) ;
10541004
10551005 if was_not_remapped {
1056- if let ControlFlow :: Break ( b) = f ( remap_kind , InFile :: new ( expansion, token) ) {
1006+ if let ControlFlow :: Break ( b) = f ( InFile :: new ( expansion, token) ) {
10571007 return Some ( b) ;
10581008 }
10591009 }
0 commit comments