]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/spans_in_type_debuginfo.rs
Auto merge of #54497 - ralexstokes:stabilize_pattern_parentheses, r=nikomatsakis
[rust.git] / src / test / incremental / spans_in_type_debuginfo.rs
1 // Copyright 2014 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 // Test that moving a type definition within a source file does not affect
12 // re-compilation.
13
14 // revisions:rpass1 rpass2
15 // compile-flags: -Z query-dep-graph -g
16
17 #![rustc_partition_reused(module="spans_in_type_debuginfo-structs", cfg="rpass2")]
18 #![rustc_partition_reused(module="spans_in_type_debuginfo-enums", cfg="rpass2")]
19
20 #![feature(rustc_attrs)]
21
22 mod structs {
23     #[cfg(rpass1)]
24     pub struct X {
25         pub x: u32,
26     }
27
28     #[cfg(rpass2)]
29     pub struct X {
30         pub x: u32,
31     }
32
33     pub fn foo(x: X) -> u32 {
34         x.x
35     }
36 }
37
38 mod enums {
39     #[cfg(rpass1)]
40     pub enum X {
41         A { x: u32 },
42         B(u32),
43     }
44
45     #[cfg(rpass2)]
46     pub enum X {
47         A { x: u32 },
48         B(u32),
49     }
50
51     pub fn foo(x: X) -> u32 {
52         match x {
53             X::A { x } => x,
54             X::B(x) => x,
55         }
56     }
57 }
58
59 pub fn main() {
60     let _ = structs::foo(structs::X { x: 1 });
61     let _ = enums::foo(enums::X::A { x: 2 });
62 }