diff options
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_session/src/filesearch.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 4 |
4 files changed, 5 insertions, 9 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index e8bc19f88e3..b0bc199c832 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2544,7 +2544,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { } // Only use this directory if it has a file we can expect to always find. - if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None } + candidate.join("library/std/src/lib.rs").is_file().then(|| candidate) }; let working_dir = std::env::current_dir().unwrap_or_else(|e| { diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index c851145440b..093698f3b35 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -322,11 +322,7 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span: .take_while(|c| *c != 'i' && *c != 'u') .all(|c| c.to_digit(base).is_some()); - if valid { - Some(format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..])) - } else { - None - } + valid.then(|| format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..])) } let token::Lit { kind, symbol, suffix, .. } = lit; diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index b6a328908ce..855dde0a614 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -217,7 +217,7 @@ pub fn get_or_default_sysroot() -> Result<PathBuf, String> { // Look for the target rustlib directory in the suspected sysroot. let mut rustlib_path = rustc_target::target_rustlib_path(&p, "dummy"); rustlib_path.pop(); // pop off the dummy target. - if rustlib_path.exists() { Some(p) } else { None } + rustlib_path.exists().then(|| p) } None => None, } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index d9e68320f8f..03e9c95e132 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -809,7 +809,7 @@ mod parse { if v.is_some() { let mut bool_arg = None; if parse_opt_bool(&mut bool_arg, v) { - *slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None }; + *slot = bool_arg.unwrap().then(|| MirSpanview::Statement); return true; } } @@ -850,7 +850,7 @@ mod parse { if v.is_some() { let mut bool_arg = None; if parse_opt_bool(&mut bool_arg, v) { - *slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None }; + *slot = bool_arg.unwrap().then(|| InstrumentCoverage::All); return true; } } |
