diff options
Diffstat (limited to 'src/test/ui/crate-loading')
17 files changed, 163 insertions, 0 deletions
diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs new file mode 100644 index 000000000..a00a19e46 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-1 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 10 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs new file mode 100644 index 000000000..71cc0a12e --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-2 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 20 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs new file mode 100644 index 000000000..921687d4c --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-3 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 30 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve2-1.rs b/src/test/ui/crate-loading/auxiliary/crateresolve2-1.rs new file mode 100644 index 000000000..e9459ed07 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve2-1.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-1 --emit=metadata +#![crate_name = "crateresolve2"] +#![crate_type = "lib"] + +pub fn f() -> isize { 10 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve2-2.rs b/src/test/ui/crate-loading/auxiliary/crateresolve2-2.rs new file mode 100644 index 000000000..c45416827 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve2-2.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-2 --emit=metadata +#![crate_name = "crateresolve2"] +#![crate_type = "lib"] + +pub fn f() -> isize { 20 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve2-3.rs b/src/test/ui/crate-loading/auxiliary/crateresolve2-3.rs new file mode 100644 index 000000000..b356db4b6 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve2-3.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-3 --emit=metadata +#![crate_name = "crateresolve2"] +#![crate_type = "lib"] + +pub fn f() -> isize { 30 } diff --git a/src/test/ui/crate-loading/auxiliary/libfoo.rlib b/src/test/ui/crate-loading/auxiliary/libfoo.rlib new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/libfoo.rlib diff --git a/src/test/ui/crate-loading/auxiliary/proc-macro.rs b/src/test/ui/crate-loading/auxiliary/proc-macro.rs new file mode 100644 index 000000000..52631de57 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/proc-macro.rs @@ -0,0 +1,12 @@ +// force-host +// no-prefer-dynamic +#![crate_name = "reproduction"] +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro] +pub fn mac(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui/crate-loading/crateresolve1.rs b/src/test/ui/crate-loading/crateresolve1.rs new file mode 100644 index 000000000..f4795e953 --- /dev/null +++ b/src/test/ui/crate-loading/crateresolve1.rs @@ -0,0 +1,15 @@ +// aux-build:crateresolve1-1.rs +// aux-build:crateresolve1-2.rs +// aux-build:crateresolve1-3.rs + +// normalize-stderr-test: "\.nll/" -> "/" +// normalize-stderr-test: "\\\?\\" -> "" +// normalize-stderr-test: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib" + +// NOTE: This test is duplicated at `src/test/ui/error-codes/E0464.rs`. + +extern crate crateresolve1; +//~^ ERROR multiple matching crates for `crateresolve1` + +fn main() { +} diff --git a/src/test/ui/crate-loading/crateresolve1.stderr b/src/test/ui/crate-loading/crateresolve1.stderr new file mode 100644 index 000000000..0d7538eaf --- /dev/null +++ b/src/test/ui/crate-loading/crateresolve1.stderr @@ -0,0 +1,14 @@ +error[E0464]: multiple matching crates for `crateresolve1` + --> $DIR/crateresolve1.rs:11:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidates: + crate `crateresolve1`: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-1.somelib + crate `crateresolve1`: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-2.somelib + crate `crateresolve1`: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-3.somelib + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0464`. diff --git a/src/test/ui/crate-loading/crateresolve2.rs b/src/test/ui/crate-loading/crateresolve2.rs new file mode 100644 index 000000000..5a4fee7ed --- /dev/null +++ b/src/test/ui/crate-loading/crateresolve2.rs @@ -0,0 +1,14 @@ +// check-fail + +// aux-build:crateresolve2-1.rs +// aux-build:crateresolve2-2.rs +// aux-build:crateresolve2-3.rs + +// normalize-stderr-test: "\.nll/" -> "/" +// normalize-stderr-test: "\\\?\\" -> "" + +extern crate crateresolve2; +//~^ ERROR multiple matching crates for `crateresolve2` + +fn main() { +} diff --git a/src/test/ui/crate-loading/crateresolve2.stderr b/src/test/ui/crate-loading/crateresolve2.stderr new file mode 100644 index 000000000..afd3702de --- /dev/null +++ b/src/test/ui/crate-loading/crateresolve2.stderr @@ -0,0 +1,14 @@ +error[E0464]: multiple matching crates for `crateresolve2` + --> $DIR/crateresolve2.rs:10:1 + | +LL | extern crate crateresolve2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidates: + crate `crateresolve2`: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-1.rmeta + crate `crateresolve2`: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-2.rmeta + crate `crateresolve2`: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-3.rmeta + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0464`. diff --git a/src/test/ui/crate-loading/cross-compiled-proc-macro.rs b/src/test/ui/crate-loading/cross-compiled-proc-macro.rs new file mode 100644 index 000000000..c1f433143 --- /dev/null +++ b/src/test/ui/crate-loading/cross-compiled-proc-macro.rs @@ -0,0 +1,8 @@ +// edition:2018 +// compile-flags:--extern reproduction +// aux-build:proc-macro.rs +// check-pass + +reproduction::mac!(); + +fn main() {} diff --git a/src/test/ui/crate-loading/invalid-rlib.rs b/src/test/ui/crate-loading/invalid-rlib.rs new file mode 100644 index 000000000..aea861e32 --- /dev/null +++ b/src/test/ui/crate-loading/invalid-rlib.rs @@ -0,0 +1,10 @@ +// compile-flags: --crate-type lib --extern foo={{src-base}}/crate-loading/auxiliary/libfoo.rlib +// normalize-stderr-test: "failed to mmap file '.*auxiliary/libfoo.rlib':.*" -> "failed to mmap file 'auxiliary/libfoo.rlib'" +// don't emit warn logging, it's basically the same as the errors and it's annoying to normalize +// rustc-env:RUSTC_LOG=error +// edition:2018 +#![no_std] +use ::foo; //~ ERROR invalid metadata files for crate `foo` +//~| NOTE failed to mmap file +//~^^ ERROR invalid metadata files for crate `foo` +//~| NOTE failed to mmap file diff --git a/src/test/ui/crate-loading/invalid-rlib.stderr b/src/test/ui/crate-loading/invalid-rlib.stderr new file mode 100644 index 000000000..3c0d23bf7 --- /dev/null +++ b/src/test/ui/crate-loading/invalid-rlib.stderr @@ -0,0 +1,19 @@ +error[E0786]: found invalid metadata files for crate `foo` + --> $DIR/invalid-rlib.rs:7:7 + | +LL | use ::foo; + | ^^^ + | + = note: failed to mmap file 'auxiliary/libfoo.rlib' + +error[E0786]: found invalid metadata files for crate `foo` + --> $DIR/invalid-rlib.rs:7:7 + | +LL | use ::foo; + | ^^^ + | + = note: failed to mmap file 'auxiliary/libfoo.rlib' + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0786`. diff --git a/src/test/ui/crate-loading/missing-std.rs b/src/test/ui/crate-loading/missing-std.rs new file mode 100644 index 000000000..400d9f6e0 --- /dev/null +++ b/src/test/ui/crate-loading/missing-std.rs @@ -0,0 +1,12 @@ +// compile-flags: --target x86_64-unknown-uefi +// needs-llvm-components: x86 +// rustc-env:CARGO=/usr/bin/cargo +#![feature(no_core)] +#![no_core] +extern crate core; +//~^ ERROR can't find crate for `core` +//~| NOTE can't find crate +//~| NOTE target may not be installed +//~| HELP consider building the standard library from source with `cargo build -Zbuild-std` +//~| HELP consider downloading the target with `rustup target add x86_64-unknown-uefi` +fn main() {} diff --git a/src/test/ui/crate-loading/missing-std.stderr b/src/test/ui/crate-loading/missing-std.stderr new file mode 100644 index 000000000..70bcae1e0 --- /dev/null +++ b/src/test/ui/crate-loading/missing-std.stderr @@ -0,0 +1,15 @@ +error[E0463]: can't find crate for `core` + --> $DIR/missing-std.rs:6:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ can't find crate + | + = note: the `x86_64-unknown-uefi` target may not be installed + = help: consider downloading the target with `rustup target add x86_64-unknown-uefi` + = help: consider building the standard library from source with `cargo build -Zbuild-std` + +error: requires `sized` lang_item + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0463`. |