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+
111use super :: { ObligationForest , Outcome , Error } ;
212
313#[ test]
@@ -86,42 +96,46 @@ fn success_in_grandchildren() {
8696 let mut forest = ObligationForest :: new ( ) ;
8797 forest. push_root ( "A" ) ;
8898
89- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
90- match * obligation {
91- "A" => Ok ( Some ( vec ! [ "A.1" , "A.2" , "A.3" ] ) ) ,
92- _ => unreachable ! ( ) ,
93- }
94- } ) ;
99+ let Outcome { successful : ok, errors : err, .. } =
100+ forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
101+ match * obligation {
102+ "A" => Ok ( Some ( vec ! [ "A.1" , "A.2" , "A.3" ] ) ) ,
103+ _ => unreachable ! ( ) ,
104+ }
105+ } ) ;
95106 assert ! ( ok. is_empty( ) ) ;
96107 assert ! ( err. is_empty( ) ) ;
97108
98- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
99- match * obligation {
100- "A.1" => Ok ( Some ( vec ! [ ] ) ) ,
101- "A.2" => Ok ( Some ( vec ! [ "A.2.i" , "A.2.ii" ] ) ) ,
102- "A.3" => Ok ( Some ( vec ! [ ] ) ) ,
103- _ => unreachable ! ( ) ,
104- }
105- } ) ;
109+ let Outcome { successful : ok, errors : err, .. } =
110+ forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
111+ match * obligation {
112+ "A.1" => Ok ( Some ( vec ! [ ] ) ) ,
113+ "A.2" => Ok ( Some ( vec ! [ "A.2.i" , "A.2.ii" ] ) ) ,
114+ "A.3" => Ok ( Some ( vec ! [ ] ) ) ,
115+ _ => unreachable ! ( ) ,
116+ }
117+ } ) ;
106118 assert_eq ! ( ok, vec![ "A.3" , "A.1" ] ) ;
107119 assert ! ( err. is_empty( ) ) ;
108120
109- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
110- match * obligation {
111- "A.2.i" => Ok ( Some ( vec ! [ "A.2.i.a" ] ) ) ,
112- "A.2.ii" => Ok ( Some ( vec ! [ ] ) ) ,
113- _ => unreachable ! ( ) ,
114- }
115- } ) ;
121+ let Outcome { successful : ok, errors : err, .. } =
122+ forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
123+ match * obligation {
124+ "A.2.i" => Ok ( Some ( vec ! [ "A.2.i.a" ] ) ) ,
125+ "A.2.ii" => Ok ( Some ( vec ! [ ] ) ) ,
126+ _ => unreachable ! ( ) ,
127+ }
128+ } ) ;
116129 assert_eq ! ( ok, vec![ "A.2.ii" ] ) ;
117130 assert ! ( err. is_empty( ) ) ;
118131
119- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
120- match * obligation {
121- "A.2.i.a" => Ok ( Some ( vec ! [ ] ) ) ,
122- _ => unreachable ! ( ) ,
123- }
124- } ) ;
132+ let Outcome { successful : ok, errors : err, .. } =
133+ forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
134+ match * obligation {
135+ "A.2.i.a" => Ok ( Some ( vec ! [ ] ) ) ,
136+ _ => unreachable ! ( ) ,
137+ }
138+ } ) ;
125139 assert_eq ! ( ok, vec![ "A.2.i.a" , "A.2.i" , "A.2" , "A" ] ) ;
126140 assert ! ( err. is_empty( ) ) ;
127141
@@ -137,12 +151,13 @@ fn to_errors_no_throw() {
137151 // only yields one of them (and does not panic, in particular).
138152 let mut forest = ObligationForest :: new ( ) ;
139153 forest. push_root ( "A" ) ;
140- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
141- match * obligation {
142- "A" => Ok ( Some ( vec ! [ "A.1" , "A.2" , "A.3" ] ) ) ,
143- _ => unreachable ! ( ) ,
144- }
145- } ) ;
154+ let Outcome { successful : ok, errors : err, .. } =
155+ forest. process_obligations :: < ( ) , _ > ( |obligation, _| {
156+ match * obligation {
157+ "A" => Ok ( Some ( vec ! [ "A.1" , "A.2" , "A.3" ] ) ) ,
158+ _ => unreachable ! ( ) ,
159+ }
160+ } ) ;
146161 assert_eq ! ( ok. len( ) , 0 ) ;
147162 assert_eq ! ( err. len( ) , 0 ) ;
148163 let errors = forest. to_errors ( ( ) ) ;
@@ -155,34 +170,37 @@ fn backtrace() {
155170 // only yields one of them (and does not panic, in particular).
156171 let mut forest: ObligationForest < & ' static str > = ObligationForest :: new ( ) ;
157172 forest. push_root ( "A" ) ;
158- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, mut backtrace| {
159- assert ! ( backtrace. next( ) . is_none( ) ) ;
160- match * obligation {
161- "A" => Ok ( Some ( vec ! [ "A.1" ] ) ) ,
162- _ => unreachable ! ( ) ,
163- }
164- } ) ;
173+ let Outcome { successful : ok, errors : err, .. } =
174+ forest. process_obligations :: < ( ) , _ > ( |obligation, mut backtrace| {
175+ assert ! ( backtrace. next( ) . is_none( ) ) ;
176+ match * obligation {
177+ "A" => Ok ( Some ( vec ! [ "A.1" ] ) ) ,
178+ _ => unreachable ! ( ) ,
179+ }
180+ } ) ;
165181 assert ! ( ok. is_empty( ) ) ;
166182 assert ! ( err. is_empty( ) ) ;
167- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, mut backtrace| {
168- assert ! ( backtrace. next( ) . unwrap( ) == & "A" ) ;
169- assert ! ( backtrace. next( ) . is_none( ) ) ;
170- match * obligation {
171- "A.1" => Ok ( Some ( vec ! [ "A.1.i" ] ) ) ,
172- _ => unreachable ! ( ) ,
173- }
174- } ) ;
183+ let Outcome { successful : ok, errors : err, .. } =
184+ forest. process_obligations :: < ( ) , _ > ( |obligation, mut backtrace| {
185+ assert ! ( backtrace. next( ) . unwrap( ) == & "A" ) ;
186+ assert ! ( backtrace. next( ) . is_none( ) ) ;
187+ match * obligation {
188+ "A.1" => Ok ( Some ( vec ! [ "A.1.i" ] ) ) ,
189+ _ => unreachable ! ( ) ,
190+ }
191+ } ) ;
175192 assert ! ( ok. is_empty( ) ) ;
176193 assert ! ( err. is_empty( ) ) ;
177- let Outcome { successful : ok, errors : err, .. } = forest. process_obligations :: < ( ) , _ > ( |obligation, mut backtrace| {
178- assert ! ( backtrace. next( ) . unwrap( ) == & "A.1" ) ;
179- assert ! ( backtrace. next( ) . unwrap( ) == & "A" ) ;
180- assert ! ( backtrace. next( ) . is_none( ) ) ;
181- match * obligation {
182- "A.1.i" => Ok ( None ) ,
183- _ => unreachable ! ( ) ,
184- }
185- } ) ;
194+ let Outcome { successful : ok, errors : err, .. } =
195+ forest. process_obligations :: < ( ) , _ > ( |obligation, mut backtrace| {
196+ assert ! ( backtrace. next( ) . unwrap( ) == & "A.1" ) ;
197+ assert ! ( backtrace. next( ) . unwrap( ) == & "A" ) ;
198+ assert ! ( backtrace. next( ) . is_none( ) ) ;
199+ match * obligation {
200+ "A.1.i" => Ok ( None ) ,
201+ _ => unreachable ! ( ) ,
202+ }
203+ } ) ;
186204 assert_eq ! ( ok. len( ) , 0 ) ;
187205 assert ! ( err. is_empty( ) ) ;
188206}
0 commit comments