Skip to content

Test do nothing with doc comment with code #6232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tests/rustfmt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 changes: 7 additions & 0 deletions tests/target/issue-6109.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// Some doc comment with code snippet:
///```
/// '\u{1F}
/// ```
pub struct Code {}

fn main() {}
Loading