@@ -6,7 +6,10 @@ use hir_expand::{InFile, Lookup, name::Name};
6
6
use intern:: { Symbol , sym} ;
7
7
use la_arena:: { Arena , Idx } ;
8
8
use rustc_abi:: { IntegerType , ReprOptions } ;
9
- use syntax:: ast:: { self , HasGenericParams , IsString } ;
9
+ use syntax:: {
10
+ AstNode , SyntaxNodePtr ,
11
+ ast:: { self , HasGenericParams , IsString } ,
12
+ } ;
10
13
use triomphe:: Arc ;
11
14
12
15
use crate :: {
@@ -23,10 +26,9 @@ use crate::{
23
26
hir:: { ExprId , PatId , generics:: GenericParams } ,
24
27
item_tree:: {
25
28
AttrOwner , Field , FieldParent , FieldsShape , ItemTree , ModItem , RawVisibility ,
26
- RawVisibilityId , TreeId ,
29
+ RawVisibilityId ,
27
30
} ,
28
31
lang_item:: LangItem ,
29
- nameres:: diagnostics:: DefDiagnostic ,
30
32
src:: HasSource ,
31
33
type_ref:: { TraitRef , TypeBound , TypeRef , TypeRefId } ,
32
34
} ;
@@ -732,8 +734,7 @@ impl VariantFields {
732
734
db : & dyn DefDatabase ,
733
735
id : VariantId ,
734
736
) -> ( Arc < Self > , Arc < ExpressionStoreSourceMap > ) {
735
- // FIXME: Report def diagnostics
736
- let ( shape, ( fields, store, source_map, _diagnostics) ) = match id {
737
+ let ( shape, ( fields, store, source_map) ) = match id {
737
738
VariantId :: EnumVariantId ( id) => {
738
739
let loc = id. lookup ( db) ;
739
740
let item_tree = loc. id . item_tree ( db) ;
@@ -744,7 +745,6 @@ impl VariantFields {
744
745
lower_fields (
745
746
db,
746
747
parent. container ,
747
- loc. id . tree_id ( ) ,
748
748
& item_tree,
749
749
FieldParent :: EnumVariant ( loc. id . value ) ,
750
750
loc. source ( db) . map ( |src| {
@@ -753,12 +753,14 @@ impl VariantFields {
753
753
. map ( |it| {
754
754
match it {
755
755
ast:: FieldList :: RecordFieldList ( record_field_list) => {
756
- Either :: Left (
757
- record_field_list . fields ( ) . map ( |it| it. ty ( ) ) ,
758
- )
756
+ Either :: Left ( record_field_list . fields ( ) . map ( |it| {
757
+ ( SyntaxNodePtr :: new ( it . syntax ( ) ) , it. ty ( ) )
758
+ } ) )
759
759
}
760
760
ast:: FieldList :: TupleFieldList ( field_list) => {
761
- Either :: Right ( field_list. fields ( ) . map ( |it| it. ty ( ) ) )
761
+ Either :: Right ( field_list. fields ( ) . map ( |it| {
762
+ ( SyntaxNodePtr :: new ( it. syntax ( ) ) , it. ty ( ) )
763
+ } ) )
762
764
}
763
765
}
764
766
. into_iter ( )
@@ -780,7 +782,6 @@ impl VariantFields {
780
782
lower_fields (
781
783
db,
782
784
loc. container ,
783
- loc. id . tree_id ( ) ,
784
785
& item_tree,
785
786
FieldParent :: Struct ( loc. id . value ) ,
786
787
loc. source ( db) . map ( |src| {
@@ -789,12 +790,14 @@ impl VariantFields {
789
790
. map ( |it| {
790
791
match it {
791
792
ast:: FieldList :: RecordFieldList ( record_field_list) => {
792
- Either :: Left (
793
- record_field_list . fields ( ) . map ( |it| it. ty ( ) ) ,
794
- )
793
+ Either :: Left ( record_field_list . fields ( ) . map ( |it| {
794
+ ( SyntaxNodePtr :: new ( it . syntax ( ) ) , it. ty ( ) )
795
+ } ) )
795
796
}
796
797
ast:: FieldList :: TupleFieldList ( field_list) => {
797
- Either :: Right ( field_list. fields ( ) . map ( |it| it. ty ( ) ) )
798
+ Either :: Right ( field_list. fields ( ) . map ( |it| {
799
+ ( SyntaxNodePtr :: new ( it. syntax ( ) ) , it. ty ( ) )
800
+ } ) )
798
801
}
799
802
}
800
803
. into_iter ( )
@@ -816,13 +819,15 @@ impl VariantFields {
816
819
lower_fields (
817
820
db,
818
821
loc. container ,
819
- loc. id . tree_id ( ) ,
820
822
& item_tree,
821
823
FieldParent :: Union ( loc. id . value ) ,
822
824
loc. source ( db) . map ( |src| {
823
825
union. fields . iter ( ) . zip (
824
826
src. record_field_list ( )
825
- . map ( |it| it. fields ( ) . map ( |it| it. ty ( ) ) )
827
+ . map ( |it| {
828
+ it. fields ( )
829
+ . map ( |it| ( SyntaxNodePtr :: new ( it. syntax ( ) ) , it. ty ( ) ) )
830
+ } )
826
831
. into_iter ( )
827
832
. flatten ( ) ,
828
833
)
@@ -852,17 +857,15 @@ impl VariantFields {
852
857
fn lower_fields < ' a > (
853
858
db : & dyn DefDatabase ,
854
859
module : ModuleId ,
855
- tree_id : TreeId ,
856
860
item_tree : & ItemTree ,
857
861
parent : FieldParent ,
858
- fields : InFile < impl Iterator < Item = ( & ' a Field , Option < ast:: Type > ) > > ,
862
+ fields : InFile < impl Iterator < Item = ( & ' a Field , ( SyntaxNodePtr , Option < ast:: Type > ) ) > > ,
859
863
override_visibility : Option < RawVisibilityId > ,
860
- ) -> ( Arena < FieldData > , ExpressionStore , ExpressionStoreSourceMap , Vec < DefDiagnostic > ) {
861
- let mut diagnostics = Vec :: new ( ) ;
864
+ ) -> ( Arena < FieldData > , ExpressionStore , ExpressionStoreSourceMap ) {
862
865
let mut arena = Arena :: new ( ) ;
863
866
let cfg_options = module. krate . cfg_options ( db) ;
864
867
let mut col = ExprCollector :: new ( db, module, fields. file_id ) ;
865
- for ( idx, ( field, ty ) ) in fields. value . enumerate ( ) {
868
+ for ( idx, ( field, ( ptr , ty ) ) ) in fields. value . enumerate ( ) {
866
869
let attr_owner = AttrOwner :: make_field_indexed ( parent, idx) ;
867
870
let attrs = item_tree. attrs ( db, module. krate , attr_owner) ;
868
871
if attrs. is_cfg_enabled ( cfg_options) {
@@ -873,17 +876,17 @@ fn lower_fields<'a>(
873
876
is_unsafe : field. is_unsafe ,
874
877
} ) ;
875
878
} else {
876
- diagnostics. push ( DefDiagnostic :: unconfigured_code (
877
- module . local_id ,
878
- tree_id ,
879
- attr_owner ,
880
- attrs . cfg ( ) . unwrap ( ) ,
881
- cfg_options . clone ( ) ,
882
- ) )
879
+ col . source_map . diagnostics . push (
880
+ crate :: expr_store :: ExpressionStoreDiagnostics :: InactiveCode {
881
+ node : InFile :: new ( fields . file_id , ptr ) ,
882
+ cfg : attrs . cfg ( ) . unwrap ( ) ,
883
+ opts : cfg_options . clone ( ) ,
884
+ } ,
885
+ ) ;
883
886
}
884
887
}
885
888
let store = col. store . finish ( ) ;
886
- ( arena, store, col. source_map , diagnostics )
889
+ ( arena, store, col. source_map )
887
890
}
888
891
889
892
#[ derive( Debug , Clone , PartialEq , Eq ) ]
0 commit comments