2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-07-11 12:28:30 -05:00
|
|
|
// Here: foo is parameterized because it contains a method that
|
|
|
|
// refers to self.
|
|
|
|
|
2013-02-26 13:34:00 -06:00
|
|
|
trait foo<'self> {
|
|
|
|
fn self_int() -> &'self int;
|
2012-07-11 12:28:30 -05:00
|
|
|
|
|
|
|
fn any_int() -> ∫
|
|
|
|
}
|
|
|
|
|
2013-02-26 13:34:00 -06:00
|
|
|
struct with_foo<'self> {
|
|
|
|
f: foo<'self>
|
2013-02-22 18:08:16 -06:00
|
|
|
}
|
2012-07-11 12:28:30 -05:00
|
|
|
|
2012-07-11 17:00:40 -05:00
|
|
|
trait set_foo_foo {
|
2013-02-26 13:34:00 -06:00
|
|
|
fn set_foo(&mut self, f: @foo);
|
2012-07-11 17:00:40 -05:00
|
|
|
}
|
|
|
|
|
2013-02-26 13:34:00 -06:00
|
|
|
impl<'self> set_foo_foo for with_foo<'self> {
|
|
|
|
fn set_foo(&mut self, f: @foo) {
|
2012-08-14 20:17:18 -05:00
|
|
|
self.f = f; //~ ERROR mismatched types: expected `@foo/&self` but found `@foo/&`
|
2012-07-11 12:28:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bar is not region parameterized.
|
|
|
|
|
2012-07-31 12:27:51 -05:00
|
|
|
trait bar {
|
2012-07-11 12:28:30 -05:00
|
|
|
fn any_int() -> ∫
|
|
|
|
}
|
|
|
|
|
2013-02-22 18:08:16 -06:00
|
|
|
struct with_bar {
|
|
|
|
f: bar
|
|
|
|
}
|
2012-07-11 12:28:30 -05:00
|
|
|
|
2012-07-11 17:00:40 -05:00
|
|
|
trait set_foo_bar {
|
2013-02-22 18:08:16 -06:00
|
|
|
fn set_foo(&mut self, f: bar);
|
2012-07-11 17:00:40 -05:00
|
|
|
}
|
|
|
|
|
2013-02-14 13:47:00 -06:00
|
|
|
impl set_foo_bar for with_bar {
|
2013-02-22 18:08:16 -06:00
|
|
|
fn set_foo(&mut self, f: bar) {
|
2012-07-11 12:28:30 -05:00
|
|
|
self.f = f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-11 17:00:40 -05:00
|
|
|
fn main() {}
|