Skip to content

Commit 43b8e04

Browse files
committed
[Clippy] Swap non_octal_unix_permissions to use diagnostic item instead of path
1 parent 5f85f73 commit 43b8e04

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ symbols! {
14371437
pattern_parentheses,
14381438
pattern_type,
14391439
pattern_types,
1440+
permissions_from_mode,
14401441
phantom_data,
14411442
pic,
14421443
pie,

library/std/src/os/unix/fs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ pub trait PermissionsExt {
334334
/// assert_eq!(permissions.mode(), 0o644);
335335
/// ```
336336
#[stable(feature = "fs_ext", since = "1.1.0")]
337+
#[cfg_attr(not(test), rustc_diagnostic_item = "permissions_from_mode")]
337338
fn from_mode(mode: u32) -> Self;
338339
}
339340

src/tools/clippy/clippy_lints/src/non_octal_unix_permissions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::{snippet_with_applicability, SpanRangeExt};
3-
use clippy_utils::{match_def_path, paths};
43
use rustc_errors::Applicability;
54
use rustc_hir::{Expr, ExprKind};
65
use rustc_lint::{LateContext, LateLintPass};
@@ -63,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for NonOctalUnixPermissions {
6362
ExprKind::Call(func, [param]) => {
6463
if let ExprKind::Path(ref path) = func.kind
6564
&& let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id()
66-
&& match_def_path(cx, def_id, &paths::PERMISSIONS_FROM_MODE)
65+
&& cx.tcx.is_diagnostic_item(sym::permissions_from_mode, def_id)
6766
&& let ExprKind::Lit(_) = param.kind
6867
&& param.span.eq_ctxt(expr.span)
6968
&& param

src/tools/clippy/clippy_utils/src/paths.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ pub const OPEN_OPTIONS_NEW: [&str; 4] = ["std", "fs", "OpenOptions", "new"];
3939
pub const PARKING_LOT_MUTEX_GUARD: [&str; 3] = ["lock_api", "mutex", "MutexGuard"];
4040
pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockReadGuard"];
4141
pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockWriteGuard"];
42-
#[cfg_attr(not(unix), allow(clippy::invalid_paths))]
43-
pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"];
4442
pub const REGEX_BUILDER_NEW: [&str; 3] = ["regex", "RegexBuilder", "new"];
4543
pub const REGEX_BYTES_BUILDER_NEW: [&str; 4] = ["regex", "bytes", "RegexBuilder", "new"];
4644
pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "bytes", "Regex", "new"];

0 commit comments

Comments
 (0)