Add failing tests (fmt panic) on weird doc comments.

Isolated doc comments causes the compiler to panic with:

  ```
  'no consecutive empty lines'
  ```

  This is reproducible when doc comments are wrapped in sandwich between
  comments and newlines.
This commit is contained in:
KtorZ
2023-03-16 23:22:36 +01:00
committed by Lucas
parent 0feb2df0a0
commit 57e217e81c
3 changed files with 52 additions and 0 deletions

View File

@@ -322,6 +322,25 @@ fn utf8_hex_literal_warning() {
))
}
#[test]
fn weird_comments() {
let source_code = r#"
// A
/// B
// C
fn foo () {
todo
}
"#;
assert!(matches!(
check(parse(source_code)),
Err((_, Error::UnexpectedDocComment { .. }))
))
}
#[test]
fn discarded_let_bindings() {
let source_code = r#"

View File

@@ -629,3 +629,29 @@ fn test_preserve_pipe() {
assert_fmt(src, expected);
}
#[test]
fn weird_comments() {
let src = indoc! { r#"
// A
/// B
/// C
fn bar () {
todo
}
"#};
let expected = indoc! { r#"
// A
/// B
/// C
fn bar () {
todo
}
"#};
assert_fmt(src, expected);
}