@@ -7,8 +7,8 @@ use rue_hir::{Hir, SymbolPath, Value};
77use rue_types:: { Pair , Type , Union } ;
88
99use crate :: {
10- Compiler , CompletionContext , PathKind , PathResult , SyntaxField , SyntaxItem , SyntaxItemKind ,
11- compile_expr , compile_path,
10+ Compiler , CompletionContext , PathKind , PathResult , SyntaxField , SyntaxItemKind , compile_expr ,
11+ compile_path,
1212} ;
1313
1414pub fn compile_struct_initializer_expr (
@@ -17,7 +17,7 @@ pub fn compile_struct_initializer_expr(
1717) -> Value {
1818 let ty = if let Some ( path) = expr. path ( )
1919 && let PathResult :: Type ( ty, _) =
20- compile_path ( ctx, path. syntax ( ) , path. segments ( ) , PathKind :: Type )
20+ compile_path ( ctx, path. syntax ( ) , path. segments ( ) , PathKind :: Type , true )
2121 {
2222 ty
2323 } else {
@@ -27,7 +27,7 @@ pub fn compile_struct_initializer_expr(
2727
2828 let semantic = rue_types:: unwrap_semantic ( ctx. types_mut ( ) , ty, true ) ;
2929
30- ctx. syntax_map_mut ( ) . add_item ( SyntaxItem :: new (
30+ ctx. add_syntax (
3131 SyntaxItemKind :: CompletionContext ( CompletionContext :: StructFields {
3232 ty : semantic,
3333 specified_fields : Some (
@@ -38,7 +38,7 @@ pub fn compile_struct_initializer_expr(
3838 ) ,
3939 } ) ,
4040 expr. syntax ( ) . text_range ( ) ,
41- ) ) ;
41+ ) ;
4242
4343 let Type :: Struct ( struct_type) = ctx. ty ( semantic) . clone ( ) else {
4444 debug ! ( "Unresolved struct initializer due to non struct type" ) ;
@@ -98,9 +98,13 @@ pub fn compile_struct_initializer_expr(
9898 continue ;
9999 } ;
100100
101- if let PathResult :: Symbol ( symbol, override_type, _) =
102- compile_path ( ctx, field. syntax ( ) , [ name] . into_iter ( ) , PathKind :: Symbol )
103- {
101+ if let PathResult :: Symbol ( symbol, override_type, _) = compile_path (
102+ ctx,
103+ field. syntax ( ) ,
104+ [ name] . into_iter ( ) ,
105+ PathKind :: Symbol ,
106+ false ,
107+ ) {
104108 let ty = ctx. symbol_type ( symbol) ;
105109
106110 let mut value = Value :: new ( ctx. alloc_hir ( Hir :: Reference ( symbol) ) , ty)
@@ -124,7 +128,7 @@ pub fn compile_struct_initializer_expr(
124128 continue ;
125129 } ;
126130
127- ctx. syntax_map_mut ( ) . add_item ( SyntaxItem :: new (
131+ ctx. add_syntax (
128132 SyntaxItemKind :: FieldInitializer ( SyntaxField {
129133 name : name. text ( ) . to_string ( ) ,
130134 container : semantic,
@@ -134,7 +138,7 @@ pub fn compile_struct_initializer_expr(
134138 . unwrap_or ( value. ty ) ,
135139 } ) ,
136140 name. text_range ( ) ,
137- ) ) ;
141+ ) ;
138142
139143 if struct_type. fields . contains ( name. text ( ) ) {
140144 if let Some ( expected_type) = expected_field_types. get ( name. text ( ) ) {
0 commit comments