diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index 624f4dd7c2b1c..0263b91f50b80 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -8,8 +8,8 @@ use tracing::*; use crate::common::{CodegenBackend, Config, Debugger, FailMode, PassMode, RunFailMode, TestMode}; use crate::debuggers::{extract_cdb_version, extract_gdb_version}; -pub(crate) use crate::directives::auxiliary::AuxProps; use crate::directives::auxiliary::parse_and_update_aux; +pub(crate) use crate::directives::auxiliary::{AuxCrate, AuxProps}; use crate::directives::directive_names::{ KNOWN_DIRECTIVE_NAMES_SET, KNOWN_HTMLDOCCK_DIRECTIVE_NAMES, KNOWN_JSONDOCCK_DIRECTIVE_NAMES, }; diff --git a/src/tools/compiletest/src/directives/auxiliary.rs b/src/tools/compiletest/src/directives/auxiliary.rs index 40e2e7049c8fa..1b72931949c54 100644 --- a/src/tools/compiletest/src/directives/auxiliary.rs +++ b/src/tools/compiletest/src/directives/auxiliary.rs @@ -7,6 +7,16 @@ use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC use crate::common::Config; use crate::directives::DirectiveLine; +/// The value of an `aux-crate` directive. +#[derive(Clone, Debug, Default)] +pub struct AuxCrate { + /// With `aux-crate: foo=bar.rs` this will be `foo`. + /// With `aux-crate: noprelude:foo=bar.rs` this will be `noprelude:foo`. + pub name: String, + /// With `aux-crate: foo=bar.rs` this will be `bar.rs`. + pub path: String, +} + /// Properties parsed from `aux-*` test directives. #[derive(Clone, Debug, Default)] pub(crate) struct AuxProps { @@ -17,7 +27,7 @@ pub(crate) struct AuxProps { pub(crate) bins: Vec, /// Similar to `builds`, but a list of NAME=somelib.rs of dependencies /// to build and pass with the `--extern` flag. - pub(crate) crates: Vec<(String, String)>, + pub(crate) crates: Vec, /// Same as `builds`, but for proc-macros. pub(crate) proc_macros: Vec, /// Similar to `builds`, but also uses the resulting dylib as a @@ -34,7 +44,7 @@ impl AuxProps { iter::empty() .chain(builds.iter().map(String::as_str)) .chain(bins.iter().map(String::as_str)) - .chain(crates.iter().map(|(_, path)| path.as_str())) + .chain(crates.iter().map(|c| c.path.as_str())) .chain(proc_macros.iter().map(String::as_str)) .chain(codegen_backend.iter().map(String::as_str)) } @@ -63,10 +73,10 @@ pub(super) fn parse_and_update_aux( } } -fn parse_aux_crate(r: String) -> (String, String) { +fn parse_aux_crate(r: String) -> AuxCrate { let mut parts = r.trim().splitn(2, '='); - ( - parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(), - parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(), - ) + AuxCrate { + name: parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(), + path: parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(), + } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 6efdb5a99ee22..901ce8421ebf4 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -18,7 +18,7 @@ use crate::common::{ TestSuite, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name, }; -use crate::directives::TestProps; +use crate::directives::{AuxCrate, TestProps}; use crate::errors::{Error, ErrorKind, load_errors}; use crate::output_capture::ConsoleOut; use crate::read2::{Truncated, read2_abbreviated}; @@ -1285,9 +1285,9 @@ impl<'test> TestCx<'test> { } }; - for (aux_name, aux_path) in &self.props.aux.crates { - let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None); - add_extern(rustc, aux_name, aux_path, aux_type); + for AuxCrate { name, path } in &self.props.aux.crates { + let aux_type = self.build_auxiliary(&path, &aux_dir, None); + add_extern(rustc, name, path, aux_type); } for proc_macro in &self.props.aux.proc_macros {