]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/regions-trait-1.rs
1 // Copyright 2012 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 #![feature(box_syntax)]
13 struct ctxt { v: usize }
16 // Here the `&` is bound in the method definition:
17 fn get_ctxt(&self) -> &ctxt
;
20 struct has_ctxt
<'a
> { c: &'a ctxt }
22 impl<'a
> get_ctxt
for has_ctxt
<'a
> {
24 // Here an error occurs because we used `&self` but
25 // the definition used `&`:
26 fn get_ctxt(&self) -> &'a ctxt
{ //~ ERROR method not compatible with trait
32 fn get_v(gc
: Box
<get_ctxt
>) -> usize {
37 let ctxt
= ctxt { v: 22 }
;
38 let hc
= has_ctxt { c: &ctxt }
;
39 assert_eq
!(get_v(box hc
as Box
<get_ctxt
>), 22);