Observe unsafeness only for replace_derive_with_manual_impl

This commit is contained in:
Ali Bektas 2025-03-09 18:47:40 +01:00
parent 477b987179
commit 824df43d2d
3 changed files with 6 additions and 34 deletions

View file

@ -5,7 +5,7 @@ use syntax::{
SyntaxKind::WHITESPACE,
T,
ast::{self, AstNode, HasName, make},
ted,
ted::{self, Position},
};
use crate::{
@ -223,6 +223,10 @@ fn impl_def_from_trait(
let first_assoc_item =
add_trait_assoc_items_to_impl(sema, &trait_items, trait_, &impl_def, &target_scope);
if trait_.is_unsafe(sema.db) {
ted::insert(Position::first_child_of(impl_def.syntax()), make::token(T![unsafe]));
}
// Generate a default `impl` function body for the derived trait.
if let ast::AssocItem::Fn(ref func) = first_assoc_item {
let _ = gen_trait_fn_body(func, trait_path, adt, None);