Skip to content

Commit

Permalink
changed msrv name for consistency & changed nested if for style
Browse files Browse the repository at this point in the history
  • Loading branch information
darklyspaced committed Jun 27, 2023
1 parent ca00b13 commit a693cbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions clippy_lints/src/methods/option_map_unwrap_or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,10 @@ pub(super) fn check<'tcx>(
return;
}

let mut suggest_is_some_and = false;
// argument to `unwrap_or` is false & is_some_and is stabilised; should suggest using `is_some_and`
if msrv.meets(msrvs::OPT_IS_SOME_AND) {
if let ExprKind::Lit(unwrap_lit) = &unwrap_arg.kind {
if let rustc_ast::LitKind::Bool(false) = unwrap_lit.node {
suggest_is_some_and = true;
}
}
}
// is_some_and is stabilised && `unwrap_or` argument is false; suggest `is_some_and` instead
let suggest_is_some_and = msrv.meets(msrvs::OPTION_IS_SOME_AND)
&& matches!(&unwrap_arg.kind, ExprKind::Lit(lit)
if matches!(lit.node, rustc_ast::LitKind::Bool(false)));

let mut applicability = Applicability::MachineApplicable;
// get snippet for unwrap_or()
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macro_rules! msrv_aliases {

// names may refer to stabilized feature flags or library items
msrv_aliases! {
1,70,0 { OPT_IS_SOME_AND }
1,70,0 { OPTION_IS_SOME_AND }
1,68,0 { PATH_MAIN_SEPARATOR_STR }
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
Expand Down

0 comments on commit a693cbc

Please sign in to comment.