From 74c9b5f1b3f8aa325be07430250c76fbaee66165 Mon Sep 17 00:00:00 2001 From: Peter Edge Date: Thu, 7 Mar 2024 19:35:15 -0800 Subject: [PATCH] Default to empty string in the case of missing doc comment --- martian-derive/src/lib.rs | 8 +------- martian-derive/tests/mro/test_struct.mro | 2 +- martian-derive/tests/test_full_mro.rs | 1 + 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/martian-derive/src/lib.rs b/martian-derive/src/lib.rs index aeeb962584..87d1cf126e 100644 --- a/martian-derive/src/lib.rs +++ b/martian-derive/src/lib.rs @@ -563,13 +563,7 @@ pub fn martian_struct(item: proc_macro::TokenStream) -> proc_macro::TokenStream }; if mro_filename.is_some() && doc_comment.is_none() { - return syn::Error::new_spanned(field, - "ERROR: mro_filename attribute was specified for field but a doc comment was not defined for the field. \ - mro_filename can only be specified when a doc comment is specified for a field, \ - because doc comments are converted into Martian struct field descriptions which precede \ - the Martian filename column (optional 3rd and 4th columns in Martian struct def)") - .to_compile_error() - .into(); + doc_comment = Some("".to_string()); } let doc_comment_code = match doc_comment { diff --git a/martian-derive/tests/mro/test_struct.mro b/martian-derive/tests/mro/test_struct.mro index 6af8b0a7d4..f9543f3909 100644 --- a/martian-derive/tests/mro/test_struct.mro +++ b/martian-derive/tests/mro/test_struct.mro @@ -21,7 +21,7 @@ struct Config( struct ChemistryDef( string name "The chemistry name", string barcode_read, - int barcode_length, + int barcode_length "" "the_bc_length", ) struct RnaChunk( diff --git a/martian-derive/tests/test_full_mro.rs b/martian-derive/tests/test_full_mro.rs index c3267ed7cb..e1ba276bb9 100644 --- a/martian-derive/tests/test_full_mro.rs +++ b/martian-derive/tests/test_full_mro.rs @@ -424,6 +424,7 @@ fn test_with_struct() { /// The chemistry name name: String, barcode_read: String, + #[mro_filename = "the_bc_length"] barcode_length: u8, }