Skip to content

Commit 1951d86

Browse files
committed
Manual cleanup of some is_{or_none|some_and} usages
1 parent 264fa0f commit 1951d86

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

compiler/rustc_errors/src/json.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ impl DiagnosticSpan {
463463
// is an empty string, increase the length to include the newline so we don't
464464
// leave an empty line
465465
if start.col.0 == 0
466-
&& suggestion.is_some_and(|(s, _)| s.is_empty())
466+
&& let Some((suggestion, _)) = suggestion
467+
&& suggestion.is_empty()
467468
&& let Ok(after) = je.sm.span_to_next_source(span)
468469
&& after.starts_with('\n')
469470
{

compiler/rustc_errors/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use std::backtrace::{Backtrace, BacktraceStatus};
3535
use std::borrow::Cow;
3636
use std::cell::Cell;
3737
use std::error::Report;
38+
use std::ffi::OsStr;
3839
use std::hash::Hash;
3940
use std::io::Write;
4041
use std::num::NonZero;
@@ -1717,7 +1718,7 @@ impl DiagCtxtInner {
17171718
let bugs: Vec<_> =
17181719
std::mem::take(&mut self.delayed_bugs).into_iter().map(|(b, _)| b).collect();
17191720

1720-
let backtrace = std::env::var_os("RUST_BACKTRACE").is_none_or(|x| &x != "0");
1721+
let backtrace = std::env::var_os("RUST_BACKTRACE").as_deref() != Some(OsStr::new("0"));
17211722
let decorate = backtrace || self.ice_file.is_none();
17221723
let mut out = self
17231724
.ice_file

compiler/rustc_metadata/src/creader.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
417417
// Any descendants of `std` should be private. These crates are usually not marked
418418
// private in metadata, so we ignore that field.
419419
if extern_private.is_none()
420-
&& dep_root.is_some_and(|d| STDLIB_STABLE_CRATES.contains(&d.name))
420+
&& let Some(dep) = dep_root
421+
&& STDLIB_STABLE_CRATES.contains(&dep.name)
421422
{
422423
return true;
423424
}

compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
9797
debug_assert!(prov.len() <= 1);
9898
if let Some(entry) = prov.first() {
9999
// If it overlaps with this byte, it is on this byte.
100-
debug_assert!(self.bytes.as_ref().is_none_or(|b| b.get(&offset).is_none()));
100+
debug_assert!(self.bytes.as_ref().is_none_or(|b| !b.contains_key(&offset)));
101101
Some(entry.1)
102102
} else {
103103
// Look up per-byte provenance.

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ pub fn suggest_constraining_type_params<'a>(
336336
.collect();
337337

338338
constraints
339-
.retain(|(_, def_id, _)| def_id.map_or(true, |def| !bound_trait_defs.contains(&def)));
339+
.retain(|(_, def_id, _)| def_id.is_none_or(|def| !bound_trait_defs.contains(&def)));
340340

341341
if constraints.is_empty() {
342342
continue;

compiler/rustc_session/src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ impl OutputTypes {
675675

676676
/// Returns `true` if user specified a name and not just produced type
677677
pub fn contains_explicit_name(&self, key: &OutputType) -> bool {
678-
self.0.get(key).is_some_and(|f| f.is_some())
678+
matches!(self.0.get(key), Some(Some(..)))
679679
}
680680

681681
pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option<OutFileName>> {
@@ -1951,7 +1951,7 @@ fn collect_print_requests(
19511951
matches: &getopts::Matches,
19521952
) -> Vec<PrintRequest> {
19531953
let mut prints = Vec::<PrintRequest>::new();
1954-
if cg.target_cpu.as_ref().is_some_and(|s| s == "help") {
1954+
if cg.target_cpu.as_deref() == Some("help") {
19551955
prints.push(PrintRequest { kind: PrintKind::TargetCPUs, out: OutFileName::Stdout });
19561956
cg.target_cpu = None;
19571957
};

compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ fn make_elided_region_spans_suggs<'a>(
420420

421421
let mut process_consecutive_brackets =
422422
|span: Option<Span>, spans_suggs: &mut Vec<(Span, String)>| {
423-
if span.is_some_and(|span| bracket_span.is_none_or(|bracket_span| span == bracket_span))
423+
if let Some(span) = span
424+
&& bracket_span.is_none_or(|bracket_span| span == bracket_span)
424425
{
425426
consecutive_brackets += 1;
426427
} else if let Some(bracket_span) = bracket_span.take() {

0 commit comments

Comments
 (0)