Skip to content

Commit

Permalink
Rollup merge of rust-lang#67773 - michalt:issue-37333-test, r=nikomat…
Browse files Browse the repository at this point in the history
…sakis

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 <[email protected]>
  • Loading branch information
Centril authored Jan 4, 2020
2 parents 85277ff + cfab634 commit 93ff897
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
}
20 changes: 20 additions & 0 deletions src/test/incremental/change_implementation_cross_crate/main.rs
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit 93ff897

Please sign in to comment.