]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rust-2018/future-proofing-locals.rs
Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor
[rust.git] / src / test / ui / rust-2018 / future-proofing-locals.rs
1 // edition:2018
2
3 #![allow(non_camel_case_types)]
4 #![allow(unused_imports)]
5
6 mod T {
7     pub struct U;
8 }
9 mod x {
10     pub struct y;
11 }
12
13 fn type_param<T>() {
14     use T as _; //~ ERROR imports cannot refer to type parameters
15     use T::U; //~ ERROR imports cannot refer to type parameters
16     use T::*; //~ ERROR imports cannot refer to type parameters
17 }
18
19 fn self_import<T>() {
20     use T; //~ ERROR imports cannot refer to type parameters
21 }
22
23 fn let_binding() {
24     let x = 10;
25
26     use x as _; //~ ERROR imports cannot refer to local variables
27     use x::y; // OK
28     use x::*; // OK
29 }
30
31 fn param_binding(x: u8) {
32     use x; //~ ERROR imports cannot refer to local variables
33 }
34
35 fn match_binding() {
36     match 0 {
37         x => {
38             use x; //~ ERROR imports cannot refer to local variables
39         }
40     }
41 }
42
43 fn nested<T>() {
44     let x = 10;
45
46     use {T as _, x}; //~ ERROR imports cannot refer to type parameters
47                      //~| ERROR imports cannot refer to local variables
48 }
49
50 fn main() {}