From 38c2a730170f94dfb458208c36be154ab5412ec7 Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Sat, 25 Nov 2017 14:42:55 -0500 Subject: [PATCH] Testing and fixes --- src/libsyntax/parse/parser.rs | 2 +- .../feature-gate-generic_associated_types.rs | 9 ++++++- .../generic_associated_types_equals.rs | 18 -------------- .../generic_associated_types_equals.stderr | 24 ------------------- .../parse/in-trait-impl.rs | 3 ++- .../parse/in-trait.rs | 9 ++++++- 6 files changed, 19 insertions(+), 46 deletions(-) delete mode 100644 src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.rs delete mode 100644 src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5a20c7f40e6..2a80c0a05bf 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1295,7 +1295,6 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { } else { None }; + self.expect(&token::Semi)?; Ok((generics, TyParam { attrs: preceding_attrs.into(), diff --git a/src/test/compile-fail/feature-gate-generic_associated_types.rs b/src/test/compile-fail/feature-gate-generic_associated_types.rs index a8fc8226f31..e2643bafd38 100644 --- a/src/test/compile-fail/feature-gate-generic_associated_types.rs +++ b/src/test/compile-fail/feature-gate-generic_associated_types.rs @@ -10,8 +10,15 @@ use std::ops::Deref; -trait PointerFamily { +trait PointerFamily { type Pointer: Deref; + type Pointer2: Deref where T: Clone, U: Clone; +} + +struct Foo; +impl PointerFamily for Foo { + type Pointer = Box; + type Pointer2 = Box; } 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 index 6cb2aaf47ae..00000000000 --- a/src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.rs +++ /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 or the MIT license -// , 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; - type X 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 index 152c239d8f7..00000000000 --- a/src/test/ui/rfc1598-generic-associated-types/generic_associated_types_equals.stderr +++ /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 where T = f64; - | ^^^^^^^ - -error[E0412]: cannot find type `T` in this scope - --> $DIR/generic_associated_types_equals.rs:15:21 - | -15 | type X 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; - | ^ - | - = 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 - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/rfc1598-generic-associated-types/parse/in-trait-impl.rs b/src/test/ui/rfc1598-generic-associated-types/parse/in-trait-impl.rs index bb4a285ec71..a7bdadd195d 100644 --- a/src/test/ui/rfc1598-generic-associated-types/parse/in-trait-impl.rs +++ b/src/test/ui/rfc1598-generic-associated-types/parse/in-trait-impl.rs @@ -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 Baz for T where T: Foo { + //FIXME(sunjay): This should parse successfully type Quux<'a> = ::Bar<'a, 'static>; } diff --git a/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs b/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs index 3c3f20b9ff6..fb239fb2a6e 100644 --- a/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs +++ b/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs @@ -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 + Into; + type Bar<'a, 'b, T: Debug, U,> where T: Deref, U: Into; + type Bar<'a, 'b, T: Debug, U,>: Deref + Into + where T: Deref, U: Into; } fn main() {}