File tree 2 files changed +17
-2
lines changed
ide-diagnostics/src/handlers
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ impl SourceAnalyzer {
368
368
let local = if field. name_ref ( ) . is_some ( ) {
369
369
None
370
370
} else {
371
+ // Shorthand syntax, resolve to the local
371
372
let path = ModPath :: from_segments ( PathKind :: Plain , once ( local_name. clone ( ) ) ) ;
372
373
match self . resolver . resolve_path_in_value_ns_fully ( db. upcast ( ) , & path) {
373
374
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(
68
68
}
69
69
let new_field = make:: record_field (
70
70
None ,
71
- make:: name ( & record_expr_field. field_name ( ) ?. text ( ) ) ,
71
+ make:: name ( & record_expr_field. field_name ( ) ?. ident_token ( ) ? . text ( ) ) ,
72
72
make:: ty ( & new_field_type. display_source_code ( sema. db , module. into ( ) ) . ok ( ) ?) ,
73
73
) ;
74
74
@@ -109,7 +109,7 @@ fn missing_record_expr_field_fixes(
109
109
110
110
#[ cfg( test) ]
111
111
mod tests {
112
- use crate :: tests:: { check_diagnostics, check_fix} ;
112
+ use crate :: tests:: { check_diagnostics, check_fix, check_no_fix } ;
113
113
114
114
#[ test]
115
115
fn no_such_field_diagnostics ( ) {
@@ -277,6 +277,20 @@ struct Foo {
277
277
bar: i32,
278
278
pub(crate) baz: bool
279
279
}
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
+ }
280
294
"# ,
281
295
)
282
296
}
You can’t perform that action at this time.
0 commit comments