Skip to content

Commit c93e4eb

Browse files
committed
Make Clippy happy
1 parent 9e398f1 commit c93e4eb

File tree

14 files changed

+24
-24
lines changed

14 files changed

+24
-24
lines changed

cargo-dylint/tests/ci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn duplicate_dependencies() {
242242
let stdout_actual = std::str::from_utf8(&assert.get_output().stdout).unwrap();
243243
let package_versions = stdout_actual
244244
.lines()
245-
.filter(|line| line.chars().next().map_or(false, char::is_alphabetic))
245+
.filter(|line| line.chars().next().is_some_and(char::is_alphabetic))
246246
.map(|line| {
247247
<[_; 2]>::try_from(line.split_ascii_whitespace().take(2).collect::<Vec<_>>())
248248
.unwrap()

driver/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ impl rustc_driver::Callbacks for Callbacks {
245245
let dylint_libs = env::var(env::DYLINT_LIBS).ok();
246246
let dylint_metadata = env::var(env::DYLINT_METADATA).ok();
247247
let dylint_no_deps = env::var(env::DYLINT_NO_DEPS).ok();
248-
let dylint_no_deps_enabled =
249-
dylint_no_deps.as_ref().map_or(false, |value| value != "0");
248+
let dylint_no_deps_enabled = dylint_no_deps.as_ref().is_some_and(|value| value != "0");
250249
let cargo_primary_package_is_set = env::var(env::CARGO_PRIMARY_PACKAGE).is_ok();
251250

252251
sess.parse_sess().env_depinfo.lock().insert((
@@ -299,7 +298,7 @@ impl rustc_driver::Callbacks for Callbacks {
299298

300299
#[must_use]
301300
fn list_enabled() -> bool {
302-
env::var(env::DYLINT_LIST).map_or(false, |value| value != "0")
301+
env::var(env::DYLINT_LIST).is_ok_and(|value| value != "0")
303302
}
304303

305304
fn list_lints(before: &BTreeSet<Lint>, after: &BTreeSet<Lint>) {
@@ -389,6 +388,8 @@ fn rustc_args<T: AsRef<OsStr>, U: AsRef<str>, V: AsRef<Path>>(
389388
let mut rustc_args = Vec::new();
390389

391390
let first_arg = args.peek();
391+
// smoelius: `Option::is_none_or` is too recent for some toolchains we test with.
392+
#[allow(clippy::unnecessary_map_or)]
392393
if first_arg.map_or(true, |arg| !is_rustc(arg)) {
393394
rustc_args.push("rustc".to_owned());
394395
}

dylint/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn write_dylint_driver_manifest_dir() {
2626
let dylint_driver_manifest_dir = if dylint_manifest_dir.starts_with(cargo_home)
2727
|| dylint_manifest_dir
2828
.parent()
29-
.map_or(false, |path| path.ends_with("target/package"))
29+
.is_some_and(|path| path.ends_with("target/package"))
3030
|| env::var(env::DOCS_RS).is_ok()
3131
{
3232
"None".to_owned()

examples/experimental/missing_doc_comment_openai/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ fn skip_preceding_line_comments(cx: &LateContext<'_>, mut span: Span) -> Span {
375375
let lo_prev_relative = sf.lines()[line];
376376
let lo_prev = sf.absolute_position(lo_prev_relative);
377377
let span_prev = span.with_lo(lo_prev);
378-
if snippet_opt(cx, span_prev).map_or(false, |snippet| snippet.starts_with("//")) {
378+
if snippet_opt(cx, span_prev).is_some_and(|snippet| snippet.starts_with("//")) {
379379
span = span_prev;
380380
} else {
381381
break;
@@ -387,12 +387,12 @@ fn skip_preceding_line_comments(cx: &LateContext<'_>, mut span: Span) -> Span {
387387
#[must_use]
388388
fn enabled(name: &str) -> bool {
389389
let key = env!("CARGO_PKG_NAME").to_uppercase() + "_" + name;
390-
std::env::var(key).map_or(false, |value| value != "0")
390+
std::env::var(key).is_ok_and(|value| value != "0")
391391
}
392392

393393
#[must_use]
394394
fn testing() -> bool {
395-
std::env::var(OPENAI_API_KEY).map_or(false, |value| value.to_lowercase().contains("test"))
395+
std::env::var(OPENAI_API_KEY).is_ok_and(|value| value.to_lowercase().contains("test"))
396396
}
397397

398398
#[cfg(test)]

examples/general/abs_home_path/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for AbsHomePath {
7878
.home
7979
.get_or_init(home::home_dir)
8080
.as_ref()
81-
.map_or(false, |dir| path.starts_with(dir))
81+
.is_some_and(|dir| path.starts_with(dir))
8282
{
8383
span_lint(
8484
cx,

examples/general/non_local_effect_before_error_return/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn in_async_function(tcx: ty::TyCtxt<'_>, hir_id: rustc_hir::HirId) -> bool {
210210
.chain(tcx.hir().parent_iter(hir_id))
211211
.any(|(_, node)| {
212212
node.fn_kind()
213-
.map_or(false, |fn_kind| fn_kind.asyncness().is_async())
213+
.is_some_and(|fn_kind| fn_kind.asyncness().is_async())
214214
})
215215
}
216216

@@ -237,7 +237,7 @@ fn is_call_with_mut_ref<'tcx>(
237237
..
238238
} = &terminator.kind
239239
// smoelius: `deref_mut` generates too much noise.
240-
&& func.const_fn_def().map_or(true, |(def_id, _)| {
240+
&& func.const_fn_def().is_none_or(|(def_id, _)| {
241241
!cx.tcx.is_diagnostic_item(sym::deref_mut_method, def_id)
242242
})
243243
&& let (locals, constants) = collect_locals_and_constants(cx, mir, path, args.iter().map(|arg| &arg.node))
@@ -314,12 +314,12 @@ fn collect_locals_and_constants<'tcx>(
314314
&& let followed_widely = locals_widely.remove(destination.local)
315315
&& (followed_narrowly || followed_widely)
316316
{
317-
let width_preserving = func.const_fn_def().map_or(false, |(def_id, _)| {
317+
let width_preserving = func.const_fn_def().is_some_and(|(def_id, _)| {
318318
WIDTH_PRESERVING
319319
.iter()
320320
.any(|path| match_def_path(cx, def_id, path))
321321
});
322-
let widening = func.const_fn_def().map_or(false, |(def_id, _)| {
322+
let widening = func.const_fn_def().is_some_and(|(def_id, _)| {
323323
WIDENING.iter().any(|path| match_def_path(cx, def_id, path))
324324
});
325325
for arg in args {
@@ -430,7 +430,7 @@ fn error_note(span: Option<Span>) -> impl FnOnce(&mut Diag<'_, ()>) {
430430
#[must_use]
431431
fn enabled(opt: &str) -> bool {
432432
let key = env!("CARGO_PKG_NAME").to_uppercase() + "_" + opt;
433-
std::env::var(key).map_or(false, |value| value != "0")
433+
std::env::var(key).is_ok_and(|value| value != "0")
434434
}
435435

436436
#[test]

examples/restriction/collapsible_unwrap/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl CollapsibleUnwrap {
9595
let needs_mut = cx
9696
.typeck_results()
9797
.type_dependent_def_id(expr.hir_id)
98-
.map_or(false, |def_id| has_ref_mut_self(cx, def_id));
98+
.is_some_and(|def_id| has_ref_mut_self(cx, def_id));
9999
let recv_ty = cx.typeck_results().expr_ty(recv);
100100
let name = suggest_name_from_type(cx, recv_ty);
101101
recv = inner_recv;

examples/restriction/inconsistent_qualification/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<'tcx> Visitor<'tcx> for UseVisitor<'_, 'tcx, '_> {
232232
}
233233

234234
fn is_local(res: Res) -> bool {
235-
res.opt_def_id().map_or(false, DefId::is_local)
235+
res.opt_def_id().is_some_and(DefId::is_local)
236236
}
237237

238238
fn get_owner(tcx: TyCtxt<'_>, hir_id: HirId) -> Option<OwnerNode<'_>> {

examples/restriction/overscoped_allow/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn include_trailing_semicolons(cx: &LateContext<'_>, mut span: Span) -> Span {
382382
};
383383
while span.hi() < file.end_position() {
384384
let next = span.with_hi(span.hi() + BytePos(1));
385-
if !snippet_opt(cx, next).map_or(false, |snip| snip.ends_with(';')) {
385+
if !snippet_opt(cx, next).is_some_and(|snip| snip.ends_with(';')) {
386386
break;
387387
}
388388
span = next;
@@ -456,8 +456,7 @@ fn can_have_attrs(cx: &LateContext<'_>, hir_id: HirId) -> bool {
456456
}
457457

458458
fn is_lint_attr(attr: &Attribute) -> bool {
459-
attr.ident()
460-
.map_or(false, |ident| is_lint_level(ident.name))
459+
attr.ident().is_some_and(|ident| is_lint_level(ident.name))
461460
}
462461

463462
// smoelius: `is_lint_level` was copied from:

examples/supplementary/unnecessary_borrow_mut/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<'tcx> Visitor<'tcx> for V<'tcx> {
224224
#[must_use]
225225
fn enabled(opt: &str) -> bool {
226226
let key = env!("CARGO_PKG_NAME").to_uppercase() + "_" + opt;
227-
std::env::var(key).map_or(false, |value| value != "0")
227+
std::env::var(key).is_ok_and(|value| value != "0")
228228
}
229229

230230
#[test]

0 commit comments

Comments
 (0)