File: change_symbol_export_status.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (39 lines) | stat: -rw-r--r-- 1,289 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//@ revisions: rpass1 rpass2 rpass3 rpass4
//@ compile-flags: -Zquery-dep-graph
//@ [rpass1]compile-flags: -Zincremental-ignore-spans
//@ [rpass2]compile-flags: -Zincremental-ignore-spans

#![feature(rustc_attrs)]
#![rustc_partition_reused(module = "change_symbol_export_status-mod1", cfg = "rpass2")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod2", cfg = "rpass2")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod1", cfg = "rpass4")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod2", cfg = "rpass4")]

// This test case makes sure that a change in symbol visibility is detected by
// our dependency tracking. We do this by changing a module's visibility to
// `private` in rpass2, causing the contained function to go from `default` to
// `hidden` visibility.
// The function is marked with #[no_mangle] so it is considered for exporting
// even from an executable. Plain Rust functions are only exported from Rust
// libraries, which our test infrastructure does not support.

#[cfg(any(rpass1,rpass3))]
pub mod mod1 {
    #[no_mangle]
    pub fn foo() {}
}

#[cfg(any(rpass2,rpass4))]
mod mod1 {
    #[no_mangle]
    pub fn foo() {}
}

pub mod mod2 {
    #[no_mangle]
    pub fn bar() {}
}

fn main() {
    mod1::foo();
}