]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-15763.rs
Convert unknown_features lint into an error
[rust.git] / src / test / run-pass / issue-15763.rs
1 // Copyright 2014 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 #![feature(box_syntax)]
12
13 #[derive(PartialEq, Debug)]
14 struct Bar {
15     x: isize
16 }
17 impl Drop for Bar {
18     fn drop(&mut self) {
19         assert_eq!(self.x, 22);
20     }
21 }
22
23 #[derive(PartialEq, Debug)]
24 struct Foo {
25     x: Bar,
26     a: isize
27 }
28
29 fn foo() -> Result<Foo, isize> {
30     return Ok(Foo {
31         x: Bar { x: 22 },
32         a: return Err(32)
33     });
34 }
35
36 fn baz() -> Result<Foo, isize> {
37     Ok(Foo {
38         x: Bar { x: 22 },
39         a: return Err(32)
40     })
41 }
42
43 // explicit immediate return
44 fn aa() -> isize {
45     return 3;
46 }
47
48 // implicit immediate return
49 fn bb() -> isize {
50     3
51 }
52
53 // implicit outptr return
54 fn cc() -> Result<isize, isize> {
55     Ok(3)
56 }
57
58 // explicit outptr return
59 fn dd() -> Result<isize, isize> {
60     return Ok(3);
61 }
62
63 trait A {
64     fn aaa(&self) -> isize {
65         3
66     }
67     fn bbb(&self) -> isize {
68         return 3;
69     }
70     fn ccc(&self) -> Result<isize, isize> {
71         Ok(3)
72     }
73     fn ddd(&self) -> Result<isize, isize> {
74         return Ok(3);
75     }
76 }
77
78 impl A for isize {}
79
80 fn main() {
81     assert_eq!(foo(), Err(32));
82     assert_eq!(baz(), Err(32));
83
84     assert_eq!(aa(), 3);
85     assert_eq!(bb(), 3);
86     assert_eq!(cc().unwrap(), 3);
87     assert_eq!(dd().unwrap(), 3);
88
89     let i = box 32isize as Box<A>;
90     assert_eq!(i.aaa(), 3);
91     let i = box 32isize as Box<A>;
92     assert_eq!(i.bbb(), 3);
93     let i = box 32isize as Box<A>;
94     assert_eq!(i.ccc().unwrap(), 3);
95     let i = box 32isize as Box<A>;
96     assert_eq!(i.ddd().unwrap(), 3);
97 }