diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-11-17 20:00:00 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-11-18 13:58:39 +0300 |
| commit | a5f9bd02b1c6e0e2c3ae5e207bf24db2e6d2e42b (patch) | |
| tree | 843f3750344173e193b870502d921398ab5b3e3d /src/test | |
| parent | 4fc3c13e326e16e378910352fd243a84a0406a53 (diff) | |
| download | rust-a5f9bd02b1c6e0e2c3ae5e207bf24db2e6d2e42b.tar.gz rust-a5f9bd02b1c6e0e2c3ae5e207bf24db2e6d2e42b.zip | |
resolve: Future-proof against imports referring to local variables and generic parameters
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/rust-2018/future-proofing-locals.rs | 49 | ||||
| -rw-r--r-- | src/test/ui/rust-2018/future-proofing-locals.stderr | 50 |
2 files changed, 99 insertions, 0 deletions
diff --git a/src/test/ui/rust-2018/future-proofing-locals.rs b/src/test/ui/rust-2018/future-proofing-locals.rs new file mode 100644 index 00000000000..d2e6dbbb954 --- /dev/null +++ b/src/test/ui/rust-2018/future-proofing-locals.rs @@ -0,0 +1,49 @@ +// edition:2018 + +#![feature(uniform_paths, underscore_imports)] + +mod T { + pub struct U; +} +mod x { + pub struct y; +} + +fn type_param<T>() { + use T as _; //~ ERROR imports cannot refer to type parameters + use T::U; //~ ERROR imports cannot refer to type parameters + use T::*; //~ ERROR imports cannot refer to type parameters +} + +fn self_import<T>() { + use T; // FIXME Should be an error, but future-proofing fails due to `T` being "self-shadowed" +} + +fn let_binding() { + let x = 10; + + use x as _; //~ ERROR imports cannot refer to local variables + use x::y; // OK + use x::*; // OK +} + +fn param_binding(x: u8) { + use x; //~ ERROR imports cannot refer to local variables +} + +fn match_binding() { + match 0 { + x => { + use x; //~ ERROR imports cannot refer to local variables + } + } +} + +fn nested<T>() { + let x = 10; + + use {T as _, x}; //~ ERROR imports cannot refer to type parameters + //~| ERROR imports cannot refer to local variables +} + +fn main() {} diff --git a/src/test/ui/rust-2018/future-proofing-locals.stderr b/src/test/ui/rust-2018/future-proofing-locals.stderr new file mode 100644 index 00000000000..68354b332a9 --- /dev/null +++ b/src/test/ui/rust-2018/future-proofing-locals.stderr @@ -0,0 +1,50 @@ +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:13:9 + | +LL | use T as _; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:14:9 + | +LL | use T::U; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:15:9 + | +LL | use T::*; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:25:9 + | +LL | use x as _; //~ ERROR imports cannot refer to local variables + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:31:9 + | +LL | use x; //~ ERROR imports cannot refer to local variables + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:37:17 + | +LL | use x; //~ ERROR imports cannot refer to local variables + | ^ + +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:45:10 + | +LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:45:18 + | +LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters + | ^ + +error: aborting due to 8 previous errors + |
