about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/rustfmt/main.rs14
-rw-r--r--tests/target/issue-6109.rs7
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/rustfmt/main.rs b/tests/rustfmt/main.rs
index 58cf0e5e4db..e99890acd1b 100644
--- a/tests/rustfmt/main.rs
+++ b/tests/rustfmt/main.rs
@@ -5,7 +5,7 @@ use std::fs::remove_file;
 use std::path::Path;
 use std::process::Command;
 
-use rustfmt_config_proc_macro::rustfmt_only_ci_test;
+use rustfmt_config_proc_macro::{nightly_only_test, rustfmt_only_ci_test};
 
 /// Run the rustfmt executable and return its output.
 fn rustfmt(args: &[&str]) -> (String, String) {
@@ -207,3 +207,15 @@ fn rustfmt_emits_error_when_control_brace_style_is_always_next_line() {
     let (_stdout, stderr) = rustfmt(&args);
     assert!(!stderr.contains("error[internal]: left behind trailing whitespace"))
 }
+
+#[nightly_only_test]
+#[test]
+fn rustfmt_generates_no_error_if_failed_format_code_in_doc_comments() {
+    // See also https://github.com/rust-lang/rustfmt/issues/6109
+
+    let file = "tests/target/issue-6109.rs";
+    let args = ["--config", "format_code_in_doc_comments=true", file];
+    let (stdout, stderr) = rustfmt(&args);
+    assert!(stderr.is_empty());
+    assert!(stdout.is_empty());
+}
diff --git a/tests/target/issue-6109.rs b/tests/target/issue-6109.rs
new file mode 100644
index 00000000000..7d2bbf75691
--- /dev/null
+++ b/tests/target/issue-6109.rs
@@ -0,0 +1,7 @@
+/// Some doc comment with code snippet:
+///```
+/// '\u{1F}
+/// ```
+pub struct Code {}
+
+fn main() {}