Skip to content

Commit 60d4e20

Browse files
committed
compiletest: add aux-crate directive
1 parent 590dd7d commit 60d4e20

File tree

11 files changed

+129
-116
lines changed

11 files changed

+129
-116
lines changed

src/test/run-make-fulldeps/extern-flag-noprelude/Makefile

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/test/run-make-fulldeps/extern-flag-noprelude/foo.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/test/rustdoc/issue-66159.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// aux-build:issue-66159-1.rs
1+
// aux-crate:priv:issue_66159_1=issue-66159-1.rs
22
// compile-flags:-Z unstable-options
3-
// extern-private:issue_66159_1
43

54
// The issue was an ICE which meant that we never actually generated the docs
65
// so if we have generated the docs, we're okay.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
// aux-crate:noprelude:somedep=somedep.rs
3+
// compile-flags: -Zunstable-options
4+
// edition:2018
5+
6+
// `extern crate` can be used to add to prelude.
7+
extern crate somedep;
8+
9+
fn main() {
10+
somedep::somefun();
11+
}

src/test/ui/extern-flag/noprelude.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// aux-crate:noprelude:somedep=somedep.rs
2+
// compile-flags: -Zunstable-options
3+
// edition:2018
4+
5+
fn main() {
6+
somedep::somefun(); //~ ERROR failed to resolve
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0433]: failed to resolve: use of undeclared type or module `somedep`
2+
--> $DIR/noprelude.rs:6:5
3+
|
4+
LL | somedep::somefun();
5+
| ^^^^^^^ use of undeclared type or module `somedep`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0433`.

src/test/ui/privacy/pub-priv-dep/pub-priv1.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
// aux-build:priv_dep.rs
1+
// aux-crate:priv:priv_dep=priv_dep.rs
22
// aux-build:pub_dep.rs
3-
// extern-private:priv_dep
43
#![deny(exported_private_dependencies)]
54

65
// This crate is a private dependency
76
extern crate priv_dep;
8-
// This crate is a public dependenct
7+
// This crate is a public dependency
98
extern crate pub_dep;
109

1110
use priv_dep::{OtherType, OtherTrait};

src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
2-
--> $DIR/pub-priv1.rs:21:5
2+
--> $DIR/pub-priv1.rs:20:5
33
|
44
LL | pub field: OtherType,
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
77
note: lint level defined here
8-
--> $DIR/pub-priv1.rs:4:9
8+
--> $DIR/pub-priv1.rs:3:9
99
|
1010
LL | #![deny(exported_private_dependencies)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
14-
--> $DIR/pub-priv1.rs:28:5
14+
--> $DIR/pub-priv1.rs:27:5
1515
|
1616
LL | pub fn pub_fn(param: OtherType) {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface
20-
--> $DIR/pub-priv1.rs:34:1
20+
--> $DIR/pub-priv1.rs:33:1
2121
|
2222
LL | / pub trait MyPubTrait {
2323
LL | | type Foo: OtherTrait;

src/tools/compiletest/src/header.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub struct EarlyProps {
7171
pub ignore: Ignore,
7272
pub should_fail: bool,
7373
pub aux: Vec<String>,
74+
pub aux_crate: Vec<(String, String)>,
7475
pub revisions: Vec<String>,
7576
}
7677

@@ -80,6 +81,7 @@ impl EarlyProps {
8081
ignore: Ignore::Run,
8182
should_fail: false,
8283
aux: Vec::new(),
84+
aux_crate: Vec::new(),
8385
revisions: vec![],
8486
};
8587

@@ -157,6 +159,10 @@ impl EarlyProps {
157159
props.aux.push(s);
158160
}
159161

162+
if let Some(ac) = config.parse_aux_crate(ln) {
163+
props.aux_crate.push(ac);
164+
}
165+
160166
if let Some(r) = config.parse_revisions(ln) {
161167
props.revisions.extend(r);
162168
}
@@ -311,10 +317,9 @@ pub struct TestProps {
311317
// directory as the test, but for backwards compatibility reasons
312318
// we also check the auxiliary directory)
313319
pub aux_builds: Vec<String>,
314-
// A list of crates to pass '--extern priv:name=PATH' flags for
315-
// This should be a subset of 'aux_build'
316-
// FIXME: Replace this with a better solution: https://github.com/rust-lang/rust/pull/54020
317-
pub extern_private: Vec<String>,
320+
// Similar to `aux_builds`, but a list of NAME=somelib.rs of dependencies
321+
// to build and pass with the `--extern` flag.
322+
pub aux_crates: Vec<(String, String)>,
318323
// Environment settings to use for compiling
319324
pub rustc_env: Vec<(String, String)>,
320325
// Environment variables to unset prior to compiling.
@@ -387,7 +392,7 @@ impl TestProps {
387392
run_flags: None,
388393
pp_exact: None,
389394
aux_builds: vec![],
390-
extern_private: vec![],
395+
aux_crates: vec![],
391396
revisions: vec![],
392397
rustc_env: vec![],
393398
unset_rustc_env: vec![],
@@ -514,8 +519,8 @@ impl TestProps {
514519
self.aux_builds.push(ab);
515520
}
516521

517-
if let Some(ep) = config.parse_extern_private(ln) {
518-
self.extern_private.push(ep);
522+
if let Some(ac) = config.parse_aux_crate(ln) {
523+
self.aux_crates.push(ac);
519524
}
520525

521526
if let Some(ee) = config.parse_env(ln, "exec-env") {
@@ -713,8 +718,14 @@ impl Config {
713718
.map(|r| r.trim().to_string())
714719
}
715720

716-
fn parse_extern_private(&self, line: &str) -> Option<String> {
717-
self.parse_name_value_directive(line, "extern-private")
721+
fn parse_aux_crate(&self, line: &str) -> Option<(String, String)> {
722+
self.parse_name_value_directive(line, "aux-crate").map(|r| {
723+
let mut parts = r.trim().splitn(2, '=');
724+
(
725+
parts.next().expect("aux-crate name").to_string(),
726+
parts.next().expect("aux-crate value").to_string(),
727+
)
728+
})
718729
}
719730

720731
fn parse_compile_flags(&self, line: &str) -> Option<String> {

0 commit comments

Comments
 (0)