File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
crates/ide-diagnostics/src/handlers Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,8 @@ fn missing_record_expr_field_fixes(
102102 let indent = IndentLevel :: from_node ( last_field_syntax) ;
103103
104104 let mut new_field = new_field. to_string ( ) ;
105- if usage_file_id != def_file_id {
105+ // FIXME: check submodule instead of FileId
106+ if usage_file_id != def_file_id && !matches ! ( def_id, hir:: VariantDef :: Variant ( _) ) {
106107 new_field = format ! ( "pub(crate) {new_field}" ) ;
107108 }
108109 new_field = format ! ( "\n {indent}{new_field}" ) ;
@@ -357,6 +358,34 @@ pub struct Foo {
357358 )
358359 }
359360
361+ #[ test]
362+ fn test_add_enum_variant_field_in_other_file_from_usage ( ) {
363+ check_fix (
364+ r#"
365+ //- /main.rs
366+ mod foo;
367+
368+ fn main() {
369+ foo::Foo::Variant { bar: 3, $0baz: false};
370+ }
371+ //- /foo.rs
372+ pub enum Foo {
373+ Variant {
374+ bar: i32
375+ }
376+ }
377+ "# ,
378+ r#"
379+ pub enum Foo {
380+ Variant {
381+ bar: i32,
382+ baz: bool
383+ }
384+ }
385+ "# ,
386+ )
387+ }
388+
360389 #[ test]
361390 fn test_tuple_field_on_record_struct ( ) {
362391 check_no_fix (
You can’t perform that action at this time.
0 commit comments