about summary refs log tree commit diff
path: root/src/test/parse-fail
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2015-12-18 14:38:28 -0800
committerAaron Turon <aturon@mozilla.com>2016-03-14 15:04:33 -0700
commit8fe63e23421f66b730afdbd14c3ec90e39950288 (patch)
tree6b1fcefd268964fede314d9d915593c1b57bfaf1 /src/test/parse-fail
parent659ba09b2d9dfe1c9ae50d86ab87fc9acb55a03e (diff)
downloadrust-8fe63e23421f66b730afdbd14c3ec90e39950288.tar.gz
rust-8fe63e23421f66b730afdbd14c3ec90e39950288.zip
Add `default` as contextual keyword, and parse it for impl items.
Diffstat (limited to 'src/test/parse-fail')
-rw-r--r--src/test/parse-fail/default.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/parse-fail/default.rs b/src/test/parse-fail/default.rs
new file mode 100644
index 00000000000..d18401e6764
--- /dev/null
+++ b/src/test/parse-fail/default.rs
@@ -0,0 +1,35 @@
+// 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.
+
+// compile-flags: -Z parse-only
+
+// Test successful and unsucessful parsing of the `default` contextual keyword
+
+trait Foo {
+    fn foo<T: Default>() -> T;
+}
+
+impl Foo for u8 {
+    default fn foo<T: Default>() -> T {
+        T::default()
+    }
+}
+
+impl Foo for u16 {
+    pub default fn foo<T: Default>() -> T {
+        T::default()
+    }
+}
+
+impl Foo for u32 {
+    default pub fn foo<T: Default>() -> T { T::default() } //~ ERROR expected one of
+}
+
+fn main() {}