]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-20427.rs
Lift the restriction on reusing names of primitive types
[rust.git] / src / test / run-pass / issue-20427.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // aux-build:i8.rs
12 extern crate i8;
13 use std::string as i16;
14 static i32: i32 = 0;
15 const i64: i64 = 0;
16 fn u8(f32: f32) {}
17 fn f<f64>(f64: f64) {}
18 enum u32 {}
19 struct u64;
20 trait bool {}
21
22 mod char {
23     extern crate i8;
24     static i32_: i32 = 0;
25     const i64_: i64 = 0;
26     fn u8_(f32: f32) {}
27     fn f_<f64_>(f64: f64_) {}
28     type u16_ = u16;
29     enum u32_ {}
30     struct u64_;
31     trait bool_ {}
32     mod char_ {}
33
34     mod str {
35         use super::i8 as i8;
36         use super::i32_ as i32;
37         use super::i64_ as i64;
38         use super::u8_ as u8;
39         use super::f_ as f64;
40         use super::u16_ as u16;
41         use super::u32_ as u32;
42         use super::u64_ as u64;
43         use super::bool_ as bool;
44         use super::{bool_ as str};
45         use super::char_ as char;
46     }
47 }
48
49 trait isize_ {
50     type isize;
51 }
52
53 fn usize<'usize>(usize: &'usize usize) -> &'usize usize { usize }
54
55 mod reuse {
56     use std::mem::size_of;
57
58     type u8 = u64;
59     use std::string::String as i16;
60
61     pub fn check<u16>() {
62         assert_eq!(size_of::<u8>(), 8);
63         assert_eq!(size_of::<::u64>(), 0);
64         assert_eq!(size_of::<i16>(), 3 * size_of::<*const ()>());
65         assert_eq!(size_of::<u16>(), 0);
66     }
67 }
68
69 fn main() {
70     let bool = true;
71     let _ = match bool {
72         str @ true => if str { i32 as i64 } else { i64 },
73         false => i64,
74     };
75
76     reuse::check::<u64>();
77 }