new manual_option_as_slice lint (#13901)
Hey folks. It's been a while since I added the `as_slice` method to `Option`, and I totally forgot about a lint to suggest it. Well, I had some time around Christmas, so here it is now. --- changelog: add [`manual_option_as_slice`] lint
This commit is contained in:
commit
c5218d509b
10 changed files with 432 additions and 9 deletions
|
|
@ -341,6 +341,14 @@ pub fn is_wild(pat: &Pat<'_>) -> bool {
|
|||
matches!(pat.kind, PatKind::Wild)
|
||||
}
|
||||
|
||||
// Checks if arm has the form `None => _`
|
||||
pub fn is_none_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
|
||||
matches!(
|
||||
arm.pat.kind,
|
||||
PatKind::Path(ref qpath) if is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id),OptionNone)
|
||||
)
|
||||
}
|
||||
|
||||
/// Checks if the given `QPath` belongs to a type alias.
|
||||
pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
|
||||
match *qpath {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use rustc_ast::attr::AttributeExt;
|
||||
|
||||
use rustc_attr_parsing::{RustcVersion, parse_version};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::{Symbol, sym};
|
||||
|
|
@ -18,12 +19,14 @@ macro_rules! msrv_aliases {
|
|||
|
||||
// names may refer to stabilized feature flags or library items
|
||||
msrv_aliases! {
|
||||
1,84,0 { CONST_OPTION_AS_SLICE }
|
||||
1,83,0 { CONST_EXTERN_FN, CONST_FLOAT_BITS_CONV, CONST_FLOAT_CLASSIFY, CONST_MUT_REFS, CONST_UNWRAP }
|
||||
1,82,0 { IS_NONE_OR, REPEAT_N, RAW_REF_OP }
|
||||
1,81,0 { LINT_REASONS_STABILIZATION, ERROR_IN_CORE, EXPLICIT_SELF_TYPE_ELISION }
|
||||
1,80,0 { BOX_INTO_ITER, LAZY_CELL }
|
||||
1,77,0 { C_STR_LITERALS }
|
||||
1,76,0 { PTR_FROM_REF, OPTION_RESULT_INSPECT }
|
||||
1,75,0 { OPTION_AS_SLICE }
|
||||
1,74,0 { REPR_RUST }
|
||||
1,73,0 { MANUAL_DIV_CEIL }
|
||||
1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue