File tree 3 files changed +10
-7
lines changed
compiler/rustc_passes/src
3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -98,15 +98,11 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
98
98
self . worklist . push ( def_id) ;
99
99
} else {
100
100
match res {
101
- // If this path leads to a constant, then we need to
102
- // recurse into the constant to continue finding
103
- // items that are reachable.
104
- Res :: Def ( DefKind :: Const | DefKind :: AssocConst , _) => {
101
+ // Reachable constants and reachable statics can have their contents inlined
102
+ // into other crates. Mark them as reachable and recurse into their body.
103
+ Res :: Def ( DefKind :: Const | DefKind :: AssocConst | DefKind :: Static ( _) , _) => {
105
104
self . worklist . push ( def_id) ;
106
105
}
107
-
108
- // If this wasn't a static, then the destination is
109
- // surely reachable.
110
106
_ => {
111
107
self . reachable_symbols . insert ( def_id) ;
112
108
}
Original file line number Diff line number Diff line change 1
1
pub static V : & u32 = & X ;
2
2
pub static F : fn ( ) = f;
3
+ pub static G : fn ( ) = G0 ;
3
4
4
5
static X : u32 = 42 ;
6
+ static G0 : fn ( ) = g;
5
7
6
8
pub fn v ( ) -> * const u32 {
7
9
V
8
10
}
9
11
10
12
fn f ( ) { }
13
+
14
+ fn g ( ) { }
Original file line number Diff line number Diff line change
1
+ // Regression test for #84455 and #115052.
1
2
// run-pass
2
3
// aux-build:static_init_aux.rs
3
4
extern crate static_init_aux as aux;
4
5
5
6
static V : & u32 = aux:: V ;
6
7
static F : fn ( ) = aux:: F ;
8
+ static G : fn ( ) = aux:: G ;
7
9
8
10
fn v ( ) -> * const u32 {
9
11
V
@@ -12,4 +14,5 @@ fn v() -> *const u32 {
12
14
fn main ( ) {
13
15
assert_eq ! ( aux:: v( ) , crate :: v( ) ) ;
14
16
F ( ) ;
17
+ G ( ) ;
15
18
}
You can’t perform that action at this time.
0 commit comments