]> git.lizzy.rs Git - rust.git/blob - tests/incremental/spans_in_type_debuginfo.rs
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
[rust.git] / tests / incremental / spans_in_type_debuginfo.rs
1 // Test that moving a type definition within a source file does not affect
2 // re-compilation.
3
4 // ignore-asmjs wasm2js does not support source maps yet
5 // revisions:rpass1 rpass2
6 // compile-flags: -Z query-dep-graph -g
7
8 #![rustc_partition_reused(module="spans_in_type_debuginfo-structs", cfg="rpass2")]
9 #![rustc_partition_reused(module="spans_in_type_debuginfo-enums", cfg="rpass2")]
10
11 #![feature(rustc_attrs)]
12
13 mod structs {
14     #[cfg(rpass1)]
15     pub struct X {
16         pub x: u32,
17     }
18
19     #[cfg(rpass2)]
20     pub struct X {
21         pub x: u32,
22     }
23
24     pub fn foo(x: X) -> u32 {
25         x.x
26     }
27 }
28
29 mod enums {
30     #[cfg(rpass1)]
31     pub enum X {
32         A { x: u32 },
33         B(u32),
34     }
35
36     #[cfg(rpass2)]
37     pub enum X {
38         A { x: u32 },
39         B(u32),
40     }
41
42     pub fn foo(x: X) -> u32 {
43         match x {
44             X::A { x } => x,
45             X::B(x) => x,
46         }
47     }
48 }
49
50 pub fn main() {
51     let _ = structs::foo(structs::X { x: 1 });
52     let _ = enums::foo(enums::X::A { x: 2 });
53 }