ensure parse errors aren't emitted when formatting doc comments (#6232)
This adds a test case to validate behavior when using `format_code_in_doc_comments=true`
This commit is contained in:
parent
eed7e237bc
commit
c8290a5fb7
2 changed files with 20 additions and 1 deletions
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
7
tests/target/issue-6109.rs
Normal file
7
tests/target/issue-6109.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/// Some doc comment with code snippet:
|
||||
///```
|
||||
/// '\u{1F}
|
||||
/// ```
|
||||
pub struct Code {}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue