Skip to content
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

Update to edition 2021 #293

Merged
merged 3 commits into from
Oct 18, 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "2021"

[lib]
name = "compiletest_rs"
Expand Down
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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") {
Expand Down
4 changes: 2 additions & 2 deletions src/read2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod imp {
pub fn read2(
out_pipe: ChildStdout,
err_pipe: ChildStderr,
data: &mut FnMut(bool, &mut Vec<u8>, bool),
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
) -> io::Result<()> {
let mut buffer = Vec::new();
out_pipe.read_to_end(&mut buffer)?;
Expand Down Expand Up @@ -129,7 +129,7 @@ mod imp {
pub fn read2(
out_pipe: ChildStdout,
err_pipe: ChildStderr,
data: &mut FnMut(bool, &mut Vec<u8>, bool),
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
) -> io::Result<()> {
let mut out = Vec::new();
let mut err = Vec::new();
Expand Down
32 changes: 15 additions & 17 deletions src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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<Mutex<File>> {
lazy_static::lazy_static! {
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -3067,7 +3065,7 @@ fn nocomment_mir_line(line: &str) -> &str {
}

fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
use read2::read2;
use crate::read2::read2;
use std::mem::replace;

const HEAD_LEN: usize = 160 * 1024;
Expand Down Expand Up @@ -3142,8 +3140,8 @@ fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
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<u8>, _| {
if is_stdout { &mut stdout } else { &mut stderr }.extend(&data);
data.clear();
},
)?;
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/bless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading