File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
compiler/rustc_interface/src Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 33#![ feature( file_buffered) ]
44#![ feature( iter_intersperse) ]
55#![ feature( let_chains) ]
6+ #![ feature( refcell_try_map) ]
67#![ feature( try_blocks) ]
78#![ warn( unreachable_pub) ]
89// tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -33,14 +33,16 @@ pub struct Query<T> {
3333
3434impl < T > Query < T > {
3535 fn compute < F : FnOnce ( ) -> Result < T > > ( & self , f : F ) -> Result < QueryResult < ' _ , T > > {
36- RefMut :: filter_map (
37- self . result . borrow_mut ( ) ,
38- |r : & mut Option < Result < Steal < T > > > | -> Option < & mut Steal < T > > {
39- r. get_or_insert_with ( || f ( ) . map ( Steal :: new) ) . as_mut ( ) . ok ( )
40- } ,
41- )
42- . map_err ( |r| * r. as_ref ( ) . unwrap ( ) . as_ref ( ) . map ( |_| ( ) ) . unwrap_err ( ) )
43- . map ( QueryResult )
36+ let result = RefMut :: try_map ( self . result . borrow_mut ( ) , |option| {
37+ match option. get_or_insert_with ( || f ( ) . map ( Steal :: new) ) {
38+ Ok ( steal) => Ok ( steal) ,
39+ & mut Err ( error) => Err ( error) ,
40+ }
41+ } ) ;
42+ match result {
43+ Ok ( r) => Ok ( QueryResult ( r) ) ,
44+ Err ( ( _, e) ) => Err ( e) ,
45+ }
4446 }
4547}
4648
You can’t perform that action at this time.
0 commit comments