File tree Expand file tree Collapse file tree 6 files changed +98
-11
lines changed Expand file tree Collapse file tree 6 files changed +98
-11
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8- refs/heads/try2: e9ff91e9beb6c92d9662242c1090c507b1611c59
8+ refs/heads/try2: 38ed4674e8054ee854871303401bffed7c05b01b
99refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -126,9 +126,9 @@ ifdef TRACE
126126endif
127127ifdef CFG_DISABLE_RPATH
128128# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
129- RUSTFLAGS_STAGE1 += -- no-rpath
130- RUSTFLAGS_STAGE2 += -- no-rpath
131- RUSTFLAGS_STAGE3 += -- no-rpath
129+ RUSTFLAGS_STAGE1 += -C no-rpath
130+ RUSTFLAGS_STAGE2 += -C no-rpath
131+ RUSTFLAGS_STAGE3 += -C no-rpath
132132endif
133133
134134# The executables crated during this compilation process have no need to include
Original file line number Diff line number Diff line change @@ -63,6 +63,26 @@ pub fn find<T:Clone>(ls: @List<T>, f: |&T| -> bool) -> Option<T> {
6363 } ;
6464}
6565
66+ /**
67+ * Returns true if a list contains an element that matches a given predicate
68+ *
69+ * Apply function `f` to each element of `ls`, starting from the first.
70+ * When function `f` returns true then it also returns true. If `f` matches no
71+ * elements then false is returned.
72+ */
73+ pub fn any < T > ( ls : @List < T > , f: |& T | -> bool) -> bool {
74+ let mut ls = ls;
75+ loop {
76+ ls = match * ls {
77+ Cons ( ref hd, tl) => {
78+ if f ( hd) { return true ; }
79+ tl
80+ }
81+ Nil => return false
82+ }
83+ } ;
84+ }
85+
6686/// Returns true if a list contains an element with the given value
6787pub fn has < T : Eq > ( ls : @List < T > , elt : T ) -> bool {
6888 let mut found = false ;
@@ -222,6 +242,15 @@ mod tests {
222242 assert_eq ! ( list:: find( empty, match_) , option:: None :: <int>) ;
223243 }
224244
245+ #[ test]
246+ fn test_any ( ) {
247+ fn match_ ( i : & int ) -> bool { return * i == 2 ; }
248+ let l = from_vec ( [ 0 , 1 , 2 ] ) ;
249+ let empty = @list:: Nil :: < int > ;
250+ assert_eq ! ( list:: any( l, match_) , true ) ;
251+ assert_eq ! ( list:: any( empty, match_) , false ) ;
252+ }
253+
225254 #[ test]
226255 fn test_has ( ) {
227256 let l = from_vec ( [ 5 , 8 , 6 ] ) ;
Original file line number Diff line number Diff line change @@ -1506,16 +1506,19 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
15061506 // emitting should be enabled.
15071507 debuginfo:: start_emitting_source_locations( & fcx) ;
15081508
1509+ let dest = match fcx. llretptr. get( ) {
1510+ Some ( e) => { expr:: SaveIn ( e) }
1511+ None => {
1512+ assert!( type_is_zero_size( bcx. ccx( ) , block_ty) )
1513+ expr:: Ignore
1514+ }
1515+ } ;
1516+
15091517 // This call to trans_block is the place where we bridge between
15101518 // translation calls that don't have a return value (trans_crate,
15111519 // trans_mod, trans_item, et cetera) and those that do
15121520 // (trans_block, trans_expr, et cetera).
1513- if body. expr. is_none( ) || type_is_zero_size( bcx. ccx( ) , block_ty) {
1514- bcx = controlflow:: trans_block( bcx, body, expr:: Ignore ) ;
1515- } else {
1516- let dest = expr:: SaveIn ( fcx. llretptr. get( ) . unwrap( ) ) ;
1517- bcx = controlflow:: trans_block ( bcx , body , dest ) ;
1518- }
1521+ bcx = controlflow:: trans_block( bcx, body, dest) ;
15191522
15201523 match fcx. llreturn. get( ) {
15211524 Some ( _) => {
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
7474
7575pub fn trans_block < ' a > ( bcx : & ' a Block < ' a > ,
7676 b : & ast:: Block ,
77- dest : expr:: Dest )
77+ mut dest : expr:: Dest )
7878 -> & ' a Block < ' a > {
7979 let _icx = push_ctxt ( "trans_block" ) ;
8080 let fcx = bcx. fcx ;
@@ -85,6 +85,14 @@ pub fn trans_block<'a>(bcx: &'a Block<'a>,
8585 for s in b. stmts . iter ( ) {
8686 bcx = trans_stmt ( bcx, * s) ;
8787 }
88+
89+ if dest != expr:: Ignore {
90+ let block_ty = node_id_type ( bcx, b. id ) ;
91+ if b. expr . is_none ( ) || type_is_zero_size ( bcx. ccx ( ) , block_ty) {
92+ dest = expr:: Ignore ;
93+ }
94+ }
95+
8896 match b. expr {
8997 Some ( e) => {
9098 bcx = expr:: trans_into ( bcx, e, dest) ;
Original file line number Diff line number Diff line change 1+ // Copyright 2014 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+ // xfail-pretty
12+
13+ // Don't fail on blocks without results
14+ // There are several tests in this run-pass that raised
15+ // when this bug was oppened. The cases where the compiler
16+ // failed before the fix have a comment.
17+
18+ struct S { x : ( ) }
19+
20+
21+ fn test ( slot : & mut Option < proc ( ) -> proc ( ) > , _: proc ( ) ) -> ( ) {
22+ let a = slot. take ( ) ;
23+ let _a = match a {
24+ // `{let .. a(); }` would break
25+ Some ( a) => { let _a = a ( ) ; } ,
26+ None => ( ) ,
27+ } ;
28+ }
29+
30+ fn not ( b : bool ) -> bool {
31+ if b {
32+ !b
33+ } else {
34+ // `fail!(...)` would break
35+ fail ! ( "Break the compiler" ) ;
36+ }
37+ }
38+
39+ pub fn main ( ) {
40+ // {} would break
41+ let _r = { } ;
42+ let mut slot = None ;
43+ // `{ test(...); }` would break
44+ let _s : S = S { x : { test ( & mut slot, proc ( ) { } ) ; } } ;
45+
46+ let _b = not ( true ) ;
47+ }
You can’t perform that action at this time.
0 commit comments