Skip to content

Commit 3c6895c

Browse files
committed
non_octal_unix_permissions: get_diagnostic_name once
1 parent 6934f67 commit 3c6895c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

clippy_lints/src/non_octal_unix_permissions.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ impl<'tcx> LateLintPass<'tcx> for NonOctalUnixPermissions {
4343
match &expr.kind {
4444
ExprKind::MethodCall(path, func, [param], _) => {
4545
if let Some(adt) = cx.typeck_results().expr_ty(func).peel_refs().ty_adt_def()
46-
&& ((path.ident.name == sym::mode
47-
&& matches!(
48-
cx.tcx.get_diagnostic_name(adt.did()),
49-
Some(sym::FsOpenOptions | sym::DirBuilder)
50-
))
51-
|| (path.ident.name == sym::set_mode
52-
&& cx.tcx.is_diagnostic_item(sym::FsPermissions, adt.did())))
46+
&& matches!(
47+
(path.ident.name, cx.tcx.get_diagnostic_name(adt.did())),
48+
(sym::mode, Some(sym::FsOpenOptions | sym::DirBuilder))
49+
| (sym::set_mode, Some(sym::FsPermissions))
50+
)
5351
&& let ExprKind::Lit(_) = param.kind
5452
&& param.span.eq_ctxt(expr.span)
5553
&& param

0 commit comments

Comments
 (0)