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

Transition compiletest to Rust 2018 #58091

Merged
merged 1 commit into from Feb 9, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tools/compiletest/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "compiletest"
version = "0.0.0"
edition = "2018"

[dependencies]
diff = "0.1.10"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/common.rs
Expand Up @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;

use test::ColorConfig;
use util::PathBufExt;
use crate::util::PathBufExt;

#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Mode {
Expand Down Expand Up @@ -66,7 +66,7 @@ impl FromStr for Mode {
}

impl fmt::Display for Mode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match *self {
CompileFail => "compile-fail",
RunFail => "run-fail",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/errors.rs
Expand Up @@ -33,7 +33,7 @@ impl FromStr for ErrorKind {
}

impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ErrorKind::Help => write!(f, "help message"),
ErrorKind::Error => write!(f, "error"),
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/header.rs
Expand Up @@ -4,10 +4,10 @@ use std::io::prelude::*;
use std::io::BufReader;
use std::path::{Path, PathBuf};

use common::{self, CompareMode, Config, Mode};
use util;
use crate::common::{self, CompareMode, Config, Mode};
use crate::util;

use extract_gdb_version;
use crate::extract_gdb_version;

/// Whether to ignore the test.
#[derive(Clone, Copy, PartialEq, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/json.rs
@@ -1,5 +1,5 @@
use errors::{Error, ErrorKind};
use runtest::ProcRes;
use crate::errors::{Error, ErrorKind};
use crate::runtest::ProcRes;
use serde_json;
use std::path::Path;
use std::str::FromStr;
Expand Down
22 changes: 8 additions & 14 deletions src/tools/compiletest/src/main.rs
@@ -1,29 +1,21 @@
#![crate_name = "compiletest"]
#![feature(test)]
#![deny(warnings)]
#![deny(warnings, rust_2018_idioms)]

extern crate diff;
extern crate env_logger;
extern crate filetime;
extern crate getopts;
#[cfg(unix)]
extern crate libc;
#[macro_use]
extern crate log;
extern crate regex;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate test;
extern crate rustfix;
extern crate walkdir;

use common::CompareMode;
use common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
use common::{Config, TestPaths};
use common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
use crate::common::CompareMode;
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
use crate::common::{Config, TestPaths};
use crate::common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
use filetime::FileTime;
use getopts::Options;
use std::env;
Expand All @@ -33,8 +25,10 @@ use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
use std::process::Command;
use test::ColorConfig;
use util::logv;
use crate::util::logv;
use walkdir::WalkDir;
use env_logger;
use getopts;

use self::header::{EarlyProps, Ignore};

Expand Down
11 changes: 4 additions & 7 deletions src/tools/compiletest/src/read2.rs
Expand Up @@ -100,18 +100,15 @@ mod imp {

#[cfg(windows)]
mod imp {
extern crate miow;
extern crate winapi;

use std::io;
use std::os::windows::prelude::*;
use std::process::{ChildStderr, ChildStdout};
use std::slice;

use self::miow::iocp::{CompletionPort, CompletionStatus};
use self::miow::pipe::NamedPipe;
use self::miow::Overlapped;
use self::winapi::shared::winerror::ERROR_BROKEN_PIPE;
use miow::iocp::{CompletionPort, CompletionStatus};
use miow::pipe::NamedPipe;
use miow::Overlapped;
use winapi::shared::winerror::ERROR_BROKEN_PIPE;

struct Pipe<'a> {
dst: &'a mut Vec<u8>,
Expand Down
34 changes: 17 additions & 17 deletions src/tools/compiletest/src/runtest.rs
@@ -1,18 +1,18 @@
use common::CompareMode;
use common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT};
use common::{output_base_dir, output_base_name, output_testname_unique};
use common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc};
use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind};
use common::{Config, TestPaths};
use common::{Incremental, MirOpt, RunMake, Ui};
use crate::common::CompareMode;
use crate::common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT};
use crate::common::{output_base_dir, output_base_name, output_testname_unique};
use crate::common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc};
use crate::common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind};
use crate::common::{Config, TestPaths};
use crate::common::{Incremental, MirOpt, RunMake, Ui};
use diff;
use errors::{self, Error, ErrorKind};
use crate::errors::{self, Error, ErrorKind};
use filetime::FileTime;
use header::TestProps;
use json;
use crate::header::TestProps;
use crate::json;
use regex::Regex;
use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
use util::{logv, PathBufExt};
use crate::util::{logv, PathBufExt};

use std::collections::hash_map::DefaultHasher;
use std::collections::{HashMap, HashSet, VecDeque};
Expand All @@ -27,8 +27,8 @@ use std::path::{Path, PathBuf};
use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::str;

use extract_gdb_version;
use is_android_gdb_target;
use crate::extract_gdb_version;
use crate::is_android_gdb_target;

#[cfg(windows)]
fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
Expand Down Expand Up @@ -1937,7 +1937,7 @@ impl<'test> TestCx<'test> {
}

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 @@ -3255,7 +3255,7 @@ impl<'test> TestCx<'test> {
}

fn create_stamp(&self) {
let stamp = ::stamp(&self.config, self.testpaths, self.revision);
let stamp = crate::stamp(&self.config, self.testpaths, self.revision);
fs::write(&stamp, compute_stamp_hash(&self.config)).unwrap();
}
}
Expand Down Expand Up @@ -3311,7 +3311,7 @@ impl<T> fmt::Debug for ExpectedLine<T>
where
T: AsRef<str> + fmt::Debug,
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
if let &ExpectedLine::Text(ref t) = self {
write!(formatter, "{:?}", t)
} else {
Expand All @@ -3334,7 +3334,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
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/util.rs
@@ -1,7 +1,7 @@
use std::ffi::OsStr;
use std::env;
use std::path::PathBuf;
use common::Config;
use crate::common::Config;

/// Conversion table from triple OS name to Rust SYSNAME
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
Expand Down