Skip to content

Commit 5df4fb6

Browse files
is_{some,ok}_and
1 parent fe3038f commit 5df4fb6

File tree

9 files changed

+10
-13
lines changed

9 files changed

+10
-13
lines changed

compiler/rustc_codegen_cranelift/build_system/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl Drop for LogGroup {
290290
}
291291

292292
pub(crate) fn maybe_incremental(cmd: &mut Command) {
293-
if is_ci() || std::env::var("CARGO_BUILD_INCREMENTAL").map_or(false, |val| val == "false") {
293+
if is_ci() || std::env::var("CARGO_BUILD_INCREMENTAL").is_some_and(|val| val == "false") {
294294
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
295295
cmd.env("CARGO_BUILD_INCREMENTAL", "false");
296296
} else {

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
9191

9292
// This opaque also needs to be from the impl method -- otherwise,
9393
// it's a refinement to a TAIT.
94-
if !tcx.hir().get_if_local(impl_opaque.def_id).map_or(false, |node| {
94+
if !tcx.hir().get_if_local(impl_opaque.def_id).is_some_and(|node| {
9595
matches!(
9696
node.expect_item().expect_opaque_ty().origin,
9797
hir::OpaqueTyOrigin::AsyncFn(def_id) | hir::OpaqueTyOrigin::FnReturn(def_id)

compiler/rustc_lint/src/levels.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
736736
if attr.has_name(sym::doc)
737737
&& attr
738738
.meta_item_list()
739-
.map_or(false, |l| ast::attr::list_contains_name(&l, sym::hidden))
739+
.is_some_and(|l| ast::attr::list_contains_name(&l, sym::hidden))
740740
{
741741
self.insert(LintId::of(MISSING_DOCS), (Level::Allow, LintLevelSource::Default));
742742
continue;

compiler/rustc_middle/src/ty/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl<'tcx> TyCtxt<'tcx> {
792792
// If `extern_crate` is `None`, then the crate was injected (e.g., by the allocator).
793793
// Treat that kind of crate as "indirect", since it's an implementation detail of
794794
// the language.
795-
|| self.extern_crate(key.as_def_id()).map_or(false, |e| e.is_direct())
795+
|| self.extern_crate(key.as_def_id()).is_some_and(|e| e.is_direct())
796796
}
797797
}
798798

compiler/rustc_mir_build/src/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ impl UnsafeOpKind {
552552
) {
553553
let parent_id = tcx.hir().get_parent_item(hir_id);
554554
let parent_owner = tcx.hir().owner(parent_id);
555-
let should_suggest = parent_owner.fn_sig().map_or(false, |sig| sig.header.is_unsafe());
555+
let should_suggest = parent_owner.fn_sig().is_some_and(|sig| sig.header.is_unsafe());
556556
let unsafe_not_inherited_note = if should_suggest {
557557
suggest_unsafe_block.then(|| {
558558
let body_span = tcx.hir().body(parent_owner.body_id().unwrap()).value.span;

compiler/rustc_mir_dataflow/src/value_analysis.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ impl Map {
823823
) {
824824
// Allocate a value slot if it doesn't have one, and the user requested one.
825825
assert!(self.places[place].value_index.is_none());
826-
if tcx.layout_of(param_env.and(ty)).map_or(false, |layout| layout.abi.is_scalar()) {
826+
if tcx.layout_of(param_env.and(ty)).is_ok_and(|layout| layout.abi.is_scalar()) {
827827
self.places[place].value_index = Some(self.value_count.into());
828828
self.value_count += 1;
829829
}

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
18691869
),
18701870
};
18711871

1872-
fields.map_or(false, |fields| {
1872+
fields.is_some_and(|fields| {
18731873
fields
18741874
.iter()
18751875
.filter(|vis| !self.r.is_accessible_from(**vis, self.parent_scope.module))

compiler/rustc_trait_selection/src/traits/coherence.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,11 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
362362

363363
obligations.iter().find(|obligation| {
364364
if infcx.next_trait_solver() {
365-
infcx.evaluate_obligation(obligation).map_or(false, |result| !result.may_apply())
365+
infcx.evaluate_obligation(obligation).is_ok_and(|result| !result.may_apply())
366366
} else {
367367
// We use `evaluate_root_obligation` to correctly track intercrate
368368
// ambiguity clauses. We cannot use this in the new solver.
369-
selcx.evaluate_root_obligation(obligation).map_or(
370-
false, // Overflow has occurred, and treat the obligation as possibly holding.
371-
|result| !result.may_apply(),
372-
)
369+
selcx.evaluate_root_obligation(obligation).is_ok_and(|result| !result.may_apply())
373370
}
374371
})
375372
}

compiler/stable_mir/src/mir/mono.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Instance {
4040

4141
pub fn is_foreign_item(&self) -> bool {
4242
let item = CrateItem::try_from(*self);
43-
item.as_ref().map_or(false, CrateItem::is_foreign_item)
43+
item.as_ref().is_ok_and(CrateItem::is_foreign_item)
4444
}
4545

4646
/// Get the instance type with generic substitutions applied and lifetimes erased.

0 commit comments

Comments
 (0)