diff options
| author | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-05 09:13:28 +0100 |
|---|---|---|
| committer | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-11 09:32:08 +0000 |
| commit | cf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch) | |
| tree | 40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/crate-loading | |
| parent | ca855e6e42787ecd062d81d53336fe6788ef51a9 (diff) | |
| download | rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip | |
Move /src/test to /tests
Diffstat (limited to 'tests/ui/crate-loading')
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/crateresolve1-1.rs | 6 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/crateresolve1-2.rs | 6 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/crateresolve1-3.rs | 6 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/crateresolve2-1.rs | 5 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/crateresolve2-2.rs | 5 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/crateresolve2-3.rs | 5 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/libfoo.rlib | 0 | ||||
| -rw-r--r-- | tests/ui/crate-loading/auxiliary/proc-macro.rs | 12 | ||||
| -rw-r--r-- | tests/ui/crate-loading/crateresolve1.rs | 14 | ||||
| -rw-r--r-- | tests/ui/crate-loading/crateresolve1.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/crate-loading/crateresolve2.rs | 13 | ||||
| -rw-r--r-- | tests/ui/crate-loading/crateresolve2.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/crate-loading/cross-compiled-proc-macro.rs | 8 | ||||
| -rw-r--r-- | tests/ui/crate-loading/invalid-rlib.rs | 10 | ||||
| -rw-r--r-- | tests/ui/crate-loading/invalid-rlib.stderr | 19 | ||||
| -rw-r--r-- | tests/ui/crate-loading/missing-std.rs | 12 | ||||
| -rw-r--r-- | tests/ui/crate-loading/missing-std.stderr | 15 |
17 files changed, 162 insertions, 0 deletions
diff --git a/tests/ui/crate-loading/auxiliary/crateresolve1-1.rs b/tests/ui/crate-loading/auxiliary/crateresolve1-1.rs new file mode 100644 index 00000000000..bd9c8483ec2 --- /dev/null +++ b/tests/ui/crate-loading/auxiliary/crateresolve1-1.rs @@ -0,0 +1,6 @@ +// compile-flags:-C extra-filename=-1 +// no-prefer-dynamic +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 10 } diff --git a/tests/ui/crate-loading/auxiliary/crateresolve1-2.rs b/tests/ui/crate-loading/auxiliary/crateresolve1-2.rs new file mode 100644 index 00000000000..bd0f08f45b6 --- /dev/null +++ b/tests/ui/crate-loading/auxiliary/crateresolve1-2.rs @@ -0,0 +1,6 @@ +// compile-flags:-C extra-filename=-2 +// no-prefer-dynamic +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 20 } diff --git a/tests/ui/crate-loading/auxiliary/crateresolve1-3.rs b/tests/ui/crate-loading/auxiliary/crateresolve1-3.rs new file mode 100644 index 00000000000..1226c2fbb46 --- /dev/null +++ b/tests/ui/crate-loading/auxiliary/crateresolve1-3.rs @@ -0,0 +1,6 @@ +// compile-flags:-C extra-filename=-3 +// no-prefer-dynamic +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 30 } diff --git a/tests/ui/crate-loading/auxiliary/crateresolve2-1.rs b/tests/ui/crate-loading/auxiliary/crateresolve2-1.rs new file mode 100644 index 00000000000..e9459ed0719 --- /dev/null +++ b/tests/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/tests/ui/crate-loading/auxiliary/crateresolve2-2.rs b/tests/ui/crate-loading/auxiliary/crateresolve2-2.rs new file mode 100644 index 00000000000..c4541682723 --- /dev/null +++ b/tests/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/tests/ui/crate-loading/auxiliary/crateresolve2-3.rs b/tests/ui/crate-loading/auxiliary/crateresolve2-3.rs new file mode 100644 index 00000000000..b356db4b6fc --- /dev/null +++ b/tests/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/tests/ui/crate-loading/auxiliary/libfoo.rlib b/tests/ui/crate-loading/auxiliary/libfoo.rlib new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tests/ui/crate-loading/auxiliary/libfoo.rlib diff --git a/tests/ui/crate-loading/auxiliary/proc-macro.rs b/tests/ui/crate-loading/auxiliary/proc-macro.rs new file mode 100644 index 00000000000..52631de5757 --- /dev/null +++ b/tests/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/tests/ui/crate-loading/crateresolve1.rs b/tests/ui/crate-loading/crateresolve1.rs new file mode 100644 index 00000000000..f5477f244dd --- /dev/null +++ b/tests/ui/crate-loading/crateresolve1.rs @@ -0,0 +1,14 @@ +// 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 candidates for `rlib` dependency `crateresolve1` found + +fn main() {} diff --git a/tests/ui/crate-loading/crateresolve1.stderr b/tests/ui/crate-loading/crateresolve1.stderr new file mode 100644 index 00000000000..7b840b52628 --- /dev/null +++ b/tests/ui/crate-loading/crateresolve1.stderr @@ -0,0 +1,13 @@ +error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found + --> $DIR/crateresolve1.rs:11:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidate #1: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-1.somelib + = note: candidate #2: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-2.somelib + = note: candidate #3: $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/tests/ui/crate-loading/crateresolve2.rs b/tests/ui/crate-loading/crateresolve2.rs new file mode 100644 index 00000000000..0774c0dfd32 --- /dev/null +++ b/tests/ui/crate-loading/crateresolve2.rs @@ -0,0 +1,13 @@ +// 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 candidates for `rmeta` dependency `crateresolve2` found + +fn main() {} diff --git a/tests/ui/crate-loading/crateresolve2.stderr b/tests/ui/crate-loading/crateresolve2.stderr new file mode 100644 index 00000000000..a36f4f02265 --- /dev/null +++ b/tests/ui/crate-loading/crateresolve2.stderr @@ -0,0 +1,13 @@ +error[E0464]: multiple candidates for `rmeta` dependency `crateresolve2` found + --> $DIR/crateresolve2.rs:10:1 + | +LL | extern crate crateresolve2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidate #1: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-1.rmeta + = note: candidate #2: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-2.rmeta + = note: candidate #3: $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/tests/ui/crate-loading/cross-compiled-proc-macro.rs b/tests/ui/crate-loading/cross-compiled-proc-macro.rs new file mode 100644 index 00000000000..c1f4331438e --- /dev/null +++ b/tests/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/tests/ui/crate-loading/invalid-rlib.rs b/tests/ui/crate-loading/invalid-rlib.rs new file mode 100644 index 00000000000..aea861e3261 --- /dev/null +++ b/tests/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/tests/ui/crate-loading/invalid-rlib.stderr b/tests/ui/crate-loading/invalid-rlib.stderr new file mode 100644 index 00000000000..3c0d23bf7b4 --- /dev/null +++ b/tests/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/tests/ui/crate-loading/missing-std.rs b/tests/ui/crate-loading/missing-std.rs new file mode 100644 index 00000000000..400d9f6e0ba --- /dev/null +++ b/tests/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/tests/ui/crate-loading/missing-std.stderr b/tests/ui/crate-loading/missing-std.stderr new file mode 100644 index 00000000000..70bcae1e0ed --- /dev/null +++ b/tests/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`. |
