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; return;
} }
let mut suggest_is_some_and = false; // is_some_and is stabilised && `unwrap_or` argument is false; suggest `is_some_and` instead
// argument to `unwrap_or` is false & is_some_and is stabilised; should suggest using `is_some_and` let suggest_is_some_and = msrv.meets(msrvs::OPTION_IS_SOME_AND)
if msrv.meets(msrvs::OPT_IS_SOME_AND) { && matches!(&unwrap_arg.kind, ExprKind::Lit(lit)
if let ExprKind::Lit(unwrap_lit) = &unwrap_arg.kind { if matches!(lit.node, rustc_ast::LitKind::Bool(false)));
if let rustc_ast::LitKind::Bool(false) = unwrap_lit.node {
suggest_is_some_and = true;
}
}
}
let mut applicability = Applicability::MachineApplicable; let mut applicability = Applicability::MachineApplicable;
// get snippet for unwrap_or() // 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 // names may refer to stabilized feature flags or library items
msrv_aliases! { msrv_aliases! {
1,70,0 { OPT_IS_SOME_AND } 1,70,0 { OPTION_IS_SOME_AND }
1,68,0 { PATH_MAIN_SEPARATOR_STR } 1,68,0 { PATH_MAIN_SEPARATOR_STR }
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS } 1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE } 1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }