@@ -703,8 +703,8 @@ impl Session {
703
703
match self . opts . maybe_sysroot {
704
704
Some ( ref sysroot) => sysroot,
705
705
None => self . default_sysroot
706
- . as_ref ( )
707
- . expect ( "missing sysroot and default_sysroot in Session" ) ,
706
+ . as_ref ( )
707
+ . expect ( "missing sysroot and default_sysroot in Session" ) ,
708
708
}
709
709
}
710
710
pub fn target_filesearch ( & self , kind : PathKind ) -> filesearch:: FileSearch < ' _ > {
@@ -727,14 +727,8 @@ impl Session {
727
727
pub fn set_incr_session_load_dep_graph ( & self , load : bool ) {
728
728
let mut incr_comp_session = self . incr_comp_session . borrow_mut ( ) ;
729
729
730
- match * incr_comp_session {
731
- IncrCompSession :: Active {
732
- ref mut load_dep_graph,
733
- ..
734
- } => {
735
- * load_dep_graph = load;
736
- }
737
- _ => { }
730
+ if let IncrCompSession :: Active { ref mut load_dep_graph, .. } = * incr_comp_session {
731
+ * load_dep_graph = load;
738
732
}
739
733
}
740
734
@@ -872,9 +866,9 @@ impl Session {
872
866
/// This expends fuel if applicable, and records fuel if applicable.
873
867
pub fn consider_optimizing < T : Fn ( ) -> String > ( & self , crate_name : & str , msg : T ) -> bool {
874
868
let mut ret = true ;
875
- match self . optimization_fuel_crate {
876
- Some ( ref c ) if c == crate_name => {
877
- assert ! ( self . query_threads( ) == 1 ) ;
869
+ if let Some ( ref c ) = self . optimization_fuel_crate {
870
+ if c == crate_name {
871
+ assert_eq ! ( self . query_threads( ) , 1 ) ;
878
872
let fuel = self . optimization_fuel_limit . get ( ) ;
879
873
ret = fuel != 0 ;
880
874
if fuel == 0 && !self . out_of_fuel . get ( ) {
@@ -884,14 +878,12 @@ impl Session {
884
878
self . optimization_fuel_limit . set ( fuel - 1 ) ;
885
879
}
886
880
}
887
- _ => { }
888
881
}
889
- match self . print_fuel_crate {
890
- Some ( ref c ) if c == crate_name => {
891
- assert ! ( self . query_threads( ) == 1 ) ;
882
+ if let Some ( ref c ) = self . print_fuel_crate {
883
+ if c == crate_name {
884
+ assert_eq ! ( self . query_threads( ) , 1 ) ;
892
885
self . print_fuel . set ( self . print_fuel . get ( ) + 1 ) ;
893
886
}
894
- _ => { }
895
887
}
896
888
ret
897
889
}
@@ -1108,14 +1100,11 @@ pub fn build_session_(
1108
1100
source_map : Lrc < source_map:: SourceMap > ,
1109
1101
) -> Session {
1110
1102
let host_triple = TargetTriple :: from_triple ( config:: host_triple ( ) ) ;
1111
- let host = match Target :: search ( & host_triple) {
1112
- Ok ( t) => t,
1113
- Err ( e) => {
1114
- span_diagnostic
1115
- . fatal ( & format ! ( "Error loading host specification: {}" , e) )
1116
- . raise ( ) ;
1117
- }
1118
- } ;
1103
+ let host = Target :: search ( & host_triple) . unwrap_or_else ( |e|
1104
+ span_diagnostic
1105
+ . fatal ( & format ! ( "Error loading host specification: {}" , e) )
1106
+ . raise ( )
1107
+ ) ;
1119
1108
let target_cfg = config:: build_target_config ( & sopts, & span_diagnostic) ;
1120
1109
1121
1110
let p_s = parse:: ParseSess :: with_span_handler ( span_diagnostic, source_map) ;
@@ -1135,12 +1124,11 @@ pub fn build_session_(
1135
1124
let print_fuel_crate = sopts. debugging_opts . print_fuel . clone ( ) ;
1136
1125
let print_fuel = LockCell :: new ( 0 ) ;
1137
1126
1138
- let working_dir = match env:: current_dir ( ) {
1139
- Ok ( dir) => dir,
1140
- Err ( e) => p_s. span_diagnostic
1127
+ let working_dir = env:: current_dir ( ) . unwrap_or_else ( |e|
1128
+ p_s. span_diagnostic
1141
1129
. fatal ( & format ! ( "Current directory is invalid: {}" , e) )
1142
- . raise ( ) ,
1143
- } ;
1130
+ . raise ( )
1131
+ ) ;
1144
1132
let working_dir = file_path_mapping. map_prefix ( working_dir) ;
1145
1133
1146
1134
let cgu_reuse_tracker = if sopts. debugging_opts . query_dep_graph {
0 commit comments