Skip to content

Commit f7eb004

Browse files
incr.comp. Add tests for stable span hashing.
1 parent 7c72f99 commit f7eb004

File tree

7 files changed

+194
-0
lines changed

7 files changed

+194
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
// This test makes sure that different expansions of the file!(), line!(),
12+
// column!() macros get picked up by the incr. comp. hash.
13+
14+
// revisions:rpass1 rpass2
15+
16+
// compile-flags: -Z query-dep-graph
17+
18+
#![feature(rustc_attrs)]
19+
20+
#[rustc_clean(label="Hir", cfg="rpass2")]
21+
fn line_same() {
22+
let _ = line!();
23+
}
24+
25+
#[rustc_clean(label="Hir", cfg="rpass2")]
26+
fn col_same() {
27+
let _ = column!();
28+
}
29+
30+
#[rustc_clean(label="Hir", cfg="rpass2")]
31+
fn file_same() {
32+
let _ = file!();
33+
}
34+
35+
#[cfg(rpass1)]
36+
fn line_different() {
37+
let _ = line!();
38+
}
39+
40+
#[cfg(rpass2)]
41+
#[rustc_dirty(label="Hir", cfg="rpass2")]
42+
fn line_different() {
43+
let _ = line!();
44+
}
45+
46+
#[cfg(rpass1)]
47+
fn col_different() {
48+
let _ = column!();
49+
}
50+
51+
#[cfg(rpass2)]
52+
#[rustc_dirty(label="Hir", cfg="rpass2")]
53+
fn col_different() {
54+
let _ = column!();
55+
}
56+
57+
fn main() {
58+
line_same();
59+
line_different();
60+
col_same();
61+
col_different();
62+
file_same();
63+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
#[cfg(rpass1)]
12+
pub mod sub2;
13+
14+
pub mod sub1;
15+
16+
#[cfg(rpass2)]
17+
pub mod sub2;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
#[rustc_clean(label="Hir", cfg="rpass2")]
12+
pub struct SomeType {
13+
pub x: u32,
14+
pub y: i64,
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
#[rustc_clean(label="Hir", cfg="rpass2")]
12+
pub struct SomeOtherType {
13+
pub a: i32,
14+
pub b: u64,
15+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
// This test makes sure that it doesn't make a difference in which order we are
12+
// adding source files to the codemap. The order affects the BytePos values of
13+
// the spans and this test makes sure that we handle them correctly by hashing
14+
// file:line:column instead of raw byte offset.
15+
16+
// revisions:rpass1 rpass2
17+
// compile-flags: -g -Z query-dep-graph
18+
19+
#![feature(rustc_attrs)]
20+
21+
mod auxiliary;
22+
23+
fn main() {
24+
let _ = auxiliary::sub1::SomeType {
25+
x: 0,
26+
y: 1,
27+
};
28+
29+
let _ = auxiliary::sub2::SomeOtherType {
30+
a: 2,
31+
b: 3,
32+
};
33+
}
34+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
// This test makes sure that just changing a definition's location in the
12+
// source file does *not* change its incr. comp. hash, if debuginfo is disabled.
13+
14+
// revisions:rpass1 rpass2
15+
16+
// compile-flags: -Z query-dep-graph
17+
18+
#![feature(rustc_attrs)]
19+
20+
#[cfg(rpass1)]
21+
pub fn main() {}
22+
23+
#[cfg(rpass2)]
24+
#[rustc_clean(label="Hir", cfg="rpass2")]
25+
pub fn main() {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
// This test makes sure that just changing a definition's location in the
12+
// source file also changes its incr. comp. hash, if debuginfo is enabled.
13+
14+
// revisions:rpass1 rpass2
15+
16+
// compile-flags: -g -Z query-dep-graph
17+
18+
#![feature(rustc_attrs)]
19+
20+
#[cfg(rpass1)]
21+
pub fn main() {}
22+
23+
#[cfg(rpass2)]
24+
#[rustc_dirty(label="Hir", cfg="rpass2")]
25+
pub fn main() {}

0 commit comments

Comments
 (0)