]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/issue-2548.rs
cb0b8afbf8ba4454f4bf688c4d6468e675145b20
[rust.git] / src / test / compile-fail / issue-2548.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.
4 //
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.
10
11 // A test case for #2548.
12
13 struct foo {
14     x: @mut int,
15
16
17 }
18
19 #[unsafe_destructor]
20 impl Drop for foo {
21     fn drop(&self) {
22         unsafe {
23             println("Goodbye, World!");
24             *self.x += 1;
25         }
26     }
27 }
28
29 fn foo(x: @mut int) -> foo {
30     foo { x: x }
31 }
32
33 fn main() {
34     let x = @mut 0;
35
36     {
37         let mut res = foo(x);
38
39         let mut v = ~[];
40         v = ~[(res)] + v; //~ failed to find an implementation of trait
41         assert_eq!(v.len(), 2);
42     }
43
44     assert_eq!(*x, 1);
45 }