about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2015-02-01 09:59:46 +0200
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-12-16 17:12:35 +0300
commitb8157cc67fa25f2944b24f4306151d53d1b80b56 (patch)
tree0d9ddf074f25fec3fa9f56fc5c69c118f6dcd3af /src/test
parentce7bc51933e2facb4eca029ac17b398f372f5b41 (diff)
downloadrust-b8157cc67fa25f2944b24f4306151d53d1b80b56.tar.gz
rust-b8157cc67fa25f2944b24f4306151d53d1b80b56.zip
Implement type ascription.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/parse-fail/struct-literal-in-for.rs2
-rw-r--r--src/test/parse-fail/struct-literal-in-if.rs2
-rw-r--r--src/test/parse-fail/struct-literal-in-while.rs2
-rw-r--r--src/test/run-pass/coerce-expect-unsized-ascribed.rs40
4 files changed, 43 insertions, 3 deletions
diff --git a/src/test/parse-fail/struct-literal-in-for.rs b/src/test/parse-fail/struct-literal-in-for.rs
index 8fb71e13f16..107b836d160 100644
--- a/src/test/parse-fail/struct-literal-in-for.rs
+++ b/src/test/parse-fail/struct-literal-in-for.rs
@@ -22,7 +22,7 @@ impl Foo {
 
 fn main() {
     for x in Foo {
-        x: 3    //~ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:`
+        x: 3    //~ ERROR expected type, found `3`
     }.hi() {
         println!("yo");
     }
diff --git a/src/test/parse-fail/struct-literal-in-if.rs b/src/test/parse-fail/struct-literal-in-if.rs
index 1560c83bc70..b1cccc51d7b 100644
--- a/src/test/parse-fail/struct-literal-in-if.rs
+++ b/src/test/parse-fail/struct-literal-in-if.rs
@@ -22,7 +22,7 @@ impl Foo {
 
 fn main() {
     if Foo {
-        x: 3    //~ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:`
+        x: 3    //~ ERROR expected type, found `3`
     }.hi() {
         println!("yo");
     }
diff --git a/src/test/parse-fail/struct-literal-in-while.rs b/src/test/parse-fail/struct-literal-in-while.rs
index 2052193df91..1c52dc48ccd 100644
--- a/src/test/parse-fail/struct-literal-in-while.rs
+++ b/src/test/parse-fail/struct-literal-in-while.rs
@@ -22,7 +22,7 @@ impl Foo {
 
 fn main() {
     while Foo {
-        x: 3    //~ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:`
+        x: 3    //~ ERROR expected type, found `3`
     }.hi() {
         println!("yo");
     }
diff --git a/src/test/run-pass/coerce-expect-unsized-ascribed.rs b/src/test/run-pass/coerce-expect-unsized-ascribed.rs
new file mode 100644
index 00000000000..2b1204483ba
--- /dev/null
+++ b/src/test/run-pass/coerce-expect-unsized-ascribed.rs
@@ -0,0 +1,40 @@
+// Copyright 2014 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.
+
+#![allow(unknown_features)]
+#![feature(box_syntax)]
+
+use std::fmt::Debug;
+
+// A version of coerce-expect-unsized that uses type ascription.
+
+pub fn main() {
+    let _ = box { [1, 2, 3] }: Box<[int]>;
+    let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[int]>;
+    let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[int]>;
+    let _ = box { |x| (x as u8) }: Box<Fn(int) -> _>;
+    let _ = box if true { false } else { true }: Box<Debug>;
+    let _ = box match true { true => 'a', false => 'b' }: Box<Debug>;
+
+    let _ = &{ [1, 2, 3] }: &[int];
+    let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[int];
+    let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[int];
+    let _ = &{ |x| (x as u8) }: &Fn(int) -> _;
+    let _ = &if true { false } else { true }: &Debug;
+    let _ = &match true { true => 'a', false => 'b' }: &Debug;
+
+    let _ = Box::new([1, 2, 3]): Box<[int]>;
+    let _ = Box::new(|x| (x as u8)): Box<Fn(int) -> _>;
+
+    let _ = vec![
+        Box::new(|x| (x as u8)),
+        box |x| (x as i16 as u8),
+    ]: Vec<Box<Fn(int) -> _>>;
+}