]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/exported_vs_not.rs
Auto merge of #95884 - cjgillot:assoc-item, r=lcnr
[rust.git] / src / test / 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 // [cfail4]compile-flags: -Zincremental-relative-spans
8 // [cfail5]compile-flags: -Zincremental-relative-spans
9 // [cfail6]compile-flags: -Zincremental-relative-spans
10
11 #![allow(warnings)]
12 #![feature(rustc_attrs)]
13 #![crate_type="rlib"]
14
15 // Case 1: The function body is not exported to metadata. If the body changes,
16 //         the hash of the hir_owner_nodes node should change, but not the hash of
17 //         either the hir_owner or the Metadata node.
18
19 #[cfg(any(cfail1,cfail4))]
20 pub fn body_not_exported_to_metadata() -> u32 {
21     1
22 }
23
24 #[cfg(not(any(cfail1,cfail4)))]
25 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
26 #[rustc_clean(cfg="cfail3")]
27 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
28 #[rustc_clean(cfg="cfail6")]
29 pub fn body_not_exported_to_metadata() -> u32 {
30     2
31 }
32
33
34
35 // Case 2: The function body *is* exported to metadata because the function is
36 //         marked as #[inline]. Only the hash of the hir_owner depnode should be
37 //         unaffected by a change to the body.
38
39 #[cfg(any(cfail1,cfail4))]
40 #[inline]
41 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
42     1
43 }
44
45 #[cfg(not(any(cfail1,cfail4)))]
46 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
47 #[rustc_clean(cfg="cfail3")]
48 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
49 #[rustc_clean(cfg="cfail6")]
50 #[inline]
51 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
52     2
53 }
54
55
56
57 // Case 2: The function body *is* exported to metadata because the function is
58 //         generic. Only the hash of the hir_owner depnode should be
59 //         unaffected by a change to the body.
60
61 #[cfg(any(cfail1,cfail4))]
62 #[inline]
63 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
64     1
65 }
66
67 #[cfg(not(any(cfail1,cfail4)))]
68 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
69 #[rustc_clean(cfg="cfail3")]
70 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
71 #[rustc_clean(cfg="cfail6")]
72 #[inline]
73 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
74     2
75 }