mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add more --extern tests.
This commit is contained in:
parent
b47e3d8fe4
commit
e0058ce994
18
src/test/run-make-fulldeps/extern-flag-pathless/Makefile
Normal file
18
src/test/run-make-fulldeps/extern-flag-pathless/Makefile
Normal file
@ -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");
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
pub fn f() {
|
||||
println!("static");
|
||||
}
|
3
src/test/run-make-fulldeps/extern-flag-pathless/foo.rs
Normal file
3
src/test/run-make-fulldeps/extern-flag-pathless/foo.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
bar::f();
|
||||
}
|
@ -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
|
||||
|
10
src/test/ui-fulldeps/pathless-extern-unstable.rs
Normal file
10
src/test/ui-fulldeps/pathless-extern-unstable.rs
Normal file
@ -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
src/test/ui-fulldeps/pathless-extern-unstable.stderr
Normal file
12
src/test/ui-fulldeps/pathless-extern-unstable.stderr
Normal file
@ -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
src/test/ui/pathless-extern-ok.rs
Normal file
9
src/test/ui/pathless-extern-ok.rs
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user