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.
13 #![allow(unused_variables)]
14 // Test that we can use `Self` types in impls in the expected way.
16 // pretty-expanded FIXME #23616
18 #![feature(box_syntax)]
22 // Test uses on inherent impl.
24 fn foo(_x: Self, _y: &Self, _z: Box<Self>) -> Self {
29 // Test that Self cannot be shadowed.
31 // There is no empty method on i32.
40 // Test uses when implementing a trait and with a type parameter.
49 trait Bar<X>: SuperBar {
52 fn bar(x: Self, y: &Self, z: Box<Self>, _: Self::SuperQux) -> Self;
53 fn dummy(&self, x: X) { }
56 impl SuperBar for Box<Baz<isize>> {
60 impl Bar<isize> for Box<Baz<isize>> {
63 fn bar(_x: Self, _y: &Self, _z: Box<Self>, _: Self::SuperQux) -> Self {
64 let _: Self::Qux = 42;
65 let _: <Self as Bar<isize>>::Qux = 42;
67 let _: Self::SuperQux = true;
68 let _: <Self as SuperBar>::SuperQux = true;
75 let _: Foo = Foo::foo(Foo, &Foo, box Foo);
76 let _: Box<Baz<isize>> = Bar::bar(box Baz { f: 42 },
78 box box Baz { f: 42 },