Skip to content

Commit c4be8f2

Browse files
committed
add a series of tests for changes to structs
These tests reveal that the edges are in some cases too strict.
1 parent dd6e8d4 commit c4be8f2

File tree

7 files changed

+326
-0
lines changed

7 files changed

+326
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 incremental compilation tracking where we change field names
12+
// in between revisions (hashing should be stable).
13+
14+
// revisions:rpass1 rpass2
15+
16+
#![feature(rustc_attrs)]
17+
18+
pub struct X {
19+
pub x: u32,
20+
21+
#[cfg(rpass2)]
22+
pub x2: u32,
23+
}
24+
25+
pub struct EmbedX {
26+
x: X
27+
}
28+
29+
pub struct Y {
30+
pub y: char
31+
}
32+
33+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
34+
pub fn use_X(x: X) -> u32 {
35+
x.x as u32
36+
}
37+
38+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
39+
pub fn use_EmbedX(embed: EmbedX) -> u32 {
40+
embed.x.x as u32
41+
}
42+
43+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
44+
pub fn use_Y() {
45+
let x: Y = Y { y: 'c' };
46+
}
47+
48+
pub fn main() { }
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 incremental compilation tracking where we change field names
12+
// in between revisions (hashing should be stable).
13+
14+
// revisions:rpass1 cfail2
15+
16+
#![feature(rustc_attrs)]
17+
18+
#[cfg(rpass1)]
19+
pub struct X {
20+
pub x: u32
21+
}
22+
23+
#[cfg(cfail2)]
24+
pub struct X {
25+
pub y: u32
26+
}
27+
28+
pub struct EmbedX {
29+
x: X
30+
}
31+
32+
pub struct Y {
33+
pub y: char
34+
}
35+
36+
#[rustc_dirty(label="TypeckItemBody", cfg="cfail2")]
37+
pub fn use_X() -> u32 {
38+
let x: X = X { x: 22 };
39+
//[cfail2]~^ ERROR structure `X` has no field named `x`
40+
x.x as u32
41+
//[cfail2]~^ ERROR attempted access of field `x`
42+
}
43+
44+
#[rustc_dirty(label="TypeckItemBody", cfg="cfail2")]
45+
pub fn use_EmbedX(embed: EmbedX) -> u32 {
46+
embed.x.x as u32
47+
//[cfail2]~^ ERROR attempted access of field `x`
48+
}
49+
50+
#[rustc_dirty(label="TypeckItemBody", cfg="cfail2")] // FIXME(#33850) should be clean
51+
pub fn use_Y() {
52+
let x: Y = Y { y: 'c' };
53+
}
54+
55+
pub fn main() { }
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 incremental compilation tracking where we change nothing
12+
// in between revisions (hashing should be stable).
13+
14+
// revisions:rpass1 rpass2
15+
16+
#![feature(rustc_attrs)]
17+
18+
#[cfg(rpass1)]
19+
pub struct X {
20+
pub x: u32
21+
}
22+
23+
#[cfg(rpass2)]
24+
pub struct X {
25+
pub x: i32
26+
}
27+
28+
pub struct EmbedX {
29+
x: X
30+
}
31+
32+
pub struct Y {
33+
pub y: char
34+
}
35+
36+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
37+
pub fn use_X() -> u32 {
38+
let x: X = X { x: 22 };
39+
x.x as u32
40+
}
41+
42+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
43+
pub fn use_EmbedX(x: EmbedX) -> u32 {
44+
let x: X = X { x: 22 };
45+
x.x as u32
46+
}
47+
48+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
49+
pub fn use_Y() {
50+
let x: Y = Y { y: 'c' };
51+
}
52+
53+
pub fn main() { }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
#![crate_type="rlib"]
12+
13+
#[cfg(rpass1)]
14+
pub struct X {
15+
pub x: u32
16+
}
17+
18+
#[cfg(rpass2)]
19+
pub struct X {
20+
pub x: i32
21+
}
22+
23+
pub struct EmbedX {
24+
pub x: X
25+
}
26+
27+
pub struct Y {
28+
pub y: char
29+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
// aux-build:a.rs
12+
// revisions:rpass1 rpass2
13+
14+
#![feature(rustc_attrs)]
15+
16+
extern crate a;
17+
18+
use a::*;
19+
20+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
21+
pub fn use_X() -> u32 {
22+
let x: X = X { x: 22 };
23+
x.x as u32
24+
}
25+
26+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
27+
pub fn use_EmbedX(embed: EmbedX) -> u32 {
28+
embed.x.x as u32
29+
}
30+
31+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
32+
pub fn use_Y() {
33+
let x: Y = Y { y: 'c' };
34+
}
35+
36+
pub fn main() { }
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 incremental compilation tracking where we change nothing
12+
// in between revisions (hashing should be stable).
13+
14+
// revisions:rpass1 rpass2
15+
16+
#![feature(rustc_attrs)]
17+
18+
#[cfg(rpass1)]
19+
pub struct X {
20+
pub x: u32
21+
}
22+
23+
#[cfg(rpass2)]
24+
pub struct X {
25+
pub x: u32
26+
}
27+
28+
pub struct EmbedX {
29+
x: X
30+
}
31+
32+
pub struct Y {
33+
pub y: char
34+
}
35+
36+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
37+
pub fn use_X() -> u32 {
38+
let x: X = X { x: 22 };
39+
x.x as u32
40+
}
41+
42+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
43+
pub fn use_EmbedX(x: EmbedX) -> u32 {
44+
let x: X = X { x: 22 };
45+
x.x as u32
46+
}
47+
48+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
49+
pub fn use_Y() {
50+
let x: Y = Y { y: 'c' };
51+
}
52+
53+
pub fn main() { }
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 incremental compilation tracking where we change field names
12+
// in between revisions (hashing should be stable).
13+
14+
// revisions:rpass1 rpass2
15+
16+
#![feature(rustc_attrs)]
17+
18+
#[cfg(rpass1)]
19+
pub struct X {
20+
pub x: u32,
21+
pub x2: u32,
22+
}
23+
24+
#[cfg(rpass2)]
25+
pub struct X {
26+
pub x: u32,
27+
}
28+
29+
pub struct EmbedX {
30+
x: X
31+
}
32+
33+
pub struct Y {
34+
pub y: char
35+
}
36+
37+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
38+
pub fn use_X(x: X) -> u32 {
39+
x.x as u32
40+
}
41+
42+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")]
43+
pub fn use_EmbedX(embed: EmbedX) -> u32 {
44+
embed.x.x as u32
45+
}
46+
47+
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
48+
pub fn use_Y() {
49+
let x: Y = Y { y: 'c' };
50+
}
51+
52+
pub fn main() { }

0 commit comments

Comments
 (0)