2015-01-07 18:53:58 -08:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
2014-05-06 16:37:32 -07:00
|
|
|
struct Foo {
|
2015-01-08 21:54:35 +11:00
|
|
|
f: isize,
|
2014-05-06 16:37:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo {
|
2017-11-07 05:16:24 -05:00
|
|
|
fn foo(self: isize, x: isize) -> isize {
|
2019-09-02 18:21:58 -07:00
|
|
|
//~^ ERROR invalid `self` parameter type
|
2014-05-06 16:37:32 -07:00
|
|
|
self.f + x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar<T> {
|
|
|
|
f: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Bar<T> {
|
2017-11-07 05:16:24 -05:00
|
|
|
fn foo(self: Bar<isize>, x: isize) -> isize {
|
2019-09-02 18:21:58 -07:00
|
|
|
//~^ ERROR invalid `self` parameter type
|
2014-05-06 16:37:32 -07:00
|
|
|
x
|
|
|
|
}
|
2017-11-07 05:16:24 -05:00
|
|
|
fn bar(self: &Bar<usize>, x: isize) -> isize {
|
2019-09-02 18:21:58 -07:00
|
|
|
//~^ ERROR invalid `self` parameter type
|
2014-05-06 16:37:32 -07:00
|
|
|
x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-15 16:58:09 -05:00
|
|
|
trait SomeTrait {
|
|
|
|
fn dummy1(&self);
|
|
|
|
fn dummy2(&self);
|
|
|
|
fn dummy3(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, T> SomeTrait for &'a Bar<T> {
|
|
|
|
fn dummy1(self: &&'a Bar<T>) { }
|
2019-09-02 18:21:58 -07:00
|
|
|
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched `self` parameter type
|
|
|
|
//~^ ERROR mismatched `self` parameter type
|
2015-01-12 01:01:44 -05:00
|
|
|
fn dummy3(self: &&Bar<T>) {}
|
2019-09-02 18:21:58 -07:00
|
|
|
//~^ ERROR mismatched `self` parameter type
|
2019-11-13 14:16:56 -08:00
|
|
|
//~| expected reference `&'a Bar<T>`
|
|
|
|
//~| found reference `&Bar<T>`
|
2017-11-09 09:16:55 -05:00
|
|
|
//~| lifetime mismatch
|
2019-09-02 18:21:58 -07:00
|
|
|
//~| ERROR mismatched `self` parameter type
|
2019-11-13 14:16:56 -08:00
|
|
|
//~| expected reference `&'a Bar<T>`
|
|
|
|
//~| found reference `&Bar<T>`
|
2017-11-09 09:16:55 -05:00
|
|
|
//~| lifetime mismatch
|
2014-11-15 16:58:09 -05:00
|
|
|
}
|
|
|
|
|
2014-05-06 16:37:32 -07:00
|
|
|
fn main() {
|
|
|
|
let foo = box Foo {
|
|
|
|
f: 1,
|
|
|
|
};
|
|
|
|
println!("{}", foo.foo(2));
|
|
|
|
let bar = box Bar {
|
|
|
|
f: 1,
|
|
|
|
};
|
|
|
|
println!("{} {}", bar.foo(2), bar.bar(2));
|
|
|
|
}
|