diff options
| author | Michal Terepeta <michal.terepeta@gmail.com> | 2020-01-01 12:39:13 +0100 |
|---|---|---|
| committer | Michal Terepeta <michal.terepeta@gmail.com> | 2020-01-01 13:07:41 +0100 |
| commit | cfab634972137e4625d3e7b7fb91b51d3f2d4cd4 (patch) | |
| tree | b5aaaee55773b7f88c3d38b5148edd227762834c /src/test/incremental | |
| parent | 38aa6bdfd705ea0604d7d5dd9fabc5e8f853a4fc (diff) | |
| download | rust-cfab634972137e4625d3e7b7fb91b51d3f2d4cd4.tar.gz rust-cfab634972137e4625d3e7b7fb91b51d3f2d4cd4.zip | |
Add a test for #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>
Diffstat (limited to 'src/test/incremental')
| -rw-r--r-- | src/test/incremental/change_implementation_cross_crate/auxiliary/a.rs | 31 | ||||
| -rw-r--r-- | src/test/incremental/change_implementation_cross_crate/main.rs | 20 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/test/incremental/change_implementation_cross_crate/auxiliary/a.rs b/src/test/incremental/change_implementation_cross_crate/auxiliary/a.rs new file mode 100644 index 00000000000..7320a97b997 --- /dev/null +++ b/src/test/incremental/change_implementation_cross_crate/auxiliary/a.rs @@ -0,0 +1,31 @@ +#![allow(warnings)] +#![crate_name = "a"] +#![crate_type = "rlib"] + +#[cfg(rpass1)] +#[inline(never)] +pub fn foo(b: u8) -> u32 { + b as u32 +} + +#[cfg(rpass2)] +#[inline(never)] +pub fn foo(b: u8) -> u32 { + (b + 42) as u32 +} + +pub fn bar(b: u8) -> u32 { + bar_impl(b) as u32 +} + +#[cfg(rpass1)] +#[inline(never)] +fn bar_impl(b: u8) -> u16 { + b as u16 +} + +#[cfg(rpass2)] +#[inline(never)] +fn bar_impl(b: u8) -> u32 { + (b + 42) as u32 +} diff --git a/src/test/incremental/change_implementation_cross_crate/main.rs b/src/test/incremental/change_implementation_cross_crate/main.rs new file mode 100644 index 00000000000..dee9ebd74a8 --- /dev/null +++ b/src/test/incremental/change_implementation_cross_crate/main.rs @@ -0,0 +1,20 @@ +// Test that we are able to reuse `main` despite the changes in the implementation of `foo` and +// `bar`. + +// revisions: rpass1 rpass2 +// aux-build: a.rs +// compile-flags: -Zquery-dep-graph + +#![feature(rustc_attrs)] +#![crate_type = "bin"] +#![rustc_partition_reused(module = "main", cfg = "rpass2")] + +extern crate a; + +pub fn main() { + let vec: Vec<u8> = vec![0, 1, 2, 3]; + for b in vec { + println!("{}", a::foo(b)); + println!("{}", a::bar(b)); + } +} |
