]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/issue-20427.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / run-pass / issue-20427.rs
CommitLineData
54a0048b 1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
85aaf69f
SL
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
c30ab7b3 12// ignore-pretty issue #37201
54a0048b 13
85aaf69f
SL
14extern crate i8;
15use std::string as i16;
16static i32: i32 = 0;
17const i64: i64 = 0;
18fn u8(f32: f32) {}
19fn f<f64>(f64: f64) {}
54a0048b
SL
20enum u32 {}
21struct u64;
22trait bool {}
85aaf69f
SL
23
24mod char {
25 extern crate i8;
26 static i32_: i32 = 0;
27 const i64_: i64 = 0;
28 fn u8_(f32: f32) {}
29 fn f_<f64_>(f64: f64_) {}
30 type u16_ = u16;
31 enum u32_ {}
32 struct u64_;
33 trait bool_ {}
34 mod char_ {}
35
36 mod str {
37 use super::i8 as i8;
38 use super::i32_ as i32;
39 use super::i64_ as i64;
40 use super::u8_ as u8;
41 use super::f_ as f64;
42 use super::u16_ as u16;
85aaf69f 43 use super::u32_ as u32;
85aaf69f 44 use super::u64_ as u64;
85aaf69f 45 use super::bool_ as bool;
e9174d1e 46 use super::{bool_ as str};
85aaf69f
SL
47 use super::char_ as char;
48 }
49}
50
51trait isize_ {
54a0048b 52 type isize;
85aaf69f
SL
53}
54
55fn usize<'usize>(usize: &'usize usize) -> &'usize usize { usize }
56
54a0048b
SL
57mod reuse {
58 use std::mem::size_of;
59
60 type u8 = u64;
61 use std::string::String as i16;
62
63 pub fn check<u16>() {
64 assert_eq!(size_of::<u8>(), 8);
65 assert_eq!(size_of::<::u64>(), 0);
66 assert_eq!(size_of::<i16>(), 3 * size_of::<*const ()>());
67 assert_eq!(size_of::<u16>(), 0);
68 }
69}
70
71mod guard {
72 pub fn check() {
73 use std::u8; // bring module u8 in scope
74 fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8
75 u8::max_value() // OK, resolves to associated function <u8>::max_value,
76 // not to non-existent std::u8::max_value
77 }
78 assert_eq!(f(), u8::MAX); // OK, resolves to std::u8::MAX
79 }
80}
81
85aaf69f
SL
82fn main() {
83 let bool = true;
54a0048b 84 let _ = match bool {
9cc50fc6 85 str @ true => if str { i32 as i64 } else { i64 },
85aaf69f 86 false => i64,
9cc50fc6 87 };
54a0048b
SL
88
89 reuse::check::<u64>();
90 guard::check();
85aaf69f 91}