]> git.lizzy.rs Git - rust.git/blob - tests/incremental/hashes/exported_vs_not.rs
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
[rust.git] / tests / incremental / hashes / exported_vs_not.rs
1 // build-pass (FIXME(62277): could be check-pass?)
2 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
3 // compile-flags: -Z query-dep-graph -O
4 // [cfail1]compile-flags: -Zincremental-ignore-spans
5 // [cfail2]compile-flags: -Zincremental-ignore-spans
6 // [cfail3]compile-flags: -Zincremental-ignore-spans
7
8 #![allow(warnings)]
9 #![feature(rustc_attrs)]
10 #![crate_type="rlib"]
11
12 // Case 1: The function body is not exported to metadata. If the body changes,
13 //         the hash of the hir_owner_nodes node should change, but not the hash of
14 //         either the hir_owner or the Metadata node.
15
16 #[cfg(any(cfail1,cfail4))]
17 pub fn body_not_exported_to_metadata() -> u32 {
18     1
19 }
20
21 #[cfg(not(any(cfail1,cfail4)))]
22 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
23 #[rustc_clean(cfg="cfail3")]
24 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
25 #[rustc_clean(cfg="cfail6")]
26 pub fn body_not_exported_to_metadata() -> u32 {
27     2
28 }
29
30
31
32 // Case 2: The function body *is* exported to metadata because the function is
33 //         marked as #[inline]. Only the hash of the hir_owner depnode should be
34 //         unaffected by a change to the body.
35
36 #[cfg(any(cfail1,cfail4))]
37 #[inline]
38 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
39     1
40 }
41
42 #[cfg(not(any(cfail1,cfail4)))]
43 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
44 #[rustc_clean(cfg="cfail3")]
45 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
46 #[rustc_clean(cfg="cfail6")]
47 #[inline]
48 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
49     2
50 }
51
52
53
54 // Case 2: The function body *is* exported to metadata because the function is
55 //         generic. Only the hash of the hir_owner depnode should be
56 //         unaffected by a change to the body.
57
58 #[cfg(any(cfail1,cfail4))]
59 #[inline]
60 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
61     1
62 }
63
64 #[cfg(not(any(cfail1,cfail4)))]
65 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
66 #[rustc_clean(cfg="cfail3")]
67 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
68 #[rustc_clean(cfg="cfail6")]
69 #[inline]
70 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
71     2
72 }