Skip to content

Commit 90f0de8

Browse files
incr.comp.: Add test case for symbol visibility changes
1 parent 4a494ed commit 90f0de8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
// revisions: rpass1 rpass2
12+
13+
#![feature(rustc_attrs)]
14+
#![allow(private_no_mangle_fns)]
15+
16+
#![rustc_partition_reused(module="change_symbol_export_status", cfg="rpass2")]
17+
#![rustc_partition_translated(module="change_symbol_export_status-mod1", cfg="rpass2")]
18+
19+
20+
// This test case makes sure that a change in symbol visibility is detected by
21+
// our dependency tracking. We do this by changing a module's visibility to
22+
// `private` in rpass2, causing the contained function to go from `default` to
23+
// `hidden` visibility.
24+
// The function is marked with #[no_mangle] so it is considered for exporting
25+
// even from an executable. Plain Rust functions are only exported from Rust
26+
// libraries, which our test infrastructure does not support.
27+
28+
#[cfg(rpass1)]
29+
pub mod mod1 {
30+
#[no_mangle]
31+
pub fn foo() {}
32+
}
33+
34+
#[cfg(rpass2)]
35+
mod mod1 {
36+
#[no_mangle]
37+
pub fn foo() {}
38+
}
39+
40+
fn main() {
41+
mod1::foo();
42+
}

0 commit comments

Comments
 (0)