From ae15e34456b96f56ca799b400bc9a774cc665a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= Date: Thu, 7 Mar 2024 17:32:10 +0000 Subject: [PATCH] Reformat and fix tidy error --- src/tools/compiletest/src/header.rs | 5 ++-- .../directive_checks/error_annotation.rs | 2 +- src/tools/compiletest/src/header/tests.rs | 30 +++++++++++++++---- src/tools/compiletest/src/util.rs | 2 +- .../compiletest/src/util/edit_distance.rs | 2 +- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 398ce6fa6303e..4f02cd2d9f6ab 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -746,11 +746,11 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "ignore-mode-incremental", "ignore-mode-js-doc-test", "ignore-mode-mir-opt", + "ignore-mode-pretty", "ignore-mode-run-make", "ignore-mode-run-pass-valgrind", "ignore-mode-rustdoc", "ignore-mode-rustdoc-json", - "ignore-mode-pretty", "ignore-mode-ui", "ignore-mode-ui-fulldeps", "ignore-msp430", @@ -993,7 +993,8 @@ fn iter_header( if testfile.extension().map(|e| e == "rs").unwrap_or(false) { let directive_ln = non_revisioned_directive_line.trim(); - let CheckDirectiveResult { is_known_directive, directive_name } = check_directive(directive_ln); + let CheckDirectiveResult { is_known_directive, directive_name } = + check_directive(directive_ln); if !is_known_directive { *poisoned = true; diff --git a/src/tools/compiletest/src/header/directive_checks/error_annotation.rs b/src/tools/compiletest/src/header/directive_checks/error_annotation.rs index 3c3d8b28efe10..fea66a5e07b4d 100644 --- a/src/tools/compiletest/src/header/directive_checks/error_annotation.rs +++ b/src/tools/compiletest/src/header/directive_checks/error_annotation.rs @@ -1,6 +1,6 @@ //@ check-pass //~ HELP -fn main() { } //~ERROR +fn main() {} //~ERROR //~^ ERROR //~| ERROR diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index f407d900cef15..25a5266da415a 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -623,34 +623,54 @@ fn run_path(poisoned: &mut bool, path: &Path, buf: &[u8]) { #[test] fn test_unknown_directive_check() { let mut poisoned = false; - run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/unknown_directive.rs")); + run_path( + &mut poisoned, + Path::new("a.rs"), + include_bytes!("./directive_checks/unknown_directive.rs"), + ); assert!(poisoned); } #[test] fn test_known_legacy_directive_check() { let mut poisoned = false; - run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/known_legacy_directive.rs")); + run_path( + &mut poisoned, + Path::new("a.rs"), + include_bytes!("./directive_checks/known_legacy_directive.rs"), + ); assert!(poisoned); } #[test] fn test_known_directive_check_no_error() { let mut poisoned = false; - run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/known_directive.rs")); + run_path( + &mut poisoned, + Path::new("a.rs"), + include_bytes!("./directive_checks/known_directive.rs"), + ); assert!(!poisoned); } #[test] fn test_error_annotation_no_error() { let mut poisoned = false; - run_path(&mut poisoned, Path::new("a.rs"), include_bytes!("./directive_checks/error_annotation.rs")); + run_path( + &mut poisoned, + Path::new("a.rs"), + include_bytes!("./directive_checks/error_annotation.rs"), + ); assert!(!poisoned); } #[test] fn test_non_rs_unknown_directive_not_checked() { let mut poisoned = false; - run_path(&mut poisoned, Path::new("a.Makefile"), include_bytes!("./directive_checks/not_rs.Makefile")); + run_path( + &mut poisoned, + Path::new("a.Makefile"), + include_bytes!("./directive_checks/not_rs.Makefile"), + ); assert!(!poisoned); } diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 176fac0cc00eb..c47c06a5db3da 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -6,9 +6,9 @@ use std::process::Command; use tracing::*; +pub(crate) mod edit_distance; #[cfg(test)] mod tests; -pub(crate) mod edit_distance; pub fn make_new_path(path: &str) -> String { assert!(cfg!(windows)); diff --git a/src/tools/compiletest/src/util/edit_distance.rs b/src/tools/compiletest/src/util/edit_distance.rs index 4710a43669106..921a9578cb498 100644 --- a/src/tools/compiletest/src/util/edit_distance.rs +++ b/src/tools/compiletest/src/util/edit_distance.rs @@ -1,7 +1,7 @@ //! Edit distance taken from rustc's `rustc_span::edit_distance`. -use std::mem; use std::cmp; +use std::mem; /// Finds the [edit distance] between two strings. ///