diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6ef792..d8e5dfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,13 @@ jobs: include: - rust: 1.36.0 test_features: "--all-features" + allow_failure: false - rust: stable test_features: "--all-features" + allow_failure: false - rust: beta test_features: "--all-features" + allow_failure: false - rust: nightly test_features: "--all-features" allow_failure: true diff --git a/schemars_derive/src/attr/doc.rs b/schemars_derive/src/attr/doc.rs index 26a5090..a1557ba 100644 --- a/schemars_derive/src/attr/doc.rs +++ b/schemars_derive/src/attr/doc.rs @@ -32,7 +32,7 @@ fn merge_description_lines(doc: &str) -> Option { } fn get_doc(attrs: &[Attribute]) -> Option { - let doc = attrs + let attrs = attrs .iter() .filter_map(|attr| { if !attr.path.is_ident("doc") { @@ -46,14 +46,31 @@ fn get_doc(attrs: &[Attribute]) -> Option { None }) - .collect::>() + .collect::>(); + + let mut lines = attrs .iter() .flat_map(|a| a.split('\n')) .map(str::trim) .skip_while(|s| *s == "") - .collect::>() - .join("\n"); - none_if_empty(doc) + .collect::>(); + + if let Some(&"") = lines.last() { + lines.pop(); + } + + // Added for backward-compatibility, but perhaps we shouldn't do this + // https://github.com/rust-lang/rust/issues/32088 + if lines.iter().all(|l| l.starts_with("*")) { + for line in lines.iter_mut() { + *line = line[1..].trim() + } + while let Some(&"") = lines.first() { + lines.remove(0); + } + }; + + none_if_empty(lines.join("\n")) } fn none_if_empty(s: String) -> Option {