Do not propose to auto-derive Clone in presence of unsafe fields (#14559)
`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. changelog: [`expl_impl_clone_on_copy`]: do not lint in the presence of `unsafe` fields Fixes #14558
This commit is contained in:
commit
8dfcaa0590
3 changed files with 31 additions and 10 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue