File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
src/librustc_data_structures/obligation_forest Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -348,15 +348,16 @@ impl<O: ForestObligation> ObligationForest<O> {
348
348
349
349
/// Converts all remaining obligations to the given error.
350
350
pub fn to_errors < E : Clone > ( & mut self , error : E ) -> Vec < Error < O , E > > {
351
- let mut errors = vec ! [ ] ;
352
- for ( index , node) in self . nodes . iter ( ) . enumerate ( ) {
353
- if let NodeState :: Pending = node . state . get ( ) {
354
- errors . push ( Error {
351
+ let errors = self . nodes . iter ( ) . enumerate ( )
352
+ . filter ( | ( _index , node) | node . state . get ( ) == NodeState :: Pending )
353
+ . map ( | ( index , _node ) | {
354
+ Error {
355
355
error : error. clone ( ) ,
356
356
backtrace : self . error_at ( index) ,
357
- } ) ;
358
- }
359
- }
357
+ }
358
+ } )
359
+ . collect ( ) ;
360
+
360
361
let successful_obligations = self . compress ( DoCompleted :: Yes ) ;
361
362
assert ! ( successful_obligations. unwrap( ) . is_empty( ) ) ;
362
363
errors
@@ -366,10 +367,9 @@ impl<O: ForestObligation> ObligationForest<O> {
366
367
pub fn map_pending_obligations < P , F > ( & self , f : F ) -> Vec < P >
367
368
where F : Fn ( & O ) -> P
368
369
{
369
- self . nodes
370
- . iter ( )
371
- . filter ( |n| n. state . get ( ) == NodeState :: Pending )
372
- . map ( |n| f ( & n. obligation ) )
370
+ self . nodes . iter ( )
371
+ . filter ( |node| node. state . get ( ) == NodeState :: Pending )
372
+ . map ( |node| f ( & node. obligation ) )
373
373
. collect ( )
374
374
}
375
375
You can’t perform that action at this time.
0 commit comments