File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ impl SourceAnalyzer {
368368 let local = if field. name_ref ( ) . is_some ( ) {
369369 None
370370 } else {
371+ // Shorthand syntax, resolve to the local
371372 let path = ModPath :: from_segments ( PathKind :: Plain , once ( local_name. clone ( ) ) ) ;
372373 match self . resolver . resolve_path_in_value_ns_fully ( db. upcast ( ) , & path) {
373374 Some ( ValueNs :: LocalBinding ( pat_id) ) => {
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ fn missing_record_expr_field_fixes(
6868 }
6969 let new_field = make:: record_field (
7070 None ,
71- make:: name ( & record_expr_field. field_name ( ) ?. text ( ) ) ,
71+ make:: name ( & record_expr_field. field_name ( ) ?. ident_token ( ) ? . text ( ) ) ,
7272 make:: ty ( & new_field_type. display_source_code ( sema. db , module. into ( ) ) . ok ( ) ?) ,
7373 ) ;
7474
@@ -109,7 +109,7 @@ fn missing_record_expr_field_fixes(
109109
110110#[ cfg( test) ]
111111mod tests {
112- use crate :: tests:: { check_diagnostics, check_fix} ;
112+ use crate :: tests:: { check_diagnostics, check_fix, check_no_fix } ;
113113
114114 #[ test]
115115 fn no_such_field_diagnostics ( ) {
@@ -277,6 +277,20 @@ struct Foo {
277277 bar: i32,
278278 pub(crate) baz: bool
279279}
280+ "# ,
281+ )
282+ }
283+
284+ #[ test]
285+ fn test_tuple_field_on_record_struct ( ) {
286+ check_no_fix (
287+ r#"
288+ struct Struct {}
289+ fn main() {
290+ Struct {
291+ 0$0: 0
292+ }
293+ }
280294"# ,
281295 )
282296 }
You can’t perform that action at this time.
0 commit comments