File tree 3 files changed +46
-0
lines changed 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ use syntax::ast;
25
25
use syntax:: ast:: Name ;
26
26
use syntax:: ast_util;
27
27
use syntax:: codemap:: Span ;
28
+ use syntax:: visit:: Visitor ;
28
29
29
30
pub fn trans_block ( bcx : @mut Block , b : & ast:: Block , dest : expr:: Dest ) -> @mut Block {
30
31
let _icx = push_ctxt ( "trans_block" ) ;
@@ -64,12 +65,22 @@ pub fn trans_if(bcx: @mut Block,
64
65
// Drop branches that are known to be impossible
65
66
if is_const ( cond_val) && !is_undef ( cond_val) {
66
67
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
+ }
67
75
// if true { .. } [else { .. }]
68
76
return do with_scope ( bcx, thn. info ( ) , "if_true_then" ) |bcx| {
69
77
let bcx_out = trans_block ( bcx, thn, dest) ;
70
78
trans_block_cleanups ( bcx_out, block_cleanups ( bcx) )
71
79
}
72
80
} else {
81
+ let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
82
+ trans. visit_block ( thn, ( ) ) ;
83
+
73
84
match els {
74
85
// if false { .. } else { .. }
75
86
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