Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 264fa0f

Browse files
committed
Run clippy --fix for unnecessary_map_or lint
1 parent 39dc268 commit 264fa0f

File tree

39 files changed

+61
-67
lines changed

39 files changed

+61
-67
lines changed

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
7272
if let Some(local_sig_id) = def_id.as_local() {
7373
// The value may be missing due to recursive delegation.
7474
// Error will be emitted later during HIR ty lowering.
75-
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
75+
self.resolver.delegation_fn_sigs.get(&local_sig_id).is_some_and(|sig| sig.has_self)
7676
} else {
7777
match self.tcx.def_kind(def_id) {
7878
DefKind::Fn => false,

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'a> PostExpansionVisitor<'a> {
8383
feature_err_issue(&self.sess, feature, span, GateIssue::Language, explain).emit();
8484
}
8585
Err(abi::AbiDisabled::Unrecognized) => {
86-
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
86+
if self.sess.opts.pretty.is_none_or(|ppm| ppm.needs_hir()) {
8787
self.sess.dcx().span_delayed_bug(
8888
span,
8989
format!(

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &impl AttributeExt) -> Vec<ReprAttr
166166
// the `check_mod_attrs` pass, but this pass doesn't always run
167167
// (e.g. if we only pretty-print the source), so we have to gate
168168
// the `span_delayed_bug` call as follows:
169-
if sess.opts.pretty.map_or(true, |pp| pp.needs_analysis()) {
169+
if sess.opts.pretty.is_none_or(|pp| pp.needs_analysis()) {
170170
dcx.span_delayed_bug(item.span(), "unrecognized representation hint");
171171
}
172172
}

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24802480
// To support cases like `|| { v.call(|this| v.get()) }`
24812481
// FIXME: actually support such cases (need to figure out how to move from the
24822482
// capture place to original local).
2483-
&& self.res.as_ref().map_or(true, |(prev_res, _)| prev_res.span.contains(ex.span))
2483+
&& self.res.as_ref().is_none_or(|(prev_res, _)| prev_res.span.contains(ex.span))
24842484
{
24852485
self.res = Some((ex, closure));
24862486
}

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ impl<'tcx> BorrowExplanation<'tcx> {
131131
&& let Ok(pat) = tcx.sess.source_map().span_to_snippet(pat.span)
132132
{
133133
suggest_rewrite_if_let(tcx, expr, &pat, init, conseq, alt, err);
134-
} else if path_span.map_or(true, |path_span| path_span == var_or_use_span) {
134+
} else if path_span.is_none_or(|path_span| path_span == var_or_use_span) {
135135
// We can use `var_or_use_span` if either `path_span` is not present, or both
136136
// spans are the same.
137-
if borrow_span.map_or(true, |sp| !sp.overlaps(var_or_use_span)) {
137+
if borrow_span.is_none_or(|sp| !sp.overlaps(var_or_use_span)) {
138138
err.span_label(
139139
var_or_use_span,
140140
format!("{borrow_desc}borrow later {message}"),

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ pub(crate) fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) ->
442442
// (or if there is no allocator argument).
443443
ty::Adt(def, args)
444444
if def.is_box()
445-
&& args.get(1).map_or(true, |arg| cx.layout_of(arg.expect_ty()).is_1zst()) =>
445+
&& args.get(1).is_none_or(|arg| cx.layout_of(arg.expect_ty()).is_1zst()) =>
446446
{
447447
build_pointer_or_reference_di_node(cx, t, t.expect_boxed_ty(), unique_type_id)
448448
}

compiler/rustc_errors/src/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3146,7 +3146,7 @@ impl FileWithAnnotatedLines {
31463146
add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line());
31473147
}
31483148
let line_end = ann.line_end - 1;
3149-
let end_is_empty = file.get_line(line_end - 1).map_or(false, |s| !filter(&s));
3149+
let end_is_empty = file.get_line(line_end - 1).is_some_and(|s| !filter(&s));
31503150
if middle < line_end && !end_is_empty {
31513151
add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line());
31523152
}

compiler/rustc_errors/src/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ 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.map_or(false, |(s, _)| s.is_empty())
466+
&& suggestion.is_some_and(|(s, _)| s.is_empty())
467467
&& let Ok(after) = je.sm.span_to_next_source(span)
468468
&& after.starts_with('\n')
469469
{

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ impl DiagCtxtInner {
17171717
let bugs: Vec<_> =
17181718
std::mem::take(&mut self.delayed_bugs).into_iter().map(|(b, _)| b).collect();
17191719

1720-
let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0");
1720+
let backtrace = std::env::var_os("RUST_BACKTRACE").is_none_or(|x| &x != "0");
17211721
let decorate = backtrace || self.ice_file.is_none();
17221722
let mut out = self
17231723
.ice_file

compiler/rustc_expand/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl<'a> StripUnconfigured<'a> {
391391
validate_attr::deny_builtin_meta_unsafety(&self.sess.psess, &meta_item);
392392

393393
(
394-
parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| {
394+
parse_cfg(&meta_item, self.sess).is_none_or(|meta_item| {
395395
attr::cfg_matches(meta_item, &self.sess, self.lint_node_id, self.features)
396396
}),
397397
Some(meta_item),

0 commit comments

Comments
 (0)