]> git.lizzy.rs Git - rust.git/commitdiff
Testing and fixes
authorSunjay Varma <varma.sunjay@gmail.com>
Sat, 25 Nov 2017 19:42:55 +0000 (14:42 -0500)
committerSunjay Varma <varma.sunjay@gmail.com>
Fri, 1 Dec 2017 06:26:29 +0000 (01:26 -0500)
src/libsyntax/parse/parser.rs
src/test/compile-fail/feature-gate-generic_associated_types.rs
src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.rs [deleted file]
src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.stderr [deleted file]
src/test/ui/rfc1598-generic-associated-types/parse/in-trait-impl.rs
src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs

index 5a20c7f40e628447203a684e45610c4ad7df133c..2a80c0a05bfa4072ae2ec846130243345960e1cc 100644 (file)
@@ -1295,7 +1295,6 @@ fn parse_trait_item_(&mut self,
         let (name, node, generics) = if self.eat_keyword(keywords::Type) {
             let (generics, TyParam {ident, bounds, default, ..}) =
                 self.parse_trait_item_assoc_ty(vec![])?;
-            self.expect(&token::Semi)?;
             (ident, TraitItemKind::Type(bounds, default), generics)
         } else if self.is_const_item() {
             self.expect_keyword(keywords::Const)?;
@@ -4464,6 +4463,7 @@ fn parse_trait_item_assoc_ty(&mut self, preceding_attrs: Vec<Attribute>)
         } else {
             None
         };
+        self.expect(&token::Semi)?;
 
         Ok((generics, TyParam {
             attrs: preceding_attrs.into(),
index a8fc8226f316add3a781c529ab648b1e31eb4f3c..e2643bafd389772c00c8eaf12295adf78fc699e4 100644 (file)
 
 use std::ops::Deref;
 
-trait PointerFamily {
+trait PointerFamily<U> {
     type Pointer<T>: Deref<Target = T>;
+    type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
+}
+
+struct Foo;
+impl PointerFamily<u32> for Foo {
+    type Pointer<usize> = Box<usize>;
+    type Pointer2<u32> = Box<u32>;
 }
 
 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
deleted file mode 100644 (file)
index 6cb2aaf..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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() {}
diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.stderr b/src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.stderr
deleted file mode 100644 (file)
index 152c239..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-error: equality constraints are not yet supported in where clauses (#20041)
-  --> $DIR/generic_associated_types_equals.rs:15:21
-   |
-15 |     type X<T> where T = f64;
-   |                     ^^^^^^^
-
-error[E0412]: cannot find type `T` in this scope
-  --> $DIR/generic_associated_types_equals.rs:15:21
-   |
-15 |     type X<T> where T = f64;
-   |                     ^ not found in this scope
-
-error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions.
-  --> $DIR/generic_associated_types_equals.rs:14:14
-   |
-14 |     type Bar<T=usize>;
-   |              ^
-   |
-   = note: #[deny(invalid_type_param_default)] on by default
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
-
-error: aborting due to 3 previous errors
-
index bb4a285ec71ea13ae163af01f23051e3fdef040b..a7bdadd195db34be6dc5e4de92425513b1854915 100644 (file)
@@ -8,11 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// compile-flags: -Zparse-only
+// compile-flags: -Z parse-only
 
 #![feature(generic_associated_types)]
 
 impl<T> Baz for T where T: Foo {
+    //FIXME(sunjay): This should parse successfully
     type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
 }
 
index 3c3f20b9ff60162cf6eb6b2ec182d7632bf3d891..fb239fb2a6e295cfed0ef112090c078245621016 100644 (file)
@@ -8,10 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// compile-flags: -Zparse-only
+// compile-flags: -Z parse-only
 
 #![feature(generic_associated_types)]
 
+use std::ops::Deref;
+
 trait Foo {
     type Bar<'a>;
     type Bar<'a, 'b>;
@@ -20,6 +22,11 @@ trait Foo {
     type Bar<'a, 'b, T, U>;
     type Bar<'a, 'b, T, U,>;
     type Bar<'a, 'b, T: Debug, U,>;
+    type Bar<'a, 'b, T: Debug, U,>: Debug;
+    type Bar<'a, 'b, T: Debug, U,>: Deref<Target = T> + Into<U>;
+    type Bar<'a, 'b, T: Debug, U,> where T: Deref<Target = U>, U: Into<T>;
+    type Bar<'a, 'b, T: Debug, U,>: Deref<Target = T> + Into<U>
+        where T: Deref<Target = U>, U: Into<T>;
 }
 
 fn main() {}