Fix #[rustc_must_implement_one_of]

This adds the old, pre 90639 `is_implemented` that previously only was
true if the implementation of the item was from the given impl block and
not from the trait default.
This commit is contained in:
Maybe Waffle 2022-01-10 12:54:04 +03:00
parent 96b2f8ac32
commit f64daff0c6

View file

@ -993,10 +993,16 @@ fn check_impl_items_against_trait<'tcx>(
}
if let Some(required_items) = &must_implement_one_of {
let trait_item = tcx.associated_item(trait_item_id);
// true if this item is specifically implemented in this impl
let is_implemented_here = ancestors
.leaf_def(tcx, trait_item_id)
.map_or(false, |node_item| !node_item.defining_node.is_from_trait());
if is_implemented && required_items.contains(&trait_item.ident) {
must_implement_one_of = None;
if is_implemented_here {
let trait_item = tcx.associated_item(trait_item_id);
if required_items.contains(&trait_item.ident) {
must_implement_one_of = None;
}
}
}
}