]> git.lizzy.rs Git - rust.git/commitdiff
More testing for generic associated types parsing
authorSunjay Varma <varma.sunjay@gmail.com>
Fri, 10 Nov 2017 03:42:29 +0000 (22:42 -0500)
committerSunjay Varma <varma.sunjay@gmail.com>
Fri, 1 Dec 2017 06:26:29 +0000 (01:26 -0500)
src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs [new file with mode: 0644]
src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs
src/test/run-pass/rfc1598-generic-associated-types/where.rs [deleted file]
src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs [new file with mode: 0644]
src/test/ui/rfc1598-generic-associated-types/empty_generics.rs [new file with mode: 0644]
src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.rs [new file with mode: 0644]

diff --git a/src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs b/src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs
new file mode 100644 (file)
index 0000000..269e5dc
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2012 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.
+
+#![feature(generic_associated_types)]
+
+// Checking the interaction with this other feature
+#![feature(associated_type_defaults)]
+
+use std::fmt::{Display, Debug};
+
+trait Foo {
+    type Assoc where Self: Sized;
+    type Assoc2<T> where T: Display;
+    type WithDefault<T> = Iterator<Item=T> where T: Debug;
+}
+
+struct Bar;
+
+impl Foo for Bar {
+    type Assoc = usize;
+    type Assoc2<T> = Vec<T>;
+    type WithDefault<'a, T> = &'a Iterator<T>;
+}
+
+fn main() {}
index fd476e2592dc4e08ab66cbab1bebf30f775098c3..58ec14d10756eef9679f182677db07182ffb81da 100644 (file)
@@ -25,7 +25,8 @@ struct Foo<T: StreamingIterator> {
 
 // Users can bound parameters by the type constructed by that trait's associated type constructor
 // of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid:
-//fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { ... }
+//FIXME(sunjay): This next line should parse and be valid
+//fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ }
 fn foo<T>(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
 
 fn main() {}
diff --git a/src/test/run-pass/rfc1598-generic-associated-types/where.rs b/src/test/run-pass/rfc1598-generic-associated-types/where.rs
deleted file mode 100644 (file)
index 269e5dc..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2012 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.
-
-#![feature(generic_associated_types)]
-
-// Checking the interaction with this other feature
-#![feature(associated_type_defaults)]
-
-use std::fmt::{Display, Debug};
-
-trait Foo {
-    type Assoc where Self: Sized;
-    type Assoc2<T> where T: Display;
-    type WithDefault<T> = Iterator<Item=T> where T: Debug;
-}
-
-struct Bar;
-
-impl Foo for Bar {
-    type Assoc = usize;
-    type Assoc2<T> = Vec<T>;
-    type WithDefault<'a, T> = &'a Iterator<T>;
-}
-
-fn main() {}
diff --git a/src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs b/src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs
new file mode 100644 (file)
index 0000000..892a925
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2012 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.
+
+#![feature(generic_associated_types)]
+
+// Checking the interaction with this other feature
+#![feature(associated_type_defaults)]
+
+use std::fmt::{Display, Debug};
+
+trait Foo {
+    type Assoc where Self: Sized;
+    type Assoc2 <T >where T: Display;
+    type WithDefault <T> = Iterator <Item=T> where T: Debug;
+    // No generics on this associated type
+    type NoGenerics;
+}
+
+struct Bar;
+
+impl Foo for Bar {
+    type Assoc = usize;
+    type Assoc2 <T> = Vec<T>;
+    type WithDefault<'a, T> = &'a Iterator<T>;
+    type NoGenerics = f64;
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc1598-generic-associated-types/empty_generics.rs b/src/test/ui/rfc1598-generic-associated-types/empty_generics.rs
new file mode 100644 (file)
index 0000000..a80875d
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2017 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.
+
+#![feature(generic_associated_types)]
+
+trait Foo {
+    type Bar<,>;
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.rs b/src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.rs
new file mode 100644 (file)
index 0000000..6cb2aaf
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2017 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.
+
+#![feature(generic_associated_types)]
+
+trait Foo {
+    type Bar<T=usize>;
+    type X<T> where T = f64;
+}
+
+fn main() {}