File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ fn is_va_args_type(ty: &ast::Type) -> bool {
5454 false
5555}
5656
57- fn cfg_matches_host ( fn_item : & ast:: Fn ) -> bool {
58- for attr in fn_item . attrs ( ) {
57+ fn cfg_matches_host ( attrs : impl Iterator < Item = ast:: Attr > ) -> bool {
58+ for attr in attrs {
5959 let Some ( meta) = attr. meta ( ) else { continue } ;
6060 let Some ( path) = meta. path ( ) else { continue } ;
6161 if path. syntax ( ) . text ( ) != "cfg" {
@@ -135,7 +135,7 @@ impl SyntacticAnalysis {
135135 let mut file_ir = FileIr :: new ( ) ;
136136
137137 for fn_item in source_file. syntax ( ) . descendants ( ) . filter_map ( ast:: Fn :: cast) {
138- if !cfg_matches_host ( & fn_item) {
138+ if !cfg_matches_host ( fn_item. attrs ( ) ) {
139139 continue ;
140140 }
141141
@@ -202,6 +202,16 @@ impl<'a> FragmentCtx<'a> {
202202 match child {
203203 ra_ap_syntax:: NodeOrToken :: Token ( token) => self . visit_token ( & token) ,
204204 ra_ap_syntax:: NodeOrToken :: Node ( node) => {
205+ if ast:: Attr :: can_cast ( node. kind ( ) ) {
206+ self . text_buf . push_str ( & node. text ( ) . to_string ( ) ) ;
207+ return ;
208+ }
209+ if let Some ( has_attrs) = ast:: AnyHasAttrs :: cast ( node. clone ( ) )
210+ && !cfg_matches_host ( has_attrs. attrs ( ) )
211+ {
212+ self . text_buf . push_str ( & node. text ( ) . to_string ( ) ) ;
213+ return ;
214+ }
205215 if let Some ( call) = ast:: MethodCallExpr :: cast ( node. clone ( ) ) {
206216 self . emit_method_call ( & call) ;
207217 return ;
You can’t perform that action at this time.
0 commit comments