Skip to content

Commit e0058ce

Browse files
committed
Add more --extern tests.
1 parent b47e3d8 commit e0058ce

File tree

8 files changed

+59
-1
lines changed

8 files changed

+59
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-include ../tools.mk
2+
3+
# Test mixing pathless --extern with paths.
4+
5+
all:
6+
$(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib
7+
$(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic
8+
# rlib preferred over dylib
9+
$(RUSTC) foo.rs --extern bar
10+
$(call RUN,foo) | $(CGREP) 'static'
11+
$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
12+
$(call RUN,foo) | $(CGREP) 'static'
13+
# explicit --extern overrides pathless
14+
$(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
15+
$(call RUN,foo) | $(CGREP) 'dynamic'
16+
# prefer-dynamic does what it says
17+
$(RUSTC) foo.rs --extern bar -C prefer-dynamic
18+
$(call RUN,foo) | $(CGREP) 'dynamic'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn f() {
2+
println!("dynamic");
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn f() {
2+
println!("static");
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
bar::f();
3+
}

src/test/rustdoc/inline_cross/use_crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// aux-build:use_crate_2.rs
33
// build-aux-docs
44
// edition:2018
5-
// compile-flags:--extern use_crate --extern use_crate_2 -Z unstable-options
5+
// compile-flags:--extern use_crate --extern use_crate_2
66

77
// During the buildup to Rust 2018, rustdoc would eagerly inline `pub use some_crate;` as if it
88
// were a module, so we changed it to make `pub use`ing crate roots remain as a `pub use` statement
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ignore-stage1
2+
// edition:2018
3+
// compile-flags:--extern rustc
4+
5+
// Test that `--extern rustc` fails with `rustc_private`.
6+
7+
pub use rustc;
8+
//~^ use of unstable library feature 'rustc_private'
9+
10+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
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?
2+
--> $DIR/pathless-extern-unstable.rs:7:9
3+
|
4+
LL | pub use rustc;
5+
| ^^^^^
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
8+
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/pathless-extern-ok.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// edition:2018
2+
// compile-flags:--extern alloc
3+
// build-pass
4+
5+
// Test that `--extern alloc` will load from the sysroot without error.
6+
7+
fn main() {
8+
let _: Vec<i32> = alloc::vec::Vec::new();
9+
}

0 commit comments

Comments
 (0)