@@ -49,6 +49,8 @@ bitflags! {
49
49
const IS_MANUALLY_DROP = 1 << 6 ;
50
50
/// Indicates whether this struct is `UnsafeCell`.
51
51
const IS_UNSAFE_CELL = 1 << 7 ;
52
+ /// `#[rust_analyzer::do_not_complete(flyimport)]`
53
+ const DO_NOT_COMPLETE_FLYIMPORT = 1 << 7 ;
52
54
}
53
55
}
54
56
@@ -58,6 +60,8 @@ pub struct EnumData {
58
60
pub repr : Option < ReprOptions > ,
59
61
pub visibility : RawVisibility ,
60
62
pub rustc_has_incoherent_inherent_impls : bool ,
63
+ /// `#[rust_analyzer::do_not_complete(flyimport)]`.
64
+ pub do_not_complete_flyimport : bool ,
61
65
}
62
66
63
67
#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -208,6 +212,23 @@ impl StructData {
208
212
}
209
213
}
210
214
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
+
211
232
let strukt = & item_tree[ loc. id . value ] ;
212
233
Arc :: new ( StructData {
213
234
name : strukt. name . clone ( ) ,
@@ -225,13 +246,31 @@ impl StructData {
225
246
let repr = repr_from_value ( db, krate, & item_tree, ModItem :: from ( loc. id . value ) . into ( ) ) ;
226
247
let attrs = item_tree. attrs ( db, krate, ModItem :: from ( loc. id . value ) . into ( ) ) ;
227
248
let mut flags = StructFlags :: NO_FLAGS ;
249
+
228
250
if attrs. by_key ( & sym:: rustc_has_incoherent_inherent_impls) . exists ( ) {
229
251
flags |= StructFlags :: IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPL ;
230
252
}
231
253
if attrs. by_key ( & sym:: fundamental) . exists ( ) {
232
254
flags |= StructFlags :: IS_FUNDAMENTAL ;
233
255
}
234
256
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
+
235
274
let union = & item_tree[ loc. id . value ] ;
236
275
237
276
Arc :: new ( StructData {
@@ -289,10 +328,28 @@ impl EnumData {
289
328
let krate = loc. container . krate ;
290
329
let item_tree = loc. id . item_tree ( db) ;
291
330
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
+ }
296
353
297
354
let enum_ = & item_tree[ loc. id . value ] ;
298
355
@@ -301,6 +358,7 @@ impl EnumData {
301
358
repr,
302
359
visibility : item_tree[ enum_. visibility ] . clone ( ) ,
303
360
rustc_has_incoherent_inherent_impls,
361
+ do_not_complete_flyimport,
304
362
} )
305
363
}
306
364
0 commit comments