1 // Copyright 2014 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.
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.
11 // Test that we can use `Self` types in impls in the expected way.
13 // pretty-expanded FIXME #23616
15 #![allow(unknown_features)]
16 #![feature(box_syntax)]
20 // Test uses on inherent impl.
22 fn foo(_x: Self, _y: &Self, _z: Box<Self>) -> Self {
27 // Test that Self cannot be shadowed.
29 // There is no empty method on i32.
38 // Test uses when implementing a trait and with a type parameter.
47 trait Bar<X>: SuperBar {
50 fn bar(x: Self, y: &Self, z: Box<Self>, _: Self::SuperQux) -> Self;
51 fn dummy(&self, x: X) { }
54 impl SuperBar for Box<Baz<isize>> {
58 impl Bar<isize> for Box<Baz<isize>> {
61 fn bar(_x: Self, _y: &Self, _z: Box<Self>, _: Self::SuperQux) -> Self {
62 let _: Self::Qux = 42;
63 let _: <Self as Bar<isize>>::Qux = 42;
65 let _: Self::SuperQux = true;
66 let _: <Self as SuperBar>::SuperQux = true;
73 let _: Foo = Foo::foo(Foo, &Foo, box Foo);
74 let _: Box<Baz<isize>> = Bar::bar(box Baz { f: 42 },
76 box box Baz { f: 42 },