Skip to content

Commit 83d6964

Browse files
committed
hotfix: add help dialog for PermissionExt
1 parent cac9822 commit 83d6964

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

clippy_lints/src/permissions_set_readonly_false.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clippy_utils::diagnostics::span_lint_and_note;
1+
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::paths;
33
use clippy_utils::ty::match_type;
44
use rustc_ast::ast::LitKind;
@@ -36,13 +36,16 @@ impl<'tcx> LateLintPass<'tcx> for PermissionsSetReadonlyFalse {
3636
&& let ExprKind::Lit(lit) = &arg.kind
3737
&& LitKind::Bool(false) == lit.node
3838
{
39-
span_lint_and_note(
39+
span_lint_and_then(
4040
cx,
4141
PERMISSIONS_SET_READONLY_FALSE,
4242
expr.span,
4343
"call to `set_readonly` with argument `false`",
44-
None,
45-
"on Unix platforms this results in the file being world writable",
44+
|diag| {
45+
diag.note("on Unix platforms this results in the file being world writable");
46+
diag.help("`set_readonly(false)` makes the world-writable on Unix. You can avoid this issue with `PermissionsExt`. For more imformation, see\n\
47+
https://doc.rust-lang.org/std/os/unix/fs/trait.PermissionsExt.html");
48+
}
4649
);
4750
}
4851
}

tests/ui/permissions_set_readonly_false.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LL | permissions.set_readonly(false);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: on Unix platforms this results in the file being world writable
8+
= help: `set_readonly(false)` makes the world-writable on Unix. You can avoid this issue with `PermissionsExt`. For more imformation, see
9+
https://doc.rust-lang.org/std/os/unix/fs/trait.PermissionsExt.html
810
= note: `-D clippy::permissions-set-readonly-false` implied by `-D warnings`
911

1012
error: aborting due to previous error

0 commit comments

Comments
 (0)