Skip to content

Commit

Permalink
Default to empty string in the case of missing doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
pjedge committed Mar 8, 2024
1 parent 4c606a0 commit 74c9b5f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
8 changes: 1 addition & 7 deletions martian-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion martian-derive/tests/mro/test_struct.mro
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions martian-derive/tests/test_full_mro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ fn test_with_struct() {
/// The chemistry name
name: String,
barcode_read: String,
#[mro_filename = "the_bc_length"]
barcode_length: u8,
}

Expand Down

0 comments on commit 74c9b5f

Please sign in to comment.