Skip to content

Commit

Permalink
Add more --extern tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Nov 7, 2019
1 parent b47e3d8 commit e0058ce
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/test/run-make-fulldeps/extern-flag-pathless/Makefile
@@ -0,0 +1,18 @@
-include ../tools.mk

# Test mixing pathless --extern with paths.

all:
$(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib
$(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic
# rlib preferred over dylib
$(RUSTC) foo.rs --extern bar
$(call RUN,foo) | $(CGREP) 'static'
$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
$(call RUN,foo) | $(CGREP) 'static'
# explicit --extern overrides pathless
$(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
$(call RUN,foo) | $(CGREP) 'dynamic'
# prefer-dynamic does what it says
$(RUSTC) foo.rs --extern bar -C prefer-dynamic
$(call RUN,foo) | $(CGREP) 'dynamic'
@@ -0,0 +1,3 @@
pub fn f() {
println!("dynamic");
}
3 changes: 3 additions & 0 deletions src/test/run-make-fulldeps/extern-flag-pathless/bar-static.rs
@@ -0,0 +1,3 @@
pub fn f() {
println!("static");
}
3 changes: 3 additions & 0 deletions src/test/run-make-fulldeps/extern-flag-pathless/foo.rs
@@ -0,0 +1,3 @@
fn main() {
bar::f();
}
2 changes: 1 addition & 1 deletion src/test/rustdoc/inline_cross/use_crate.rs
Expand Up @@ -2,7 +2,7 @@
// aux-build:use_crate_2.rs
// build-aux-docs
// edition:2018
// compile-flags:--extern use_crate --extern use_crate_2 -Z unstable-options
// compile-flags:--extern use_crate --extern use_crate_2

// During the buildup to Rust 2018, rustdoc would eagerly inline `pub use some_crate;` as if it
// were a module, so we changed it to make `pub use`ing crate roots remain as a `pub use` statement
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui-fulldeps/pathless-extern-unstable.rs
@@ -0,0 +1,10 @@
// ignore-stage1
// edition:2018
// compile-flags:--extern rustc

// Test that `--extern rustc` fails with `rustc_private`.

pub use rustc;
//~^ use of unstable library feature 'rustc_private'

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui-fulldeps/pathless-extern-unstable.stderr
@@ -0,0 +1,12 @@
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
--> $DIR/pathless-extern-unstable.rs:7:9
|
LL | pub use rustc;
| ^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
= help: add `#![feature(rustc_private)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
9 changes: 9 additions & 0 deletions src/test/ui/pathless-extern-ok.rs
@@ -0,0 +1,9 @@
// edition:2018
// compile-flags:--extern alloc
// build-pass

// Test that `--extern alloc` will load from the sysroot without error.

fn main() {
let _: Vec<i32> = alloc::vec::Vec::new();
}

0 comments on commit e0058ce

Please sign in to comment.