From d2f6c2727dc82c1e8900b15e84a89a45f9f3a33c Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Fri, 21 Feb 2025 15:00:59 +0000 Subject: [PATCH] refactor(tasks): use `Option::is_none_or` (#9273) #9270 bumped MSRV to 1.82.0. So we can now use `Option::is_none_or`. This reverts part of #8929, which removed APIs incompatible with 1.81.0. --- tasks/ast_tools/src/generators/assert_layouts.rs | 5 +---- tasks/prettier_conformance/src/lib.rs | 8 +------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tasks/ast_tools/src/generators/assert_layouts.rs b/tasks/ast_tools/src/generators/assert_layouts.rs index 758152fdf2565..2f13e05ce1c7d 100644 --- a/tasks/ast_tools/src/generators/assert_layouts.rs +++ b/tasks/ast_tools/src/generators/assert_layouts.rs @@ -164,10 +164,7 @@ fn calculate_layout_for_struct(type_id: TypeId, schema: &mut Schema) -> Layout { // Update niche. // Take the largest niche. Preference for earlier niche if 2 fields have niches of same size. if let Some(field_niche) = &field_layout.niche { - // TODO: Use `Option::is_none_or` once our MSRV reaches 1.82.0 - if layout.niche.is_none() - || field_niche.count > layout.niche.as_ref().unwrap().count - { + if layout.niche.as_ref().is_none_or(|niche| field_niche.count > niche.count) { let mut niche = field_niche.clone(); niche.offset += offset; layout.niche = Some(niche); diff --git a/tasks/prettier_conformance/src/lib.rs b/tasks/prettier_conformance/src/lib.rs index a24954a12cec6..629f25d61f93e 100644 --- a/tasks/prettier_conformance/src/lib.rs +++ b/tasks/prettier_conformance/src/lib.rs @@ -172,13 +172,7 @@ fn collect_test_files(dir: &Path, filter: Option<&String>) -> Vec { .into_iter() .filter_map(Result::ok) .filter(|e| !e.file_type().is_dir()) - .filter(|e| { - // TODO: Use `Option::is_none_or` once our MSRV reaches 1.82.0 - match e.path().file_name() { - Some(name) => name != FORMAT_TEST_SPEC_NAME, - None => true, - } - }) + .filter(|e| e.path().file_name().is_none_or(|name| name != FORMAT_TEST_SPEC_NAME)) .filter(|e| !IGNORE_TESTS.iter().any(|s| e.path().to_string_lossy().contains(s))) .filter(|e| filter.is_none_or(|name| e.path().to_string_lossy().contains(name))) .map(|e| e.path().to_path_buf())