]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc1598-generic-associated-types/pointer_family.rs
tests: prefer edition: directives to compile-flags:--edition.
[rust.git] / src / test / ui / rfc1598-generic-associated-types / pointer_family.rs
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 //FIXME(#44265): "type parameter not allowed" errors will be addressed in a follow-up PR
14
15 use std::rc::Rc;
16 use std::sync::Arc;
17 use std::ops::Deref;
18
19 trait PointerFamily {
20     type Pointer<T>: Deref<Target = T>;
21     fn new<T>(value: T) -> Self::Pointer<T>;
22     //~^ ERROR type parameters are not allowed on this type [E0109]
23 }
24
25 struct ArcFamily;
26
27 impl PointerFamily for ArcFamily {
28     type Pointer<T> = Arc<T>;
29     fn new<T>(value: T) -> Self::Pointer<T> {
30     //~^ ERROR type parameters are not allowed on this type [E0109]
31         Arc::new(value)
32     }
33 }
34
35 struct RcFamily;
36
37 impl PointerFamily for RcFamily {
38     type Pointer<T> = Rc<T>;
39     fn new<T>(value: T) -> Self::Pointer<T> {
40     //~^ ERROR type parameters are not allowed on this type [E0109]
41         Rc::new(value)
42     }
43 }
44
45 struct Foo<P: PointerFamily> {
46     bar: P::Pointer<String>,
47     //~^ ERROR type parameters are not allowed on this type [E0109]
48 }
49
50 fn main() {}