File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 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> {
9898 self . worklist . push ( def_id) ;
9999 } else {
100100 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 ( _) , _) => {
105104 self . worklist . push ( def_id) ;
106105 }
107-
108- // If this wasn't a static, then the destination is
109- // surely reachable.
110106 _ => {
111107 self . reachable_symbols . insert ( def_id) ;
112108 }
Original file line number Diff line number Diff line change 11pub static V : & u32 = & X ;
22pub static F : fn ( ) = f;
3+ pub static G : fn ( ) = G0 ;
34
45static X : u32 = 42 ;
6+ static G0 : fn ( ) = g;
57
68pub fn v ( ) -> * const u32 {
79 V
810}
911
1012fn f ( ) { }
13+
14+ fn g ( ) { }
Original file line number Diff line number Diff line change 1+ // Regression test for #84455 and #115052.
12// run-pass
23// aux-build:static_init_aux.rs
34extern crate static_init_aux as aux;
45
56static V : & u32 = aux:: V ;
67static F : fn ( ) = aux:: F ;
8+ static G : fn ( ) = aux:: G ;
79
810fn v ( ) -> * const u32 {
911 V
@@ -12,4 +14,5 @@ fn v() -> *const u32 {
1214fn main ( ) {
1315 assert_eq ! ( aux:: v( ) , crate :: v( ) ) ;
1416 F ( ) ;
17+ G ( ) ;
1518}
You can’t perform that action at this time.
0 commit comments