]>
Commit | Line | Data |
---|---|---|
476ff2be SL |
1 | // Copyright 2016 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 | // must-compile-successfully | |
12 | // revisions: cfail1 cfail2 cfail3 | |
13 | // compile-flags: -Z query-dep-graph | |
14 | ||
15 | #![allow(warnings)] | |
16 | #![feature(rustc_attrs)] | |
17 | #![crate_type="rlib"] | |
18 | ||
19 | // Case 1: The function body is not exported to metadata. If the body changes, | |
20 | // the hash of the HirBody node should change, but not the hash of | |
21 | // either the Hir or the Metadata node. | |
22 | ||
23 | #[cfg(cfail1)] | |
24 | pub fn body_not_exported_to_metadata() -> u32 { | |
25 | 1 | |
26 | } | |
27 | ||
28 | #[cfg(not(cfail1))] | |
abe05a73 XL |
29 | #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")] |
30 | #[rustc_clean(cfg="cfail3")] | |
476ff2be SL |
31 | #[rustc_metadata_clean(cfg="cfail2")] |
32 | #[rustc_metadata_clean(cfg="cfail3")] | |
33 | pub fn body_not_exported_to_metadata() -> u32 { | |
34 | 2 | |
35 | } | |
36 | ||
37 | ||
38 | ||
39 | // Case 2: The function body *is* exported to metadata because the function is | |
40 | // marked as #[inline]. Only the hash of the Hir depnode should be | |
41 | // unaffected by a change to the body. | |
42 | ||
43 | #[cfg(cfail1)] | |
44 | #[inline] | |
45 | pub fn body_exported_to_metadata_because_of_inline() -> u32 { | |
46 | 1 | |
47 | } | |
48 | ||
49 | #[cfg(not(cfail1))] | |
abe05a73 XL |
50 | #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")] |
51 | #[rustc_clean(cfg="cfail3")] | |
476ff2be SL |
52 | #[rustc_metadata_dirty(cfg="cfail2")] |
53 | #[rustc_metadata_clean(cfg="cfail3")] | |
54 | #[inline] | |
55 | pub fn body_exported_to_metadata_because_of_inline() -> u32 { | |
56 | 2 | |
57 | } | |
58 | ||
59 | ||
60 | ||
61 | // Case 2: The function body *is* exported to metadata because the function is | |
62 | // generic. Only the hash of the Hir depnode should be | |
63 | // unaffected by a change to the body. | |
64 | ||
65 | #[cfg(cfail1)] | |
66 | #[inline] | |
67 | pub fn body_exported_to_metadata_because_of_generic() -> u32 { | |
68 | 1 | |
69 | } | |
70 | ||
71 | #[cfg(not(cfail1))] | |
abe05a73 XL |
72 | #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")] |
73 | #[rustc_clean(cfg="cfail3")] | |
476ff2be SL |
74 | #[rustc_metadata_dirty(cfg="cfail2")] |
75 | #[rustc_metadata_clean(cfg="cfail3")] | |
76 | #[inline] | |
77 | pub fn body_exported_to_metadata_because_of_generic() -> u32 { | |
78 | 2 | |
79 | } | |
80 |