Skip to content

Commit 73bc754

Browse files
committed
Use is_some_and in compiler
1 parent 10f4ce3 commit 73bc754

File tree

107 files changed

+168
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+168
-152
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,10 +2274,10 @@ pub struct FnDecl {
22742274

22752275
impl FnDecl {
22762276
pub fn has_self(&self) -> bool {
2277-
self.inputs.get(0).map_or(false, Param::is_self)
2277+
self.inputs.get(0).is_some_and(|p| p.is_self())
22782278
}
22792279
pub fn c_variadic(&self) -> bool {
2280-
self.inputs.last().map_or(false, |arg| matches!(arg.ty.kind, TyKind::CVarArgs))
2280+
self.inputs.last().is_some_and(|arg| matches!(arg.ty.kind, TyKind::CVarArgs))
22812281
}
22822282
}
22832283

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl NestedMetaItem {
5757

5858
/// Returns `true` if this list item is a MetaItem with a name of `name`.
5959
pub fn has_name(&self, name: Symbol) -> bool {
60-
self.meta_item().map_or(false, |meta_item| meta_item.has_name(name))
60+
self.meta_item().is_some_and(|meta_item| meta_item.has_name(name))
6161
}
6262

6363
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
@@ -101,7 +101,7 @@ impl NestedMetaItem {
101101

102102
/// Returns `true` if `self` is a `MetaItem` and the meta item is a word.
103103
pub fn is_word(&self) -> bool {
104-
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
104+
self.meta_item().is_some_and(|meta_item| meta_item.is_word())
105105
}
106106

107107
/// See [`MetaItem::name_value_literal_span`].
@@ -266,7 +266,7 @@ impl Attribute {
266266
}
267267

268268
pub fn may_have_doc_links(&self) -> bool {
269-
self.doc_str().map_or(false, |s| comments::may_have_doc_links(s.as_str()))
269+
self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str()))
270270
}
271271

272272
pub fn get_normal_item(&self) -> &AttrItem {

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(const_default_impls)]
1414
#![feature(const_trait_impl)]
1515
#![feature(if_let_guard)]
16+
#![feature(is_some_with)]
1617
#![feature(label_break_value)]
1718
#![feature(let_chains)]
1819
#![feature(min_specialization)]

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl Token {
524524
/// Returns `true` if the token is an identifier whose name is the given
525525
/// string slice.
526526
pub fn is_ident_named(&self, name: Symbol) -> bool {
527-
self.ident().map_or(false, |(ident, _)| ident.name == name)
527+
self.ident().is_some_and(|(ident, _)| ident.name == name)
528528
}
529529

530530
/// Returns `true` if the token is an interpolated path.

compiler/rustc_ast/src/util/literal.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ fn integer_lit(symbol: Symbol, suffix: Option<Symbol>) -> Result<LitKind, LitErr
329329
// Small bases are lexed as if they were base 10, e.g, the string
330330
// might be `0b10201`. This will cause the conversion above to fail,
331331
// but these kinds of errors are already reported by the lexer.
332-
let from_lexer =
333-
base < 10 && s.chars().any(|c| c.to_digit(10).map_or(false, |d| d >= base));
332+
let from_lexer = base < 10 && s.chars().any(|c| c.to_digit(10).is_some_and(|&d| d >= base));
334333
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge }
335334
})
336335
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
4040
}
4141
ExprKind::Tup(ref elts) => hir::ExprKind::Tup(self.lower_exprs(elts)),
4242
ExprKind::Call(ref f, ref args) => {
43-
if e.attrs.get(0).map_or(false, |a| a.has_name(sym::rustc_box)) {
43+
if e.attrs.get(0).is_some_and(|a| a.has_name(sym::rustc_box)) {
4444
if let [inner] = &args[..] && e.attrs.len() == 1 {
4545
let kind = hir::ExprKind::Box(self.lower_expr(&inner));
4646
let hir_id = self.lower_node_id(e.id);

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
//! in the HIR, especially for multiple identifiers.
3232
3333
#![feature(box_patterns)]
34+
#![feature(is_some_with)]
3435
#![feature(let_chains)]
3536
#![feature(let_else)]
3637
#![feature(never_type)]

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
531531
match i.kind {
532532
ast::ForeignItemKind::Fn(..) | ast::ForeignItemKind::Static(..) => {
533533
let link_name = self.sess.first_attr_value_str_by_name(&i.attrs, sym::link_name);
534-
let links_to_llvm =
535-
link_name.map_or(false, |val| val.as_str().starts_with("llvm."));
534+
let links_to_llvm = link_name.is_some_and(|val| val.as_str().starts_with("llvm."));
536535
if links_to_llvm {
537536
gate_feature_post!(
538537
&self,

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![allow(rustc::potential_query_instability)]
88
#![feature(box_patterns)]
99
#![feature(if_let_guard)]
10+
#![feature(is_some_with)]
1011
#![feature(iter_is_partitioned)]
1112
#![feature(let_chains)]
1213
#![feature(let_else)]

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
8787
let path_span = path_span.unwrap();
8888
// path_span is only present in the case of closure capture
8989
assert!(matches!(later_use_kind, LaterUseKind::ClosureCapture));
90-
if !borrow_span.map_or(false, |sp| sp.overlaps(var_or_use_span)) {
90+
if !borrow_span.is_some_and(|sp| sp.overlaps(var_or_use_span)) {
9191
let path_label = "used here by closure";
9292
let capture_kind_label = message;
9393
err.span_label(
@@ -429,7 +429,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
429429
use_location: Location,
430430
) -> bool {
431431
let back_edge = self.reach_through_backedge(borrow_location, use_location);
432-
back_edge.map_or(false, |back_edge| self.can_reach_head_of_loop(use_location, back_edge))
432+
back_edge.is_some_and(|&back_edge| self.can_reach_head_of_loop(use_location, back_edge))
433433
}
434434

435435
/// Returns the outmost back edge if `from` location can reach `to` location passing through

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
#![allow(rustc::potential_query_instability)]
44
#![feature(box_patterns)]
5+
#![feature(is_some_with)]
56
#![feature(let_chains)]
67
#![feature(let_else)]
78
#![feature(min_specialization)]

compiler/rustc_borrowck/src/region_infer/values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<N: Idx> LivenessValues<N> {
155155
/// Returns `true` if the region `r` contains the given element.
156156
pub(crate) fn contains(&self, row: N, location: Location) -> bool {
157157
let index = self.elements.point_from_location(location);
158-
self.points.row(row).map_or(false, |r| r.contains(index))
158+
self.points.row(row).is_some_and(|r| r.contains(index))
159159
}
160160

161161
/// Returns an iterator of all the elements contained by the region `r`

compiler/rustc_builtin_macros/src/cfg_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'ast> visit::Visitor<'ast> for CfgFinder {
118118
self.has_cfg_or_cfg_attr = self.has_cfg_or_cfg_attr
119119
|| attr
120120
.ident()
121-
.map_or(false, |ident| ident.name == sym::cfg || ident.name == sym::cfg_attr);
121+
.is_some_and(|ident| ident.name == sym::cfg || ident.name == sym::cfg_attr);
122122
}
123123
}
124124

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![feature(box_patterns)]
88
#![feature(decl_macro)]
99
#![feature(if_let_guard)]
10+
#![feature(is_some_with)]
1011
#![feature(is_sorted)]
1112
#![feature(let_chains)]
1213
#![feature(let_else)]

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl CoverageMapGenerator {
175175
counter_regions.sort_unstable_by_key(|(_counter, region)| *region);
176176
for (counter, region) in counter_regions {
177177
let CodeRegion { file_name, start_line, start_col, end_line, end_col } = *region;
178-
let same_file = current_file_name.as_ref().map_or(false, |p| *p == file_name);
178+
let same_file = current_file_name.is_some_and(|&p| p == file_name);
179179
if !same_file {
180180
if current_file_name.is_some() {
181181
current_file_id += 1;

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![feature(is_some_with)]
89
#![feature(let_chains)]
910
#![feature(let_else)]
1011
#![feature(extern_types)]

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
22
#![feature(box_patterns)]
3+
#![feature(is_some_with)]
34
#![feature(try_blocks)]
45
#![feature(let_else)]
56
#![feature(once_cell)]

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
869869
});
870870

871871
let needs_location =
872-
instance.map_or(false, |i| i.def.requires_caller_location(self.cx.tcx()));
872+
instance.is_some_and(|i| i.def.requires_caller_location(self.cx.tcx()));
873873
if needs_location {
874874
let mir_args = if let Some(num_untupled) = num_untupled {
875875
first_args.len() + num_untupled

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
555555
if M::enforce_number_no_provenance(self.ecx) {
556556
// As a special exception we *do* match on a `Scalar` here, since we truly want
557557
// to know its underlying representation (and *not* cast it to an integer).
558-
let is_ptr = value.check_init().map_or(false, |v| matches!(v, Scalar::Ptr(..)));
558+
let is_ptr = value.check_init().is_ok_and(|v| matches!(v, Scalar::Ptr(..)));
559559
if is_ptr {
560560
throw_validation_failure!(self.path,
561561
{ "{:x}", value } expected { "plain (non-pointer) bytes" }

compiler/rustc_const_eval/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Rust MIR: a lowered representation of Rust.
99
#![feature(control_flow_enum)]
1010
#![feature(decl_macro)]
1111
#![feature(exact_size_is_empty)]
12+
#![feature(is_some_with)]
1213
#![feature(let_chains)]
1314
#![feature(let_else)]
1415
#![feature(map_try_insert)]

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
916916
// have no `rustc_const_stable` attributes to be const-unstable as well. This
917917
// should be fixed later.
918918
let callee_is_unstable_unmarked = tcx.lookup_const_stability(callee).is_none()
919-
&& tcx.lookup_stability(callee).map_or(false, |s| s.is_unstable());
919+
&& tcx.lookup_stability(callee).is_some_and(|s| s.is_unstable());
920920
if callee_is_unstable_unmarked {
921921
trace!("callee_is_unstable_unmarked");
922922
// We do not use `const` modifiers for intrinsic "functions", as intrinsics are

compiler/rustc_const_eval/src/transform/check_consts/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ fn is_parent_const_stable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
128128
return false;
129129
}
130130

131-
tcx.lookup_const_stability(parent.owner).map_or(false, |stab| stab.is_const_stable())
131+
tcx.lookup_const_stability(parent.owner).is_some_and(|stab| stab.is_const_stable())
132132
}

compiler/rustc_const_eval/src/util/call_kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn call_kind<'tcx>(
135135
ty::Adt(def, ..) => Some(def.did()),
136136
_ => None,
137137
});
138-
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
138+
let is_option_or_result = parent_self_ty.is_some_and(|&def_id| {
139139
matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result))
140140
});
141141
CallKind::Normal { self_arg, desugaring, is_option_or_result }

compiler/rustc_data_structures/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(let_else)]
1616
#![feature(hash_raw_entry)]
1717
#![feature(hasher_prefixfree_extras)]
18+
#![feature(is_some_with)]
1819
#![feature(maybe_uninit_uninit_array)]
1920
#![feature(min_specialization)]
2021
#![feature(never_type)]

compiler/rustc_data_structures/src/obligation_forest/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<O: ForestObligation> ObligationForest<O> {
348348
&& self
349349
.error_cache
350350
.get(&obligation_tree_id)
351-
.map_or(false, |errors| errors.contains(v.key()));
351+
.is_some_and(|errors| errors.contains(v.key()));
352352

353353
if already_failed {
354354
Err(())

compiler/rustc_driver/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![feature(is_some_with)]
89
#![feature(let_else)]
910
#![feature(once_cell)]
1011
#![recursion_limit = "256"]
@@ -1209,7 +1210,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
12091210
}
12101211

12111212
// If backtraces are enabled, also print the query stack
1212-
let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");
1213+
let backtrace = env::var_os("RUST_BACKTRACE").is_some_and(|x| x != "0");
12131214

12141215
let num_frames = if backtrace { None } else { Some(2) };
12151216

compiler/rustc_errors/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(drain_filter)]
77
#![feature(backtrace)]
88
#![feature(if_let_guard)]
9+
#![feature(is_some_with)]
910
#![feature(let_else)]
1011
#![feature(never_type)]
1112
#![feature(adt_const_params)]
@@ -1226,7 +1227,7 @@ impl HandlerInner {
12261227
fn treat_err_as_bug(&self) -> bool {
12271228
self.flags
12281229
.treat_err_as_bug
1229-
.map_or(false, |c| self.err_count() + self.lint_err_count >= c.get())
1230+
.is_some_and(|c| self.err_count() + self.lint_err_count >= c.get())
12301231
}
12311232

12321233
fn print_error_count(&mut self, registry: &Registry) {
@@ -1268,7 +1269,7 @@ impl HandlerInner {
12681269
.iter()
12691270
.filter_map(|x| match &x {
12701271
DiagnosticId::Error(s)
1271-
if registry.try_find_description(s).map_or(false, |o| o.is_some()) =>
1272+
if matches!(registry.try_find_description(s), Ok(Some(_))) =>
12721273
{
12731274
Some(s.clone())
12741275
}
@@ -1344,7 +1345,7 @@ impl HandlerInner {
13441345
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
13451346
// incrementing `err_count` by one, so we need to +1 the comparing.
13461347
// FIXME: Would be nice to increment err_count in a more coherent way.
1347-
if self.flags.treat_err_as_bug.map_or(false, |c| self.err_count() + 1 >= c.get()) {
1348+
if self.flags.treat_err_as_bug.is_some_and(|c| self.err_count() + 1 >= c.get()) {
13481349
// FIXME: don't abort here if report_delayed_bugs is off
13491350
self.span_bug(sp, msg);
13501351
}

compiler/rustc_expand/src/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
15461546
cfg_pos = Some(pos); // a cfg attr found, no need to search anymore
15471547
break;
15481548
} else if attr_pos.is_none()
1549-
&& !name.map_or(false, rustc_feature::is_builtin_attr_name)
1549+
&& !name.is_some_and(|&name| rustc_feature::is_builtin_attr_name(name))
15501550
{
15511551
attr_pos = Some(pos); // a non-cfg attr found, still may find a cfg attr
15521552
}
@@ -1594,7 +1594,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
15941594
let current_span = if let Some(sp) = span { sp.to(attr.span) } else { attr.span };
15951595
span = Some(current_span);
15961596

1597-
if attrs.peek().map_or(false, |next_attr| next_attr.doc_str().is_some()) {
1597+
if attrs.peek().is_some_and(|next_attr| next_attr.doc_str().is_some()) {
15981598
continue;
15991599
}
16001600

@@ -1883,6 +1883,6 @@ impl<'feat> ExpansionConfig<'feat> {
18831883
}
18841884

18851885
fn proc_macro_hygiene(&self) -> bool {
1886-
self.features.map_or(false, |features| features.proc_macro_hygiene)
1886+
self.features.is_some_and(|features| features.proc_macro_hygiene)
18871887
}
18881888
}

compiler/rustc_expand/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(associated_type_bounds)]
44
#![feature(associated_type_defaults)]
55
#![feature(if_let_guard)]
6+
#![feature(is_some_with)]
67
#![feature(let_chains)]
78
#![feature(let_else)]
89
#![feature(macro_metavar_expr)]

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
806806
}
807807

808808
pub fn is_builtin_only_local(name: Symbol) -> bool {
809-
BUILTIN_ATTRIBUTE_MAP.get(&name).map_or(false, |attr| attr.only_local)
809+
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some_and(|attr| attr.only_local)
810810
}
811811

812812
pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>> =

compiler/rustc_feature/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! symbol to the `accepted` or `removed` modules respectively.
1313
1414
#![feature(once_cell)]
15+
#![feature(is_some_with)]
1516

1617
mod accepted;
1718
mod active;
@@ -84,11 +85,11 @@ impl UnstableFeatures {
8485
let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
8586
// Returns whether `krate` should be counted as unstable
8687
let is_unstable_crate = |var: &str| {
87-
krate.map_or(false, |name| var.split(',').any(|new_krate| new_krate == name))
88+
krate.is_some_and(|&name| var.split(',').any(|new_krate| new_krate == name))
8889
};
8990
// `true` if we should enable unstable features for bootstrapping.
90-
let bootstrap = std::env::var("RUSTC_BOOTSTRAP")
91-
.map_or(false, |var| var == "1" || is_unstable_crate(&var));
91+
let bootstrap =
92+
std::env::var("RUSTC_BOOTSTRAP").is_ok_and(|var| var == "1" || is_unstable_crate(var));
9293
match (disable_unstable_features, bootstrap) {
9394
(_, true) => UnstableFeatures::Cheat,
9495
(true, _) => UnstableFeatures::Disallow,

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ pub struct WhereBoundPredicate<'hir> {
759759
impl<'hir> WhereBoundPredicate<'hir> {
760760
/// Returns `true` if `param_def_id` matches the `bounded_ty` of this predicate.
761761
pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
762-
self.bounded_ty.as_generic_param().map_or(false, |(def_id, _)| def_id == param_def_id)
762+
self.bounded_ty.as_generic_param().is_some_and(|&(def_id, _)| def_id == param_def_id)
763763
}
764764
}
765765

compiler/rustc_hir/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(closure_track_caller)]
77
#![feature(const_btree_new)]
88
#![feature(let_else)]
9+
#![feature(is_some_with)]
910
#![feature(once_cell)]
1011
#![feature(min_specialization)]
1112
#![feature(never_type)]

compiler/rustc_index/src/bit_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ impl<T: Idx> GrowableBitSet<T> {
15441544
#[inline]
15451545
pub fn contains(&self, elem: T) -> bool {
15461546
let (word_index, mask) = word_index_and_mask(elem);
1547-
self.bit_set.words.get(word_index).map_or(false, |word| (word & mask) != 0)
1547+
self.bit_set.words.get(word_index).is_some_and(|&word| (word & mask) != 0)
15481548
}
15491549
}
15501550

@@ -1808,7 +1808,7 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
18081808
/// if the matrix represents (transitive) reachability, can
18091809
/// `row` reach `column`?
18101810
pub fn contains(&self, row: R, column: C) -> bool {
1811-
self.row(row).map_or(false, |r| r.contains(column))
1811+
self.row(row).is_some_and(|r| r.contains(column))
18121812
}
18131813

18141814
/// Adds the bits from row `read` to the bits from row `write`, and

0 commit comments

Comments
 (0)