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.
|
|
|
|
|
2012-07-31 12:27:51 -05:00
|
|
|
trait foo {
|
2012-07-12 11:36:56 -05:00
|
|
|
fn self_int() -> &self/int;
|
2012-07-11 12:28:30 -05:00
|
|
|
|
|
|
|
fn any_int() -> ∫
|
|
|
|
}
|
|
|
|
|
|
|
|
type with_foo = {mut f: foo};
|
|
|
|
|
2012-07-11 17:00:40 -05:00
|
|
|
trait set_foo_foo {
|
|
|
|
fn set_foo(f: foo);
|
|
|
|
}
|
|
|
|
|
2013-02-14 13:47:00 -06:00
|
|
|
impl set_foo_foo for with_foo {
|
2012-07-11 12:28:30 -05:00
|
|
|
fn set_foo(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() -> ∫
|
|
|
|
}
|
|
|
|
|
|
|
|
type with_bar = {mut f: bar};
|
|
|
|
|
2012-07-11 17:00:40 -05:00
|
|
|
trait set_foo_bar {
|
|
|
|
fn set_foo(f: bar);
|
|
|
|
}
|
|
|
|
|
2013-02-14 13:47:00 -06:00
|
|
|
impl set_foo_bar for with_bar {
|
2012-07-11 12:28:30 -05:00
|
|
|
fn set_foo(f: bar) {
|
|
|
|
self.f = f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-11 17:00:40 -05:00
|
|
|
fn main() {}
|