]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/nested-function-names-issue-8587.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[rust.git] / src / test / run-pass / nested-function-names-issue-8587.rs
1 // Copyright 2013 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 // Make sure nested functions are separate, even if they have
12 // equal name.
13 //
14 // Issue #8587
15
16 // pretty-expanded FIXME #23616
17
18 pub struct X;
19
20 impl X {
21     fn f(&self) -> int {
22         #[inline(never)]
23         fn inner() -> int {
24             0
25         }
26         inner()
27     }
28
29     fn g(&self) -> int {
30         #[inline(never)]
31         fn inner_2() -> int {
32             1
33         }
34         inner_2()
35     }
36
37     fn h(&self) -> int {
38         #[inline(never)]
39         fn inner() -> int {
40             2
41         }
42         inner()
43     }
44 }
45
46 pub fn main() {
47     let n = X;
48     assert_eq!(n.f(), 0);
49     assert_eq!(n.g(), 1);
50     // This test `h` used to fail.
51     assert_eq!(n.h(), 2);
52 }