File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ use syntax::ast;
2525use syntax:: ast:: Name ;
2626use syntax:: ast_util;
2727use syntax:: codemap:: Span ;
28+ use syntax:: visit:: Visitor ;
2829
2930pub fn trans_block ( bcx : @mut Block , b : & ast:: Block , dest : expr:: Dest ) -> @mut Block {
3031 let _icx = push_ctxt ( "trans_block" ) ;
@@ -64,12 +65,22 @@ pub fn trans_if(bcx: @mut Block,
6465 // Drop branches that are known to be impossible
6566 if is_const ( cond_val) && !is_undef ( cond_val) {
6667 if const_to_uint ( cond_val) == 1 {
68+ match els {
69+ Some ( elexpr) => {
70+ let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
71+ trans. visit_expr ( elexpr, ( ) ) ;
72+ }
73+ None => { }
74+ }
6775 // if true { .. } [else { .. }]
6876 return do with_scope ( bcx, thn. info ( ) , "if_true_then" ) |bcx| {
6977 let bcx_out = trans_block ( bcx, thn, dest) ;
7078 trans_block_cleanups ( bcx_out, block_cleanups ( bcx) )
7179 }
7280 } else {
81+ let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
82+ trans. visit_block ( thn, ( ) ) ;
83+
7384 match els {
7485 // if false { .. } else { .. }
7586 Some ( elexpr) => {
Original file line number Diff line number Diff line change 1+ // Copyright 2013 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+ // this used to just ICE on compiling
12+ pub fn foo ( ) {
13+ if cfg ! ( foo) {
14+ static a: int = 3 ;
15+ a
16+ } else { 3 } ;
17+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2013 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+ // aux-build:cfg_inner_static.rs
12+ // xfail-fast
13+
14+ extern mod cfg_inner_static;
15+
16+ fn main ( ) {
17+ cfg_inner_static:: foo ( ) ;
18+ }
You can’t perform that action at this time.
0 commit comments