Diagnose incorrect unsafety for trait impls

This commit is contained in:
Lukas Wirth 2023-11-14 20:02:23 +01:00
parent d5faad1dae
commit e21d21a8fb
8 changed files with 204 additions and 24 deletions

View file

@ -388,8 +388,18 @@ impl Printer<'_> {
wln!(self);
}
ModItem::Impl(it) => {
let Impl { target_trait, self_ty, is_negative, items, generic_params, ast_id: _ } =
&self.tree[it];
let Impl {
target_trait,
self_ty,
is_negative,
is_unsafe,
items,
generic_params,
ast_id: _,
} = &self.tree[it];
if *is_unsafe {
w!(self, "unsafe");
}
w!(self, "impl");
self.print_generic_params(generic_params);
w!(self, " ");