changed msrv name for consistency & changed nested if for style

This commit is contained in:
darklyspaced 2023-06-27 11:28:45 +08:00
parent ca00b138b2
commit a693cbc1bc
No known key found for this signature in database
2 changed files with 5 additions and 10 deletions

View File

@ -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()

View File

@ -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 }