]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/exported_vs_not.rs
Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnik
[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 // compile-pass
12 // revisions: cfail1 cfail2 cfail3
13 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
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(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
30 #[rustc_clean(cfg="cfail3")]
31 pub fn body_not_exported_to_metadata() -> u32 {
32     2
33 }
34
35
36
37 // Case 2: The function body *is* exported to metadata because the function is
38 //         marked as #[inline]. Only the hash of the Hir depnode should be
39 //         unaffected by a change to the body.
40
41 #[cfg(cfail1)]
42 #[inline]
43 pub fn body_exported_to_metadata_because_of_inline() -> u32 {
44     1
45 }
46
47 #[cfg(not(cfail1))]
48 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
49 #[rustc_clean(cfg="cfail3")]
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 depnode should be
59 //         unaffected by a change to the body.
60
61 #[cfg(cfail1)]
62 #[inline]
63 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
64     1
65 }
66
67 #[cfg(not(cfail1))]
68 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
69 #[rustc_clean(cfg="cfail3")]
70 #[inline]
71 pub fn body_exported_to_metadata_because_of_generic() -> u32 {
72     2
73 }
74