Skip to content

Commit cfab634

Browse files
committed
Add a test for rust-lang#37333
The test checks that we reuse the CGU of a crate when the implementation details of an `extern crate` have changed. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
1 parent 38aa6bd commit cfab634

File tree

2 files changed

+51
-0
lines changed
  • src/test/incremental/change_implementation_cross_crate

2 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![allow(warnings)]
2+
#![crate_name = "a"]
3+
#![crate_type = "rlib"]
4+
5+
#[cfg(rpass1)]
6+
#[inline(never)]
7+
pub fn foo(b: u8) -> u32 {
8+
b as u32
9+
}
10+
11+
#[cfg(rpass2)]
12+
#[inline(never)]
13+
pub fn foo(b: u8) -> u32 {
14+
(b + 42) as u32
15+
}
16+
17+
pub fn bar(b: u8) -> u32 {
18+
bar_impl(b) as u32
19+
}
20+
21+
#[cfg(rpass1)]
22+
#[inline(never)]
23+
fn bar_impl(b: u8) -> u16 {
24+
b as u16
25+
}
26+
27+
#[cfg(rpass2)]
28+
#[inline(never)]
29+
fn bar_impl(b: u8) -> u32 {
30+
(b + 42) as u32
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Test that we are able to reuse `main` despite the changes in the implementation of `foo` and
2+
// `bar`.
3+
4+
// revisions: rpass1 rpass2
5+
// aux-build: a.rs
6+
// compile-flags: -Zquery-dep-graph
7+
8+
#![feature(rustc_attrs)]
9+
#![crate_type = "bin"]
10+
#![rustc_partition_reused(module = "main", cfg = "rpass2")]
11+
12+
extern crate a;
13+
14+
pub fn main() {
15+
let vec: Vec<u8> = vec![0, 1, 2, 3];
16+
for b in vec {
17+
println!("{}", a::foo(b));
18+
println!("{}", a::bar(b));
19+
}
20+
}

0 commit comments

Comments
 (0)