Skip to content

Commit 332a3cb

Browse files
committed
More testing for generic associated types parsing
1 parent 83efebc commit 332a3cb

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed
File renamed without changes.

src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ struct Foo<T: StreamingIterator> {
2525

2626
// Users can bound parameters by the type constructed by that trait's associated type constructor
2727
// of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid:
28-
//fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { ... }
28+
//FIXME(sunjay): This next line should parse and be valid
29+
//fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ }
2930
fn foo<T>(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
3031

3132
fn main() {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(generic_associated_types)]
12+
13+
// Checking the interaction with this other feature
14+
#![feature(associated_type_defaults)]
15+
16+
use std::fmt::{Display, Debug};
17+
18+
trait Foo {
19+
type Assoc where Self: Sized;
20+
type Assoc2 <T >where T: Display;
21+
type WithDefault <T> = Iterator <Item=T> where T: Debug;
22+
// No generics on this associated type
23+
type NoGenerics;
24+
}
25+
26+
struct Bar;
27+
28+
impl Foo for Bar {
29+
type Assoc = usize;
30+
type Assoc2 <T> = Vec<T>;
31+
type WithDefault<'a, T> = &'a Iterator<T>;
32+
type NoGenerics = f64;
33+
}
34+
35+
fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(generic_associated_types)]
12+
13+
trait Foo {
14+
type Bar<,>;
15+
}
16+
17+
fn main() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(generic_associated_types)]
12+
13+
trait Foo {
14+
type Bar<T=usize>;
15+
type X<T> where T = f64;
16+
}
17+
18+
fn main() {}

0 commit comments

Comments
 (0)