@@ -35,6 +35,7 @@ pub struct FunctionData {
35
35
pub visibility : RawVisibility ,
36
36
pub abi : Option < Interned < str > > ,
37
37
pub legacy_const_generics_indices : Box < [ u32 ] > ,
38
+ pub rustc_allow_incoherent_impl : bool ,
38
39
flags : FnFlags ,
39
40
}
40
41
@@ -84,13 +85,14 @@ impl FunctionData {
84
85
}
85
86
}
86
87
87
- let legacy_const_generics_indices = item_tree
88
- . attrs ( db , krate , ModItem :: from ( loc . id . value ) . into ( ) )
88
+ let attrs = item_tree. attrs ( db , krate , ModItem :: from ( loc . id . value ) . into ( ) ) ;
89
+ let legacy_const_generics_indices = attrs
89
90
. by_key ( "rustc_legacy_const_generics" )
90
91
. tt_values ( )
91
92
. next ( )
92
93
. map ( parse_rustc_legacy_const_generics)
93
94
. unwrap_or_default ( ) ;
95
+ let rustc_allow_incoherent_impl = attrs. by_key ( "rustc_allow_incoherent_impl" ) . exists ( ) ;
94
96
95
97
Arc :: new ( FunctionData {
96
98
name : func. name . clone ( ) ,
@@ -108,6 +110,7 @@ impl FunctionData {
108
110
abi : func. abi . clone ( ) ,
109
111
legacy_const_generics_indices,
110
112
flags,
113
+ rustc_allow_incoherent_impl,
111
114
} )
112
115
}
113
116
@@ -171,6 +174,7 @@ pub struct TypeAliasData {
171
174
pub visibility : RawVisibility ,
172
175
pub is_extern : bool ,
173
176
pub rustc_has_incoherent_inherent_impls : bool ,
177
+ pub rustc_allow_incoherent_impl : bool ,
174
178
/// Bounds restricting the type alias itself (eg. `type Ty: Bound;` in a trait or impl).
175
179
pub bounds : Vec < Interned < TypeBound > > ,
176
180
}
@@ -189,17 +193,22 @@ impl TypeAliasData {
189
193
item_tree[ typ. visibility ] . clone ( )
190
194
} ;
191
195
192
- let rustc_has_incoherent_inherent_impls = item_tree
193
- . attrs ( db, loc. container . module ( db) . krate ( ) , ModItem :: from ( loc. id . value ) . into ( ) )
194
- . by_key ( "rustc_has_incoherent_inherent_impls" )
195
- . exists ( ) ;
196
+ let attrs = item_tree. attrs (
197
+ db,
198
+ loc. container . module ( db) . krate ( ) ,
199
+ ModItem :: from ( loc. id . value ) . into ( ) ,
200
+ ) ;
201
+ let rustc_has_incoherent_inherent_impls =
202
+ attrs. by_key ( "rustc_has_incoherent_inherent_impls" ) . exists ( ) ;
203
+ let rustc_allow_incoherent_impl = attrs. by_key ( "rustc_allow_incoherent_impl" ) . exists ( ) ;
196
204
197
205
Arc :: new ( TypeAliasData {
198
206
name : typ. name . clone ( ) ,
199
207
type_ref : typ. type_ref . clone ( ) ,
200
208
visibility,
201
209
is_extern : matches ! ( loc. container, ItemContainerId :: ExternBlockId ( _) ) ,
202
210
rustc_has_incoherent_inherent_impls,
211
+ rustc_allow_incoherent_impl,
203
212
bounds : typ. bounds . to_vec ( ) ,
204
213
} )
205
214
}
@@ -212,11 +221,12 @@ pub struct TraitData {
212
221
pub is_auto : bool ,
213
222
pub is_unsafe : bool ,
214
223
pub rustc_has_incoherent_inherent_impls : bool ,
224
+ pub skip_array_during_method_dispatch : bool ,
225
+ pub fundamental : bool ,
215
226
pub visibility : RawVisibility ,
216
227
/// Whether the trait has `#[rust_skip_array_during_method_dispatch]`. `hir_ty` will ignore
217
228
/// method calls to this trait's methods when the receiver is an array and the crate edition is
218
229
/// 2015 or 2018.
219
- pub skip_array_during_method_dispatch : bool ,
220
230
// box it as the vec is usually empty anyways
221
231
pub attribute_calls : Option < Box < Vec < ( AstId < ast:: Item > , MacroCallId ) > > > ,
222
232
}
@@ -245,6 +255,7 @@ impl TraitData {
245
255
attrs. by_key ( "rustc_skip_array_during_method_dispatch" ) . exists ( ) ;
246
256
let rustc_has_incoherent_inherent_impls =
247
257
attrs. by_key ( "rustc_has_incoherent_inherent_impls" ) . exists ( ) ;
258
+ let fundamental = attrs. by_key ( "fundamental" ) . exists ( ) ;
248
259
let mut collector =
249
260
AssocItemCollector :: new ( db, module_id, tree_id. file_id ( ) , ItemContainerId :: TraitId ( tr) ) ;
250
261
collector. collect ( & item_tree, tree_id. tree_id ( ) , & tr_def. items ) ;
@@ -260,6 +271,7 @@ impl TraitData {
260
271
visibility,
261
272
skip_array_during_method_dispatch,
262
273
rustc_has_incoherent_inherent_impls,
274
+ fundamental,
263
275
} ) ,
264
276
diagnostics. into ( ) ,
265
277
)
@@ -450,6 +462,7 @@ pub struct ConstData {
450
462
pub name : Option < Name > ,
451
463
pub type_ref : Interned < TypeRef > ,
452
464
pub visibility : RawVisibility ,
465
+ pub rustc_allow_incoherent_impl : bool ,
453
466
}
454
467
455
468
impl ConstData {
@@ -463,10 +476,16 @@ impl ConstData {
463
476
item_tree[ konst. visibility ] . clone ( )
464
477
} ;
465
478
479
+ let rustc_allow_incoherent_impl = item_tree
480
+ . attrs ( db, loc. container . module ( db) . krate ( ) , ModItem :: from ( loc. id . value ) . into ( ) )
481
+ . by_key ( "rustc_allow_incoherent_impl" )
482
+ . exists ( ) ;
483
+
466
484
Arc :: new ( ConstData {
467
485
name : konst. name . clone ( ) ,
468
486
type_ref : konst. type_ref . clone ( ) ,
469
487
visibility,
488
+ rustc_allow_incoherent_impl,
470
489
} )
471
490
}
472
491
}
0 commit comments