From 43d0497824d3d1a6f0b15d865a00715537673af2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 8 Apr 2022 15:30:37 +0200 Subject: [PATCH 1/2] Fix invalid array access in `beautify_doc_string` --- compiler/rustc_ast/src/util/comments.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/util/comments.rs b/compiler/rustc_ast/src/util/comments.rs index f51b0086dc8b..8730aeb0f3bf 100644 --- a/compiler/rustc_ast/src/util/comments.rs +++ b/compiler/rustc_ast/src/util/comments.rs @@ -52,7 +52,10 @@ fn get_horizontal_trim<'a>(lines: &'a [&str], kind: CommentKind) -> Option Date: Fri, 8 Apr 2022 15:30:53 +0200 Subject: [PATCH 2/2] Add test for empty doc comments with a backline --- src/test/rustdoc/empty-doc-comment.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/rustdoc/empty-doc-comment.rs diff --git a/src/test/rustdoc/empty-doc-comment.rs b/src/test/rustdoc/empty-doc-comment.rs new file mode 100644 index 000000000000..b1dae930e066 --- /dev/null +++ b/src/test/rustdoc/empty-doc-comment.rs @@ -0,0 +1,22 @@ +// Ensure that empty doc comments don't panic. + +/*! +*/ + +/// +/// +pub struct Foo; + +#[doc = " +"] +pub mod Mod { + //! + //! +} + +/** +*/ +pub mod Another { + #![doc = " +"] +}