about summary refs log tree commit diff
path: root/src/librustc_interface
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-06 19:14:51 +0000
committerbors <bors@rust-lang.org>2019-12-06 19:14:51 +0000
commitae1b871cca56613b1af1a5121dd24ac810ff4b89 (patch)
tree74e64f30306a0f66e9a98cc1929802f77906c2ff /src/librustc_interface
parent9630dbbc3caca60f2482e6eae8904aa6bda54f93 (diff)
parentf1db60ca9513c1693974f0b27c55d21a39f438b0 (diff)
Auto merge of #65195 - varkor:to_option, r=Centril
Rename `bool::then_*` to `bool::to_option_*` and use where appropriate

Name change following https://github.com/rust-lang/rfcs/pull/2757. Also try it out throughout the compiler in places I think makes the code more readable.
Diffstat (limited to 'src/librustc_interface')
-rw-r--r--src/librustc_interface/lib.rs1
-rw-r--r--src/librustc_interface/passes.rs8
-rw-r--r--src/librustc_interface/queries.rs8
-rw-r--r--src/librustc_interface/util.rs12
4 files changed, 7 insertions, 22 deletions
diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs
index 76af4342f5c..9bb18788171 100644
--- a/src/librustc_interface/lib.rs
+++ b/src/librustc_interface/lib.rs
@@ -1,3 +1,4 @@
+#![feature(bool_to_option)]
 #![feature(box_syntax)]
 #![feature(set_stdio)]
 #![feature(nll)]
diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs
index 235184382c5..2a4bc41f850 100644
--- a/src/librustc_interface/passes.rs
+++ b/src/librustc_interface/passes.rs
@@ -547,13 +547,7 @@ fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool
 }
 
 fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
-    let check = |output_path: &PathBuf| {
-        if output_path.is_dir() {
-            Some(output_path.clone())
-        } else {
-            None
-        }
-    };
+    let check = |output_path: &PathBuf| output_path.is_dir().then(|| output_path.clone());
     check_output(output_paths, check)
 }
 
diff --git a/src/librustc_interface/queries.rs b/src/librustc_interface/queries.rs
index d1fbb949fb1..e429b4d101a 100644
--- a/src/librustc_interface/queries.rs
+++ b/src/librustc_interface/queries.rs
@@ -117,11 +117,9 @@ impl<'tcx> Queries<'tcx> {
 
     pub fn dep_graph_future(&self) -> Result<&Query<Option<DepGraphFuture>>> {
         self.dep_graph_future.compute(|| {
-            Ok(if self.session().opts.build_dep_graph() {
-                Some(rustc_incremental::load_dep_graph(self.session()))
-            } else {
-                None
-            })
+            Ok(self.session().opts.build_dep_graph().then(|| {
+                rustc_incremental::load_dep_graph(self.session())
+            }))
         })
     }
 
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
index d8e20e17ce8..8c225b83f40 100644
--- a/src/librustc_interface/util.rs
+++ b/src/librustc_interface/util.rs
@@ -107,11 +107,7 @@ const STACK_SIZE: usize = 16 * 1024 * 1024;
 fn get_stack_size() -> Option<usize> {
     // FIXME: Hacks on hacks. If the env is trying to override the stack size
     // then *don't* set it explicitly.
-    if env::var_os("RUST_MIN_STACK").is_none() {
-        Some(STACK_SIZE)
-    } else {
-        None
-    }
+    env::var_os("RUST_MIN_STACK").is_none().then_some(STACK_SIZE)
 }
 
 struct Sink(Arc<Mutex<Vec<u8>>>);
@@ -285,11 +281,7 @@ fn get_rustc_path_inner(bin_path: &str) -> Option<PathBuf> {
             } else {
                 "rustc"
             });
-            if candidate.exists() {
-                Some(candidate)
-            } else {
-                None
-            }
+            candidate.exists().then_some(candidate)
         })
         .next()
 }