Skip to content

Commit 33cbf89

Browse files
Add test for block doc comments horizontal trim
1 parent e394287 commit 33cbf89

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

compiler/rustc_ast/src/util/comments/tests.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,17 @@ fn test_line_doc_comment() {
4545
#[test]
4646
fn test_doc_blocks() {
4747
create_default_session_globals_then(|| {
48-
let stripped = beautify_doc_string(
49-
Symbol::intern(
50-
" # Returns
51-
*
52-
",
53-
),
54-
CommentKind::Block,
55-
);
48+
let stripped =
49+
beautify_doc_string(Symbol::intern(" # Returns\n *\n "), CommentKind::Block);
5650
assert_eq!(stripped.as_str(), " # Returns\n\n");
5751

5852
let stripped = beautify_doc_string(
59-
Symbol::intern(
60-
"
61-
* # Returns
62-
*
63-
",
64-
),
53+
Symbol::intern("\n * # Returns\n *\n "),
6554
CommentKind::Block,
6655
);
6756
assert_eq!(stripped.as_str(), " # Returns\n\n");
57+
58+
let stripped = beautify_doc_string(Symbol::intern("\n * a\n "), CommentKind::Block);
59+
assert_eq!(stripped.as_str(), " a\n");
6860
})
6961
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
// compile-flags:--test
3+
4+
// This test ensures that no code block is detected in the doc comments.
5+
6+
pub mod Wormhole {
7+
/** # Returns
8+
*
9+
*/
10+
pub fn foofoo() {}
11+
/**
12+
* # Returns
13+
*
14+
*/
15+
pub fn barbar() {}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
running 0 tests
3+
4+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
5+

0 commit comments

Comments
 (0)