[Clippy] Swap non_octal_unix_permissions
to use diagnostic item instead of path
This commit is contained in:
parent
5f85f73f63
commit
43b8e04d46
4 changed files with 3 additions and 4 deletions
|
@ -1437,6 +1437,7 @@ symbols! {
|
||||||
pattern_parentheses,
|
pattern_parentheses,
|
||||||
pattern_type,
|
pattern_type,
|
||||||
pattern_types,
|
pattern_types,
|
||||||
|
permissions_from_mode,
|
||||||
phantom_data,
|
phantom_data,
|
||||||
pic,
|
pic,
|
||||||
pie,
|
pie,
|
||||||
|
|
|
@ -334,6 +334,7 @@ pub trait PermissionsExt {
|
||||||
/// assert_eq!(permissions.mode(), 0o644);
|
/// assert_eq!(permissions.mode(), 0o644);
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "fs_ext", since = "1.1.0")]
|
#[stable(feature = "fs_ext", since = "1.1.0")]
|
||||||
|
#[cfg_attr(not(test), rustc_diagnostic_item = "permissions_from_mode")]
|
||||||
fn from_mode(mode: u32) -> Self;
|
fn from_mode(mode: u32) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::{snippet_with_applicability, SpanRangeExt};
|
use clippy_utils::source::{snippet_with_applicability, SpanRangeExt};
|
||||||
use clippy_utils::{match_def_path, paths};
|
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
@ -63,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for NonOctalUnixPermissions {
|
||||||
ExprKind::Call(func, [param]) => {
|
ExprKind::Call(func, [param]) => {
|
||||||
if let ExprKind::Path(ref path) = func.kind
|
if let ExprKind::Path(ref path) = func.kind
|
||||||
&& let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id()
|
&& let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id()
|
||||||
&& match_def_path(cx, def_id, &paths::PERMISSIONS_FROM_MODE)
|
&& cx.tcx.is_diagnostic_item(sym::permissions_from_mode, def_id)
|
||||||
&& let ExprKind::Lit(_) = param.kind
|
&& let ExprKind::Lit(_) = param.kind
|
||||||
&& param.span.eq_ctxt(expr.span)
|
&& param.span.eq_ctxt(expr.span)
|
||||||
&& param
|
&& param
|
||||||
|
|
|
@ -39,8 +39,6 @@ pub const OPEN_OPTIONS_NEW: [&str; 4] = ["std", "fs", "OpenOptions", "new"];
|
||||||
pub const PARKING_LOT_MUTEX_GUARD: [&str; 3] = ["lock_api", "mutex", "MutexGuard"];
|
pub const PARKING_LOT_MUTEX_GUARD: [&str; 3] = ["lock_api", "mutex", "MutexGuard"];
|
||||||
pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockReadGuard"];
|
pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockReadGuard"];
|
||||||
pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockWriteGuard"];
|
pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockWriteGuard"];
|
||||||
#[cfg_attr(not(unix), allow(clippy::invalid_paths))]
|
|
||||||
pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"];
|
|
||||||
pub const REGEX_BUILDER_NEW: [&str; 3] = ["regex", "RegexBuilder", "new"];
|
pub const REGEX_BUILDER_NEW: [&str; 3] = ["regex", "RegexBuilder", "new"];
|
||||||
pub const REGEX_BYTES_BUILDER_NEW: [&str; 4] = ["regex", "bytes", "RegexBuilder", "new"];
|
pub const REGEX_BYTES_BUILDER_NEW: [&str; 4] = ["regex", "bytes", "RegexBuilder", "new"];
|
||||||
pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "bytes", "Regex", "new"];
|
pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "bytes", "Regex", "new"];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue