From fdb4a74f56d754a7d70de6add9e7e268303d675f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 18 Oct 2024 10:40:06 -0700 Subject: [PATCH 1/3] Update to edition 2018 --- Cargo.toml | 1 + src/common.rs | 4 ++-- src/header.rs | 8 ++++---- src/json.rs | 8 ++++---- src/lib.rs | 6 +++--- src/read2.rs | 2 +- src/runtest.rs | 24 ++++++++++++------------ src/util.rs | 2 +- tests/bless.rs | 4 ++-- 9 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 85c393f..19a7b86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ license = "MIT OR Apache-2.0" # Same as rustc repository = "https://github.com/Manishearth/compiletest-rs" keywords = ["compiletest", "test", "plugin"] readme = "README.md" +edition = "2018" [lib] name = "compiletest_rs" diff --git a/src/common.rs b/src/common.rs index 5d42633..d362fbd 100644 --- a/src/common.rs +++ b/src/common.rs @@ -17,8 +17,8 @@ use std::path::Path; use std::path::PathBuf; use std::str::FromStr; -use runtest::dylib_env_var; -use test::ColorConfig; +use crate::runtest::dylib_env_var; +use crate::test::ColorConfig; #[derive(Clone, Copy, PartialEq, Debug)] pub enum Mode { diff --git a/src/header.rs b/src/header.rs index d490a0d..267688a 100644 --- a/src/header.rs +++ b/src/header.rs @@ -14,11 +14,11 @@ use std::io::prelude::*; use std::io::BufReader; use std::path::{Path, PathBuf}; -use common; -use common::Config; -use util; +use crate::common; +use crate::common::Config; +use crate::util; -use extract_gdb_version; +use crate::extract_gdb_version; /// Properties which must be known very early, before actually running /// the test. diff --git a/src/json.rs b/src/json.rs index 58f4f9c..1716635 100644 --- a/src/json.rs +++ b/src/json.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use errors::{Error, ErrorKind}; -use runtest::ProcRes; +use crate::errors::{Error, ErrorKind}; +use crate::runtest::ProcRes; use std::path::Path; use std::str::FromStr; @@ -236,7 +236,7 @@ fn push_expected_errors( // Add notes for the backtrace for span in primary_spans { - for frame in &span.expansion { + if let Some(frame) = &span.expansion { push_backtrace(expected_errors, frame, file_name); } } @@ -272,7 +272,7 @@ fn push_backtrace( }); } - for previous_expansion in &expansion.span.expansion { + if let Some(previous_expansion) = &expansion.span.expansion { push_backtrace(expected_errors, previous_expansion, file_name); } } diff --git a/src/lib.rs b/src/lib.rs index 8489453..b0045cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,8 +38,8 @@ extern crate serde_json; extern crate serde_derive; extern crate rustfix; -use common::{DebugInfoGdb, DebugInfoLldb, Pretty}; -use common::{Mode, TestPaths}; +use crate::common::{DebugInfoGdb, DebugInfoLldb, Pretty}; +use crate::common::{Mode, TestPaths}; use std::env; use std::ffi::OsString; use std::fs; @@ -57,7 +57,7 @@ pub mod runtest; pub mod uidiff; pub mod util; -pub use common::Config; +pub use crate::common::Config; pub fn run_tests(config: &Config) { if config.target.contains("android") { diff --git a/src/read2.rs b/src/read2.rs index c3af44a..726686f 100644 --- a/src/read2.rs +++ b/src/read2.rs @@ -21,7 +21,7 @@ mod imp { pub fn read2( out_pipe: ChildStdout, err_pipe: ChildStderr, - data: &mut FnMut(bool, &mut Vec, bool), + data: &mut dyn FnMut(bool, &mut Vec, bool), ) -> io::Result<()> { let mut buffer = Vec::new(); out_pipe.read_to_end(&mut buffer)?; diff --git a/src/runtest.rs b/src/runtest.rs index d153fcd..e1a0da5 100644 --- a/src/runtest.rs +++ b/src/runtest.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::common::{expected_output_path, UI_FIXED, UI_STDERR, UI_STDOUT}; +use crate::common::{Assembly, Incremental, MirOpt, RunMake, Ui}; +use crate::common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; +use crate::common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; +use crate::common::{Config, TestPaths}; +use crate::errors::{self, Error, ErrorKind}; +use crate::header::TestProps; +use crate::json; use crate::util::{logv, PathBufExt}; -use common::{expected_output_path, UI_FIXED, UI_STDERR, UI_STDOUT}; -use common::{Assembly, Incremental, MirOpt, RunMake, Ui}; -use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; -use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; -use common::{Config, TestPaths}; -use errors::{self, Error, ErrorKind}; use filetime::FileTime; -use header::TestProps; -use json; use regex::Regex; use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; @@ -34,7 +34,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::str; use std::sync::{Arc, Mutex, RwLock}; -use extract_gdb_version; +use crate::extract_gdb_version; fn get_or_create_coverage_file(path: &Path, create: impl FnOnce() -> File) -> Arc> { lazy_static::lazy_static! { @@ -115,7 +115,7 @@ pub fn run(config: Config, testpaths: &TestPaths) { base_cx.complete_all(); - File::create(::stamp(&config, testpaths)).unwrap(); + File::create(crate::stamp(&config, testpaths)).unwrap(); } struct TestCx<'test> { @@ -1707,7 +1707,7 @@ actual:\n\ } fn make_cmdline(&self, command: &Command, libpath: &str) -> String { - use util; + use crate::util; // Linux and mac don't require adjusting the library search path if cfg!(unix) { @@ -3067,7 +3067,7 @@ fn nocomment_mir_line(line: &str) -> &str { } fn read2_abbreviated(mut child: Child) -> io::Result { - use read2::read2; + use crate::read2::read2; use std::mem::replace; const HEAD_LEN: usize = 160 * 1024; diff --git a/src/util.rs b/src/util.rs index 08a27fc..0773f11 100644 --- a/src/util.rs +++ b/src/util.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use common::Config; +use crate::common::Config; use std::env; use std::ffi::OsStr; use std::path::PathBuf; diff --git a/tests/bless.rs b/tests/bless.rs index 3e5b2b4..1c161d8 100644 --- a/tests/bless.rs +++ b/tests/bless.rs @@ -3,8 +3,8 @@ extern crate compiletest_rs as compiletest; mod test_support; -use compiletest::Config; -use test_support::{testsuite, TestsuiteBuilder, GLOBAL_ROOT}; +use crate::compiletest::Config; +use crate::test_support::{testsuite, TestsuiteBuilder, GLOBAL_ROOT}; fn setup(mode: &str) -> (Config, TestsuiteBuilder) { let builder = testsuite(mode); From 254abe5aef9ae3a4d081b12d54e57667229bd055 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 18 Oct 2024 10:42:38 -0700 Subject: [PATCH 2/3] Update to edition 2021 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 19a7b86..d3e9f23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" # Same as rustc repository = "https://github.com/Manishearth/compiletest-rs" keywords = ["compiletest", "test", "plugin"] readme = "README.md" -edition = "2018" +edition = "2021" [lib] name = "compiletest_rs" From d32df2299092c432c8f0cf272c17d81bfe899a7a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 18 Oct 2024 11:03:28 -0700 Subject: [PATCH 3/3] other fixes --- src/read2.rs | 2 +- src/runtest.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/read2.rs b/src/read2.rs index 726686f..715ea86 100644 --- a/src/read2.rs +++ b/src/read2.rs @@ -129,7 +129,7 @@ mod imp { pub fn read2( out_pipe: ChildStdout, err_pipe: ChildStderr, - data: &mut FnMut(bool, &mut Vec, bool), + data: &mut dyn FnMut(bool, &mut Vec, bool), ) -> io::Result<()> { let mut out = Vec::new(); let mut err = Vec::new(); diff --git a/src/runtest.rs b/src/runtest.rs index e1a0da5..2eeca4f 100644 --- a/src/runtest.rs +++ b/src/runtest.rs @@ -1940,9 +1940,7 @@ actual:\n\ fn charset() -> &'static str { // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset - if cfg!(target_os = "bitrig") { - "auto" - } else if cfg!(target_os = "freebsd") { + if cfg!(target_os = "freebsd") { "ISO-8859-1" } else { "UTF-8" @@ -3142,8 +3140,8 @@ fn read2_abbreviated(mut child: Child) -> io::Result { read2( child.stdout.take().unwrap(), child.stderr.take().unwrap(), - &mut |is_stdout, data, _| { - if is_stdout { &mut stdout } else { &mut stderr }.extend(data); + &mut |is_stdout, data: &mut Vec, _| { + if is_stdout { &mut stdout } else { &mut stderr }.extend(&data); data.clear(); }, )?;