Do not propose to auto-derive Clone in presence of unsafe fields

`unsafe_fields` is an incomplete feature; comments have been put near
`#![expect(incomplete_features)]` to ensure that we revisit the
situation when the feature becomes complete.
This commit is contained in:
Samuel Tardieu 2025-04-06 09:55:24 +02:00
parent a5a033d029
commit 315ea9590d
3 changed files with 31 additions and 10 deletions

View file

@ -349,6 +349,10 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
{
return;
}
// The presence of `unsafe` fields prevents deriving `Clone` automatically
if ty_adt.all_fields().any(|f| f.safety.is_unsafe()) {
return;
}
span_lint_and_note(
cx,