about summary refs log tree commit diff
path: root/src/test/compile-fail
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-13 07:44:41 +0000
committerbors <bors@rust-lang.org>2015-02-13 07:44:41 +0000
commitcf636c233dfeef5abf0de8fb35e23c0a161810d2 (patch)
treebb8395a62f97d34f1bfb8fd228e17a44692eef86 /src/test/compile-fail
parentba2efe96aeada34c1e2dc267a1a35948bdda91f8 (diff)
parent8ed58d8cccf61a23d9c97024c41d2fbf4a0f8ecd (diff)
downloadrust-cf636c233dfeef5abf0de8fb35e23c0a161810d2.tar.gz
rust-cf636c233dfeef5abf0de8fb35e23c0a161810d2.zip
Auto merge of #22093 - petrochenkov:builtin, r=pnkfelix
Names of structs, enums, traits, type aliases and type parameters (i.e. all identifiers that can be used as full paths in type position) are not allowed to match the names of primitive types.
See #20427 for more information.

This is a minor [breaking-change]
Diffstat (limited to 'src/test/compile-fail')
-rw-r--r--src/test/compile-fail/issue-20427.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-20427.rs b/src/test/compile-fail/issue-20427.rs
new file mode 100644
index 00000000000..96d4fae8b03
--- /dev/null
+++ b/src/test/compile-fail/issue-20427.rs
@@ -0,0 +1,66 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:i8.rs
+extern crate i8;
+use std::string as i16;
+static i32: i32 = 0;
+const i64: i64 = 0;
+fn u8(f32: f32) {}
+fn f<f64>(f64: f64) {}
+//~^ ERROR user-defined types or type parameters cannot shadow the primitive types
+type u16 = u16; //~ ERROR user-defined types or type parameters cannot shadow the primitive types
+enum u32 {} //~ ERROR user-defined types or type parameters cannot shadow the primitive types
+struct u64; //~ ERROR user-defined types or type parameters cannot shadow the primitive types
+trait bool {} //~ ERROR user-defined types or type parameters cannot shadow the primitive types
+
+mod char {
+    extern crate i8;
+    static i32_: i32 = 0;
+    const i64_: i64 = 0;
+    fn u8_(f32: f32) {}
+    fn f_<f64_>(f64: f64_) {}
+    type u16_ = u16;
+    enum u32_ {}
+    struct u64_;
+    trait bool_ {}
+    mod char_ {}
+
+    mod str {
+        use super::i8 as i8;
+        use super::i32_ as i32;
+        use super::i64_ as i64;
+        use super::u8_ as u8;
+        use super::f_ as f64;
+        use super::u16_ as u16;
+        //~^ ERROR user-defined types or type parameters cannot shadow the primitive types
+        use super::u32_ as u32;
+        //~^ ERROR user-defined types or type parameters cannot shadow the primitive types
+        use super::u64_ as u64;
+        //~^ ERROR user-defined types or type parameters cannot shadow the primitive types
+        use super::bool_ as bool;
+        //~^ ERROR user-defined types or type parameters cannot shadow the primitive types
+        use super::char_ as char;
+    }
+}
+
+trait isize_ {
+    type isize; //~ ERROR user-defined types or type parameters cannot shadow the primitive types
+}
+
+fn usize<'usize>(usize: &'usize usize) -> &'usize usize { usize }
+
+fn main() {
+    let bool = true;
+    match bool {
+        str @ true => if str { i32 as i64 } else { 0 },
+        false => i64,
+    }
+}