@@ -35,6 +35,7 @@ pub struct FunctionData {
3535 pub visibility : RawVisibility ,
3636 pub abi : Option < Interned < str > > ,
3737 pub legacy_const_generics_indices : Box < [ u32 ] > ,
38+ pub rustc_allow_incoherent_impl : bool ,
3839 flags : FnFlags ,
3940}
4041
@@ -84,13 +85,14 @@ impl FunctionData {
8485 }
8586 }
8687
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
8990 . by_key ( "rustc_legacy_const_generics" )
9091 . tt_values ( )
9192 . next ( )
9293 . map ( parse_rustc_legacy_const_generics)
9394 . unwrap_or_default ( ) ;
95+ let rustc_allow_incoherent_impl = attrs. by_key ( "rustc_allow_incoherent_impl" ) . exists ( ) ;
9496
9597 Arc :: new ( FunctionData {
9698 name : func. name . clone ( ) ,
@@ -108,6 +110,7 @@ impl FunctionData {
108110 abi : func. abi . clone ( ) ,
109111 legacy_const_generics_indices,
110112 flags,
113+ rustc_allow_incoherent_impl,
111114 } )
112115 }
113116
@@ -171,6 +174,7 @@ pub struct TypeAliasData {
171174 pub visibility : RawVisibility ,
172175 pub is_extern : bool ,
173176 pub rustc_has_incoherent_inherent_impls : bool ,
177+ pub rustc_allow_incoherent_impl : bool ,
174178 /// Bounds restricting the type alias itself (eg. `type Ty: Bound;` in a trait or impl).
175179 pub bounds : Vec < Interned < TypeBound > > ,
176180}
@@ -189,17 +193,22 @@ impl TypeAliasData {
189193 item_tree[ typ. visibility ] . clone ( )
190194 } ;
191195
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 ( ) ;
196204
197205 Arc :: new ( TypeAliasData {
198206 name : typ. name . clone ( ) ,
199207 type_ref : typ. type_ref . clone ( ) ,
200208 visibility,
201209 is_extern : matches ! ( loc. container, ItemContainerId :: ExternBlockId ( _) ) ,
202210 rustc_has_incoherent_inherent_impls,
211+ rustc_allow_incoherent_impl,
203212 bounds : typ. bounds . to_vec ( ) ,
204213 } )
205214 }
@@ -212,11 +221,12 @@ pub struct TraitData {
212221 pub is_auto : bool ,
213222 pub is_unsafe : bool ,
214223 pub rustc_has_incoherent_inherent_impls : bool ,
224+ pub skip_array_during_method_dispatch : bool ,
225+ pub fundamental : bool ,
215226 pub visibility : RawVisibility ,
216227 /// Whether the trait has `#[rust_skip_array_during_method_dispatch]`. `hir_ty` will ignore
217228 /// method calls to this trait's methods when the receiver is an array and the crate edition is
218229 /// 2015 or 2018.
219- pub skip_array_during_method_dispatch : bool ,
220230 // box it as the vec is usually empty anyways
221231 pub attribute_calls : Option < Box < Vec < ( AstId < ast:: Item > , MacroCallId ) > > > ,
222232}
@@ -245,6 +255,7 @@ impl TraitData {
245255 attrs. by_key ( "rustc_skip_array_during_method_dispatch" ) . exists ( ) ;
246256 let rustc_has_incoherent_inherent_impls =
247257 attrs. by_key ( "rustc_has_incoherent_inherent_impls" ) . exists ( ) ;
258+ let fundamental = attrs. by_key ( "fundamental" ) . exists ( ) ;
248259 let mut collector =
249260 AssocItemCollector :: new ( db, module_id, tree_id. file_id ( ) , ItemContainerId :: TraitId ( tr) ) ;
250261 collector. collect ( & item_tree, tree_id. tree_id ( ) , & tr_def. items ) ;
@@ -260,6 +271,7 @@ impl TraitData {
260271 visibility,
261272 skip_array_during_method_dispatch,
262273 rustc_has_incoherent_inherent_impls,
274+ fundamental,
263275 } ) ,
264276 diagnostics. into ( ) ,
265277 )
@@ -450,6 +462,7 @@ pub struct ConstData {
450462 pub name : Option < Name > ,
451463 pub type_ref : Interned < TypeRef > ,
452464 pub visibility : RawVisibility ,
465+ pub rustc_allow_incoherent_impl : bool ,
453466}
454467
455468impl ConstData {
@@ -463,10 +476,16 @@ impl ConstData {
463476 item_tree[ konst. visibility ] . clone ( )
464477 } ;
465478
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+
466484 Arc :: new ( ConstData {
467485 name : konst. name . clone ( ) ,
468486 type_ref : konst. type_ref . clone ( ) ,
469487 visibility,
488+ rustc_allow_incoherent_impl,
470489 } )
471490 }
472491}
0 commit comments