]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/exported_vs_not.rs
ICH: Add test case sensitive to function bodies in metadata.
[rust.git] / src / test / incremental / hashes / exported_vs_not.rs
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))]
29 #[rustc_clean(label="Hir", cfg="cfail2")]
30 #[rustc_clean(label="Hir", cfg="cfail3")]
31 #[rustc_dirty(label="HirBody", cfg="cfail2")]
32 #[rustc_clean(label="HirBody", cfg="cfail3")]
33 #[rustc_metadata_clean(cfg="cfail2")]
34 #[rustc_metadata_clean(cfg="cfail3")]
35 pub fn body_not_exported_to_metadata() -> u32 {
36     2
37 }
38
39
40
41 // Case 2: The function body *is* exported to metadata because the function is
42 //         marked as #[inline]. Only the hash of the Hir depnode should be
43 //         unaffected by a change to the body.
44
45 #[cfg(cfail1)]
46 #[inline]
47 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
48     1
49 }
50
51 #[cfg(not(cfail1))]
52 #[rustc_clean(label="Hir", cfg="cfail2")]
53 #[rustc_clean(label="Hir", cfg="cfail3")]
54 #[rustc_dirty(label="HirBody", cfg="cfail2")]
55 #[rustc_clean(label="HirBody", cfg="cfail3")]
56 #[rustc_metadata_dirty(cfg="cfail2")]
57 #[rustc_metadata_clean(cfg="cfail3")]
58 #[inline]
59 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
60     2
61 }
62
63
64
65 // Case 2: The function body *is* exported to metadata because the function is
66 //         generic. Only the hash of the Hir depnode should be
67 //         unaffected by a change to the body.
68
69 #[cfg(cfail1)]
70 #[inline]
71 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
72     1
73 }
74
75 #[cfg(not(cfail1))]
76 #[rustc_clean(label="Hir", cfg="cfail2")]
77 #[rustc_clean(label="Hir", cfg="cfail3")]
78 #[rustc_dirty(label="HirBody", cfg="cfail2")]
79 #[rustc_clean(label="HirBody", cfg="cfail3")]
80 #[rustc_metadata_dirty(cfg="cfail2")]
81 #[rustc_metadata_clean(cfg="cfail3")]
82 #[inline]
83 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
84     2
85 }
86