about summary refs log tree commit diff
path: root/src/libsyntax
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/libsyntax
parent9630dbbc3caca60f2482e6eae8904aa6bda54f93 (diff)
parentf1db60ca9513c1693974f0b27c55d21a39f438b0 (diff)
downloadrust-ae1b871cca56613b1af1a5121dd24ac810ff4b89.tar.gz
rust-ae1b871cca56613b1af1a5121dd24ac810ff4b89.zip
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/libsyntax')
-rw-r--r--src/libsyntax/lib.rs1
-rw-r--r--src/libsyntax/print/pprust.rs2
-rw-r--r--src/libsyntax/util/lev_distance.rs2
3 files changed, 3 insertions, 2 deletions
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index a94742634cf..36173801eae 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -7,6 +7,7 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
        test(attr(deny(warnings))))]
 
+#![feature(bool_to_option)]
 #![feature(box_syntax)]
 #![feature(const_fn)]
 #![feature(const_transmute)]
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 4821bbd9ec6..b2e8d8526fd 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -317,7 +317,7 @@ pub fn token_to_string(token: &Token) -> String {
 }
 
 fn token_to_string_ext(token: &Token, convert_dollar_crate: bool) -> String {
-    let convert_dollar_crate = if convert_dollar_crate { Some(token.span) } else { None };
+    let convert_dollar_crate = convert_dollar_crate.then_some(token.span);
     token_kind_to_string_ext(&token.kind, convert_dollar_crate)
 }
 
diff --git a/src/libsyntax/util/lev_distance.rs b/src/libsyntax/util/lev_distance.rs
index 4127a8c7fce..efb3c2396c3 100644
--- a/src/libsyntax/util/lev_distance.rs
+++ b/src/libsyntax/util/lev_distance.rs
@@ -77,6 +77,6 @@ pub fn find_best_match_for_name<'a, T>(iter_names: T,
     if let Some(candidate) = case_insensitive_match {
         Some(candidate) // exact case insensitive match has a higher priority
     } else {
-        if let Some((candidate, _)) = levenstein_match { Some(candidate) } else { None }
+        levenstein_match.map(|(candidate, _)| candidate)
     }
 }