Skip to content

Commit d0b3ebe

Browse files
authored
Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, r=petrochenkov
Use `Option::is_some_and` and `Result::is_ok_and` in the compiler `.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable. This PR is a sibling of #111873 (comment)
2 parents 33ded73 + 307799a commit d0b3ebe

File tree

97 files changed

+201
-246
lines changed

Some content is hidden

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

97 files changed

+201
-246
lines changed

compiler/rustc_ast/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2391,10 +2391,10 @@ pub struct FnDecl {
23912391

23922392
impl FnDecl {
23932393
pub fn has_self(&self) -> bool {
2394-
self.inputs.get(0).map_or(false, Param::is_self)
2394+
self.inputs.get(0).is_some_and(Param::is_self)
23952395
}
23962396
pub fn c_variadic(&self) -> bool {
2397-
self.inputs.last().map_or(false, |arg| matches!(arg.ty.kind, TyKind::CVarArgs))
2397+
self.inputs.last().is_some_and(|arg| matches!(arg.ty.kind, TyKind::CVarArgs))
23982398
}
23992399
}
24002400

compiler/rustc_ast/src/attr/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl Attribute {
149149
}
150150

151151
pub fn may_have_doc_links(&self) -> bool {
152-
self.doc_str().map_or(false, |s| comments::may_have_doc_links(s.as_str()))
152+
self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str()))
153153
}
154154

155155
pub fn is_proc_macro_attr(&self) -> bool {
@@ -441,12 +441,12 @@ impl NestedMetaItem {
441441

442442
/// Returns `true` if this list item is a MetaItem with a name of `name`.
443443
pub fn has_name(&self, name: Symbol) -> bool {
444-
self.meta_item().map_or(false, |meta_item| meta_item.has_name(name))
444+
self.meta_item().is_some_and(|meta_item| meta_item.has_name(name))
445445
}
446446

447447
/// Returns `true` if `self` is a `MetaItem` and the meta item is a word.
448448
pub fn is_word(&self) -> bool {
449-
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
449+
self.meta_item().is_some_and(|meta_item| meta_item.is_word())
450450
}
451451

452452
/// Gets a list of inner meta items from a list `MetaItem` type.

compiler/rustc_ast/src/token.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl Token {
607607
/// Returns `true` if the token is an identifier whose name is the given
608608
/// string slice.
609609
pub fn is_ident_named(&self, name: Symbol) -> bool {
610-
self.ident().map_or(false, |(ident, _)| ident.name == name)
610+
self.ident().is_some_and(|(ident, _)| ident.name == name)
611611
}
612612

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

compiler/rustc_ast/src/util/literal.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ fn integer_lit(symbol: Symbol, suffix: Option<Symbol>) -> Result<LitKind, LitErr
392392
// Small bases are lexed as if they were base 10, e.g, the string
393393
// might be `0b10201`. This will cause the conversion above to fail,
394394
// but these kinds of errors are already reported by the lexer.
395-
let from_lexer =
396-
base < 10 && s.chars().any(|c| c.to_digit(10).map_or(false, |d| d >= base));
395+
let from_lexer = base < 10 && s.chars().any(|c| c.to_digit(10).is_some_and(|d| d >= base));
397396
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge(base) }
398397
})
399398
}

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'a> AstValidator<'a> {
348348
let source_map = self.session.source_map();
349349
let end = source_map.end_point(sp);
350350

351-
if source_map.span_to_snippet(end).map(|s| s == ";").unwrap_or(false) {
351+
if source_map.span_to_snippet(end).is_ok_and(|s| s == ";") {
352352
end
353353
} else {
354354
sp.shrink_to_hi()

compiler/rustc_ast_passes/src/feature_gate.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
317317
match i.kind {
318318
ast::ForeignItemKind::Fn(..) | ast::ForeignItemKind::Static(..) => {
319319
let link_name = attr::first_attr_value_str_by_name(&i.attrs, sym::link_name);
320-
let links_to_llvm =
321-
link_name.map_or(false, |val| val.as_str().starts_with("llvm."));
320+
let links_to_llvm = link_name.is_some_and(|val| val.as_str().starts_with("llvm."));
322321
if links_to_llvm {
323322
gate_feature_post!(
324323
&self,

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
118118
let path_span = path_span.unwrap();
119119
// path_span is only present in the case of closure capture
120120
assert!(matches!(later_use_kind, LaterUseKind::ClosureCapture));
121-
if !borrow_span.map_or(false, |sp| sp.overlaps(var_or_use_span)) {
121+
if !borrow_span.is_some_and(|sp| sp.overlaps(var_or_use_span)) {
122122
let path_label = "used here by closure";
123123
let capture_kind_label = message;
124124
err.span_label(
@@ -224,12 +224,9 @@ impl<'tcx> BorrowExplanation<'tcx> {
224224
if info.tail_result_is_ignored {
225225
// #85581: If the first mutable borrow's scope contains
226226
// the second borrow, this suggestion isn't helpful.
227-
if !multiple_borrow_span
228-
.map(|(old, new)| {
229-
old.to(info.span.shrink_to_hi()).contains(new)
230-
})
231-
.unwrap_or(false)
232-
{
227+
if !multiple_borrow_span.is_some_and(|(old, new)| {
228+
old.to(info.span.shrink_to_hi()).contains(new)
229+
}) {
233230
err.span_suggestion_verbose(
234231
info.span.shrink_to_hi(),
235232
"consider adding semicolon after the expression so its \

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11561156
ty::Adt(def, ..) => Some(def.did()),
11571157
_ => None,
11581158
});
1159-
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
1159+
let is_option_or_result = parent_self_ty.is_some_and(|def_id| {
11601160
matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result))
11611161
});
11621162
if is_option_or_result && maybe_reinitialized_locations_is_empty {

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
289289
.body
290290
.local_decls
291291
.get(local)
292-
.map(|l| mut_borrow_of_mutable_ref(l, self.local_names[local]))
293-
.unwrap_or(false) =>
292+
.is_some_and(|l| mut_borrow_of_mutable_ref(l, self.local_names[local])) =>
294293
{
295294
let decl = &self.body.local_decls[local];
296295
err.span_label(span, format!("cannot {act}"));
@@ -443,7 +442,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
443442
.sess
444443
.source_map()
445444
.span_to_snippet(span)
446-
.map_or(false, |snippet| snippet.starts_with("&mut ")) =>
445+
.is_ok_and(|snippet| snippet.starts_with("&mut ")) =>
447446
{
448447
err.span_label(span, format!("cannot {act}"));
449448
err.span_suggestion(

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ impl OutlivesSuggestionBuilder {
125125
|(r, _)| {
126126
self.constraints_to_add
127127
.get(r)
128-
.map(|r_outlived| r_outlived.as_slice().contains(fr))
129-
.unwrap_or(false)
128+
.is_some_and(|r_outlived| r_outlived.as_slice().contains(fr))
130129
},
131130
);
132131

compiler/rustc_borrowck/src/region_infer/values.rs

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

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

compiler/rustc_builtin_macros/src/cfg_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<'ast> visit::Visitor<'ast> for CfgFinder {
119119
self.has_cfg_or_cfg_attr = self.has_cfg_or_cfg_attr
120120
|| attr
121121
.ident()
122-
.map_or(false, |ident| ident.name == sym::cfg || ident.name == sym::cfg_attr);
122+
.is_some_and(|ident| ident.name == sym::cfg || ident.name == sym::cfg_attr);
123123
}
124124
}
125125

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
432432
let is_cold = if fn_sig.abi() == Abi::RustCold {
433433
true
434434
} else {
435-
instance
436-
.map(|inst| {
437-
fx.tcx.codegen_fn_attrs(inst.def_id()).flags.contains(CodegenFnAttrFlags::COLD)
438-
})
439-
.unwrap_or(false)
435+
instance.is_some_and(|inst| {
436+
fx.tcx.codegen_fn_attrs(inst.def_id()).flags.contains(CodegenFnAttrFlags::COLD)
437+
})
440438
};
441439
if is_cold {
442440
fx.bcx.set_cold_block(fx.bcx.current_block().unwrap());
@@ -470,7 +468,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
470468
};
471469

472470
// Pass the caller location for `#[track_caller]`.
473-
if instance.map(|inst| inst.def.requires_caller_location(fx.tcx)).unwrap_or(false) {
471+
if instance.is_some_and(|inst| inst.def.requires_caller_location(fx.tcx)) {
474472
let caller_location = fx.get_caller_location(source_info);
475473
args.push(CallArgument { value: caller_location, is_owned: false });
476474
}

compiler/rustc_codegen_cranelift/src/base.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,11 @@ fn codegen_stmt<'tcx>(
630630
let to_ty = fx.monomorphize(to_ty);
631631

632632
fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
633-
ty.builtin_deref(true)
634-
.map(|ty::TypeAndMut { ty: pointee_ty, mutbl: _ }| {
633+
ty.builtin_deref(true).is_some_and(
634+
|ty::TypeAndMut { ty: pointee_ty, mutbl: _ }| {
635635
has_ptr_meta(fx.tcx, pointee_ty)
636-
})
637-
.unwrap_or(false)
636+
},
637+
)
638638
}
639639

640640
if is_fat_ptr(fx, from_ty) {

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl CoverageMapGenerator {
163163
counter_regions.sort_unstable_by_key(|(_counter, region)| *region);
164164
for (counter, region) in counter_regions {
165165
let CodeRegion { file_name, start_line, start_col, end_line, end_col } = *region;
166-
let same_file = current_file_name.map_or(false, |p| p == file_name);
166+
let same_file = current_file_name.is_some_and(|p| p == file_name);
167167
if !same_file {
168168
if current_file_name.is_some() {
169169
current_file_id += 1;

compiler/rustc_codegen_llvm/src/mono_item.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ impl CodegenCx<'_, '_> {
125125

126126
// Thread-local variables generally don't support copy relocations.
127127
let is_thread_local_var = llvm::LLVMIsAGlobalVariable(llval)
128-
.map(|v| llvm::LLVMIsThreadLocal(v) == llvm::True)
129-
.unwrap_or(false);
128+
.is_some_and(|v| llvm::LLVMIsThreadLocal(v) == llvm::True);
130129
if is_thread_local_var {
131130
return false;
132131
}

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10311031
});
10321032

10331033
let needs_location =
1034-
instance.map_or(false, |i| i.def.requires_caller_location(self.cx.tcx()));
1034+
instance.is_some_and(|i| i.def.requires_caller_location(self.cx.tcx()));
10351035
if needs_location {
10361036
let mir_args = if let Some(num_untupled) = num_untupled {
10371037
first_args.len() + num_untupled

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
944944
tcx.features().declared_lib_features.iter().any(|&(sym, _)| sym == gate)
945945
};
946946
let feature_gate_declared = gate_declared(gate);
947-
let implied_gate_declared = implied_by.map(gate_declared).unwrap_or(false);
947+
let implied_gate_declared = implied_by.is_some_and(gate_declared);
948948
if !feature_gate_declared && !implied_gate_declared {
949949
self.check_op(ops::FnCallUnstable(callee, Some(gate)));
950950
return;
@@ -971,7 +971,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
971971
// have no `rustc_const_stable` attributes to be const-unstable as well. This
972972
// should be fixed later.
973973
let callee_is_unstable_unmarked = tcx.lookup_const_stability(callee).is_none()
974-
&& tcx.lookup_stability(callee).map_or(false, |s| s.is_unstable());
974+
&& tcx.lookup_stability(callee).is_some_and(|s| s.is_unstable());
975975
if callee_is_unstable_unmarked {
976976
trace!("callee_is_unstable_unmarked");
977977
// We do not use `const` modifiers for intrinsic "functions", as intrinsics are

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,5 @@ fn is_parent_const_stable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
139139
return false;
140140
}
141141

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

compiler/rustc_data_structures/src/obligation_forest/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<O: ForestObligation> ObligationForest<O> {
366366
&& self
367367
.error_cache
368368
.get(&obligation_tree_id)
369-
.map_or(false, |errors| errors.contains(v.key()));
369+
.is_some_and(|errors| errors.contains(v.key()));
370370

371371
if already_failed {
372372
Err(())

compiler/rustc_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, extra_info:
13151315
}
13161316

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

13201320
let num_frames = if backtrace { None } else { Some(2) };
13211321

compiler/rustc_errors/src/emitter.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,11 @@ pub trait Emitter: Translate {
285285
format!(
286286
"help: {}{}: `{}`",
287287
&msg,
288-
if self
289-
.source_map()
290-
.map(|sm| is_case_difference(
291-
sm,
292-
substitution,
293-
sugg.substitutions[0].parts[0].span,
294-
))
295-
.unwrap_or(false)
296-
{
288+
if self.source_map().is_some_and(|sm| is_case_difference(
289+
sm,
290+
substitution,
291+
sugg.substitutions[0].parts[0].span,
292+
)) {
297293
" (notice the capitalization)"
298294
} else {
299295
""

compiler/rustc_errors/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ impl HandlerInner {
14371437
}
14381438

14391439
fn treat_err_as_bug(&self) -> bool {
1440-
self.flags.treat_err_as_bug.map_or(false, |c| {
1440+
self.flags.treat_err_as_bug.is_some_and(|c| {
14411441
self.err_count() + self.lint_err_count + self.delayed_bug_count() >= c.get()
14421442
})
14431443
}
@@ -1603,7 +1603,7 @@ impl HandlerInner {
16031603
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
16041604
// incrementing `err_count` by one, so we need to +1 the comparing.
16051605
// FIXME: Would be nice to increment err_count in a more coherent way.
1606-
if self.flags.treat_err_as_bug.map_or(false, |c| {
1606+
if self.flags.treat_err_as_bug.is_some_and(|c| {
16071607
self.err_count() + self.lint_err_count + self.delayed_bug_count() + 1 >= c.get()
16081608
}) {
16091609
// FIXME: don't abort here if report_delayed_bugs is off

compiler/rustc_expand/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ impl SyntaxExtension {
780780
let allow_internal_unsafe = attr::contains_name(attrs, sym::allow_internal_unsafe);
781781
let local_inner_macros = attr::find_by_name(attrs, sym::macro_export)
782782
.and_then(|macro_export| macro_export.meta_item_list())
783-
.map_or(false, |l| attr::list_contains_name(&l, sym::local_inner_macros));
783+
.is_some_and(|l| attr::list_contains_name(&l, sym::local_inner_macros));
784784
let collapse_debuginfo = attr::contains_name(attrs, sym::collapse_debuginfo);
785785
tracing::debug!(?local_inner_macros, ?collapse_debuginfo, ?allow_internal_unsafe);
786786

@@ -1449,7 +1449,7 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool {
14491449
&& version
14501450
.next()
14511451
.and_then(|c| c.parse::<u32>().ok())
1452-
.map_or(false, |v| v < 6)
1452+
.is_some_and(|v| v < 6)
14531453
};
14541454

14551455
if crate_matches {

compiler/rustc_expand/src/expand.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
15991599
cfg_pos = Some(pos); // a cfg attr found, no need to search anymore
16001600
break;
16011601
} else if attr_pos.is_none()
1602-
&& !name.map_or(false, rustc_feature::is_builtin_attr_name)
1602+
&& !name.is_some_and(rustc_feature::is_builtin_attr_name)
16031603
{
16041604
attr_pos = Some(pos); // a non-cfg attr found, still may find a cfg attr
16051605
}
@@ -1647,7 +1647,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
16471647
let current_span = if let Some(sp) = span { sp.to(attr.span) } else { attr.span };
16481648
span = Some(current_span);
16491649

1650-
if attrs.peek().map_or(false, |next_attr| next_attr.doc_str().is_some()) {
1650+
if attrs.peek().is_some_and(|next_attr| next_attr.doc_str().is_some()) {
16511651
continue;
16521652
}
16531653

@@ -1950,6 +1950,6 @@ impl<'feat> ExpansionConfig<'feat> {
19501950
}
19511951

19521952
fn proc_macro_hygiene(&self) -> bool {
1953-
self.features.map_or(false, |features| features.proc_macro_hygiene)
1953+
self.features.is_some_and(|features| features.proc_macro_hygiene)
19541954
}
19551955
}

compiler/rustc_feature/src/builtin_attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,11 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
861861
/// Whether this builtin attribute is only used in the local crate.
862862
/// If so, it is not encoded in the crate metadata.
863863
pub fn is_builtin_only_local(name: Symbol) -> bool {
864-
BUILTIN_ATTRIBUTE_MAP.get(&name).map_or(false, |attr| attr.only_local)
864+
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some_and(|attr| attr.only_local)
865865
}
866866

867867
pub fn is_valid_for_get_attr(name: Symbol) -> bool {
868-
BUILTIN_ATTRIBUTE_MAP.get(&name).map_or(false, |attr| match attr.duplicates {
868+
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some_and(|attr| match attr.duplicates {
869869
WarnFollowing | ErrorFollowing | ErrorPreceding | FutureWarnFollowing
870870
| FutureWarnPreceding => true,
871871
DuplicatesOk | WarnFollowingWordOnly => false,

compiler/rustc_feature/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,13 @@ impl UnstableFeatures {
8484
pub fn from_environment(krate: Option<&str>) -> Self {
8585
// `true` if this is a feature-staged build, i.e., on the beta or stable channel.
8686
let disable_unstable_features =
87-
option_env!("CFG_DISABLE_UNSTABLE_FEATURES").map(|s| s != "0").unwrap_or(false);
87+
option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some_and(|s| s != "0");
8888
// Returns whether `krate` should be counted as unstable
89-
let is_unstable_crate = |var: &str| {
90-
krate.map_or(false, |name| var.split(',').any(|new_krate| new_krate == name))
91-
};
89+
let is_unstable_crate =
90+
|var: &str| krate.is_some_and(|name| var.split(',').any(|new_krate| new_krate == name));
9291
// `true` if we should enable unstable features for bootstrapping.
93-
let bootstrap = std::env::var("RUSTC_BOOTSTRAP")
94-
.map_or(false, |var| var == "1" || is_unstable_crate(&var));
92+
let bootstrap =
93+
std::env::var("RUSTC_BOOTSTRAP").is_ok_and(|var| var == "1" || is_unstable_crate(&var));
9594
match (disable_unstable_features, bootstrap) {
9695
(_, true) => UnstableFeatures::Cheat,
9796
(true, _) => UnstableFeatures::Disallow,

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ pub struct WhereBoundPredicate<'hir> {
787787
impl<'hir> WhereBoundPredicate<'hir> {
788788
/// Returns `true` if `param_def_id` matches the `bounded_ty` of this predicate.
789789
pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
790-
self.bounded_ty.as_generic_param().map_or(false, |(def_id, _)| def_id == param_def_id)
790+
self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
791791
}
792792
}
793793

0 commit comments

Comments
 (0)