X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fsession%2Fmod.rs;h=1ca60d54f7a3d0c935d15c444bb6ffd5f2367806;hb=37ba1071c626c43a5b85752b4ffcf6a87e2b745e;hp=8e06191f3dd7feee920c7bd4a449ba0623793361;hpb=894a8d574d0851edf70eba1404a97df535d31e29;p=rust.git diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 8e06191f3dd..1ca60d54f7a 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -698,8 +698,8 @@ pub fn sysroot<'a>(&'a self) -> &'a Path { match self.opts.maybe_sysroot { Some(ref sysroot) => sysroot, None => self.default_sysroot - .as_ref() - .expect("missing sysroot and default_sysroot in Session"), + .as_ref() + .expect("missing sysroot and default_sysroot in Session"), } } pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { @@ -722,14 +722,8 @@ pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { pub fn set_incr_session_load_dep_graph(&self, load: bool) { let mut incr_comp_session = self.incr_comp_session.borrow_mut(); - match *incr_comp_session { - IncrCompSession::Active { - ref mut load_dep_graph, - .. - } => { - *load_dep_graph = load; - } - _ => {} + if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session { + *load_dep_graph = load; } } @@ -867,9 +861,9 @@ pub fn print_perf_stats(&self) { /// This expends fuel if applicable, and records fuel if applicable. pub fn consider_optimizing String>(&self, crate_name: &str, msg: T) -> bool { let mut ret = true; - match self.optimization_fuel_crate { - Some(ref c) if c == crate_name => { - assert!(self.query_threads() == 1); + if let Some(ref c) = self.optimization_fuel_crate { + if c == crate_name { + assert_eq!(self.query_threads(), 1); let fuel = self.optimization_fuel_limit.get(); ret = fuel != 0; if fuel == 0 && !self.out_of_fuel.get() { @@ -879,14 +873,12 @@ pub fn consider_optimizing String>(&self, crate_name: &str, msg: T) - self.optimization_fuel_limit.set(fuel - 1); } } - _ => {} } - match self.print_fuel_crate { - Some(ref c) if c == crate_name => { - assert!(self.query_threads() == 1); + if let Some(ref c) = self.print_fuel_crate { + if c == crate_name { + assert_eq!(self.query_threads(), 1); self.print_fuel.set(self.print_fuel.get() + 1); } - _ => {} } ret } @@ -1103,14 +1095,11 @@ pub fn build_session_( source_map: Lrc, ) -> Session { let host_triple = TargetTriple::from_triple(config::host_triple()); - let host = match Target::search(&host_triple) { - Ok(t) => t, - Err(e) => { - span_diagnostic - .fatal(&format!("Error loading host specification: {}", e)) - .raise(); - } - }; + let host = Target::search(&host_triple).unwrap_or_else(|e| + span_diagnostic + .fatal(&format!("Error loading host specification: {}", e)) + .raise() + ); let target_cfg = config::build_target_config(&sopts, &span_diagnostic); let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map); @@ -1130,12 +1119,11 @@ pub fn build_session_( let print_fuel_crate = sopts.debugging_opts.print_fuel.clone(); let print_fuel = LockCell::new(0); - let working_dir = match env::current_dir() { - Ok(dir) => dir, - Err(e) => p_s.span_diagnostic + let working_dir = env::current_dir().unwrap_or_else(|e| + p_s.span_diagnostic .fatal(&format!("Current directory is invalid: {}", e)) - .raise(), - }; + .raise() + ); let working_dir = file_path_mapping.map_prefix(working_dir); let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {