Skip to content

Commit e40f37c

Browse files
Brian Smithbriansmith
authored andcommitted
Downgrade known buggy pointer cast suggestions to MaybeIncorrect.
See issues #12882 and #13910. `borrow_as_ptr` was not changed since it does try to detect temporaries and initial testing did not find obvious bugs. `ptr_cast_constness` was not changed since it isn't doing a reference-to-pointer conversion.
1 parent ad6e19a commit e40f37c

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

clippy_lints/src/casts/cast_slice_from_raw_parts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
3939
RawPartsKind::Mutable => "from_raw_parts_mut",
4040
};
4141
let span = expr.span;
42-
let mut applicability = Applicability::MachineApplicable;
42+
let mut applicability = Applicability::MaybeIncorrect;
4343
let ptr = snippet_with_context(cx, ptr_arg.span, ctxt, "ptr", &mut applicability).0;
4444
let len = snippet_with_context(cx, len_arg.span, ctxt, "len", &mut applicability).0;
4545
span_lint_and_sugg(

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Msrv) {
3838
&& to_pointee_ty.is_sized(cx.tcx, cx.typing_env())
3939
&& msrv.meets(cx, msrvs::POINTER_CAST)
4040
{
41-
let mut app = Applicability::MachineApplicable;
41+
let mut app = Applicability::MaybeIncorrect;
4242
let turbofish = match &cast_to_hir_ty.kind {
4343
TyKind::Infer(()) => String::new(),
4444
TyKind::Ptr(mut_ty) => {

clippy_lints/src/casts/ptr_cast_constness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub(super) fn check_null_ptr_cast_method(cx: &LateContext<'_>, expr: &Expr<'_>)
8383
_ => return,
8484
}
8585
&& let Some(prefix) = std_or_core(cx)
86-
&& let mut app = Applicability::MachineApplicable
86+
&& let mut app = Applicability::MaybeIncorrect
8787
&& let sugg = format!("{}", Sugg::hir_with_applicability(cx, cast_expr, "_", &mut app))
8888
&& let Some((_, after_lt)) = sugg.split_once("::<")
8989
{

clippy_lints/src/casts/ref_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(super) fn check<'tcx>(
3232
Mutability::Mut => "from_mut",
3333
};
3434

35-
let mut app = Applicability::MachineApplicable;
35+
let mut app = Applicability::MaybeIncorrect;
3636
let turbofish = match &cast_to_hir_ty.kind {
3737
TyKind::Infer(()) => String::new(),
3838
TyKind::Ptr(mut_ty) => {

0 commit comments

Comments
 (0)