diff options
Diffstat (limited to 'tests/ui/rfcs/rfc-2126-extern-absolute-paths')
11 files changed, 105 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs new file mode 100644 index 000000000..c4d444764 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs @@ -0,0 +1,5 @@ +#[derive(Debug)] +pub struct S; + +#[derive(Debug)] +pub struct Z; diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs new file mode 100644 index 000000000..9c0e0bef4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs @@ -0,0 +1,5 @@ +// edition:2018 + +use xcrate::S; //~ ERROR unresolved import `xcrate` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr new file mode 100644 index 000000000..818915721 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `xcrate` + --> $DIR/non-existent-1.rs:3:5 + | +LL | use xcrate::S; + | ^^^^^^ use of undeclared crate or module `xcrate` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs new file mode 100644 index 000000000..def60feb5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs @@ -0,0 +1,6 @@ +// edition:2018 + +fn main() { + let s = ::xcrate::S; + //~^ ERROR failed to resolve: could not find `xcrate` in the list of imported crates +} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr new file mode 100644 index 000000000..7df4f06d1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: could not find `xcrate` in the list of imported crates + --> $DIR/non-existent-2.rs:4:15 + | +LL | let s = ::xcrate::S; + | ^^^^^^ could not find `xcrate` in the list of imported crates + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs new file mode 100644 index 000000000..486159c0e --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs @@ -0,0 +1,5 @@ +// edition:2018 + +use ycrate; //~ ERROR unresolved import `ycrate` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr new file mode 100644 index 000000000..bd6778cf3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `ycrate` + --> $DIR/non-existent-3.rs:3:5 + | +LL | use ycrate; + | ^^^^^^ no external crate `ycrate` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs new file mode 100644 index 000000000..acb4bbebe --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs @@ -0,0 +1,9 @@ +// edition:2018 + +// Tests that arbitrary crates (other than `core`, `std` and `meta`) +// aren't allowed without `--extern`, even if they're in the sysroot. +use alloc; //~ ERROR unresolved import `alloc` +use test; // OK, imports the built-in attribute macro `#[test]`, but not the `test` crate. +use proc_macro; // OK, imports the built-in `proc_macro` attribute, but not the `proc_macro` crate. + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr new file mode 100644 index 000000000..122e8fd35 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr @@ -0,0 +1,16 @@ +error[E0432]: unresolved import `alloc` + --> $DIR/not-allowed.rs:5:5 + | +LL | use alloc; + | ^^^^^ no external crate `alloc` + | +help: consider importing one of these items instead + | +LL | use core::alloc; + | ~~~~~~~~~~~ +LL | use std::alloc; + | ~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs new file mode 100644 index 000000000..72e50d78b --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs @@ -0,0 +1,11 @@ +// aux-build:xcrate.rs +// compile-flags:--extern xcrate +// edition:2018 + +use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` +use *; //~ ERROR cannot glob-import all possible crates + +fn main() { + let s = ::xcrate; //~ ERROR expected value, found crate `xcrate` + //~^ NOTE not a value +} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr new file mode 100644 index 000000000..253cc1bc5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr @@ -0,0 +1,21 @@ +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/single-segment.rs:5:5 + | +LL | use crate; + | ^^^^^ + +error: cannot glob-import all possible crates + --> $DIR/single-segment.rs:6:5 + | +LL | use *; + | ^ + +error[E0423]: expected value, found crate `xcrate` + --> $DIR/single-segment.rs:9:13 + | +LL | let s = ::xcrate; + | ^^^^^^^^ not a value + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0423`. |