@@ -49,6 +49,8 @@ bitflags! {
4949 const IS_MANUALLY_DROP = 1 << 6 ;
5050 /// Indicates whether this struct is `UnsafeCell`.
5151 const IS_UNSAFE_CELL = 1 << 7 ;
52+ /// `#[rust_analyzer::do_not_complete(flyimport)]`
53+ const DO_NOT_COMPLETE_FLYIMPORT = 1 << 7 ;
5254 }
5355}
5456
@@ -58,6 +60,8 @@ pub struct EnumData {
5860 pub repr : Option < ReprOptions > ,
5961 pub visibility : RawVisibility ,
6062 pub rustc_has_incoherent_inherent_impls : bool ,
63+ /// `#[rust_analyzer::do_not_complete(flyimport)]`.
64+ pub do_not_complete_flyimport : bool ,
6165}
6266
6367#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -208,6 +212,23 @@ impl StructData {
208212 }
209213 }
210214
215+ for ra_attr in attrs. rust_analyzer_tool ( ) {
216+ let segments = ra_attr. path . segments ( ) ;
217+ if segments. len ( ) != 2 {
218+ continue ;
219+ }
220+ let action = segments[ 1 ] . symbol ( ) ;
221+ if * action == sym:: do_not_complete {
222+ if let Some ( [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] ) =
223+ ra_attr. token_tree_value ( ) . map ( |tt| tt. token_trees ( ) . flat_tokens ( ) )
224+ {
225+ if ident. sym == sym:: flyimport {
226+ flags |= StructFlags :: DO_NOT_COMPLETE_FLYIMPORT ;
227+ }
228+ }
229+ }
230+ }
231+
211232 let strukt = & item_tree[ loc. id . value ] ;
212233 Arc :: new ( StructData {
213234 name : strukt. name . clone ( ) ,
@@ -225,13 +246,31 @@ impl StructData {
225246 let repr = repr_from_value ( db, krate, & item_tree, ModItem :: from ( loc. id . value ) . into ( ) ) ;
226247 let attrs = item_tree. attrs ( db, krate, ModItem :: from ( loc. id . value ) . into ( ) ) ;
227248 let mut flags = StructFlags :: NO_FLAGS ;
249+
228250 if attrs. by_key ( & sym:: rustc_has_incoherent_inherent_impls) . exists ( ) {
229251 flags |= StructFlags :: IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPL ;
230252 }
231253 if attrs. by_key ( & sym:: fundamental) . exists ( ) {
232254 flags |= StructFlags :: IS_FUNDAMENTAL ;
233255 }
234256
257+ for ra_attr in attrs. rust_analyzer_tool ( ) {
258+ let segments = ra_attr. path . segments ( ) ;
259+ if segments. len ( ) != 2 {
260+ continue ;
261+ }
262+ let action = segments[ 1 ] . symbol ( ) ;
263+ if * action == sym:: do_not_complete {
264+ if let Some ( [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] ) =
265+ ra_attr. token_tree_value ( ) . map ( |tt| tt. token_trees ( ) . flat_tokens ( ) )
266+ {
267+ if ident. sym == sym:: flyimport {
268+ flags |= StructFlags :: DO_NOT_COMPLETE_FLYIMPORT ;
269+ }
270+ }
271+ }
272+ }
273+
235274 let union = & item_tree[ loc. id . value ] ;
236275
237276 Arc :: new ( StructData {
@@ -289,10 +328,28 @@ impl EnumData {
289328 let krate = loc. container . krate ;
290329 let item_tree = loc. id . item_tree ( db) ;
291330 let repr = repr_from_value ( db, krate, & item_tree, ModItem :: from ( loc. id . value ) . into ( ) ) ;
292- let rustc_has_incoherent_inherent_impls = item_tree
293- . attrs ( db, loc. container . krate , ModItem :: from ( loc. id . value ) . into ( ) )
294- . by_key ( & sym:: rustc_has_incoherent_inherent_impls)
295- . exists ( ) ;
331+ let attrs = item_tree. attrs ( db, loc. container . krate , ModItem :: from ( loc. id . value ) . into ( ) ) ;
332+
333+ let rustc_has_incoherent_inherent_impls =
334+ attrs. by_key ( & sym:: rustc_has_incoherent_inherent_impls) . exists ( ) ;
335+
336+ let mut do_not_complete_flyimport = false ;
337+ for ra_attr in attrs. rust_analyzer_tool ( ) {
338+ let segments = ra_attr. path . segments ( ) ;
339+ if segments. len ( ) != 2 {
340+ continue ;
341+ }
342+ let action = segments[ 1 ] . symbol ( ) ;
343+ if * action == sym:: do_not_complete {
344+ if let Some ( [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] ) =
345+ ra_attr. token_tree_value ( ) . map ( |tt| tt. token_trees ( ) . flat_tokens ( ) )
346+ {
347+ if ident. sym == sym:: flyimport {
348+ do_not_complete_flyimport = true ;
349+ }
350+ }
351+ }
352+ }
296353
297354 let enum_ = & item_tree[ loc. id . value ] ;
298355
@@ -301,6 +358,7 @@ impl EnumData {
301358 repr,
302359 visibility : item_tree[ enum_. visibility ] . clone ( ) ,
303360 rustc_has_incoherent_inherent_impls,
361+ do_not_complete_flyimport,
304362 } )
305363 }
306364
0 commit comments