1
Fork 0

Do not use HashSet for #[rustc_must_implement_one_of]

This commit is contained in:
Maybe Waffle 2022-01-14 16:52:30 +03:00
parent c30ec5a6fd
commit f9174e1d80
4 changed files with 7 additions and 7 deletions

View file

@ -980,8 +980,8 @@ fn check_impl_items_against_trait<'tcx>(
// Check for missing items from trait // Check for missing items from trait
let mut missing_items = Vec::new(); let mut missing_items = Vec::new();
let mut must_implement_one_of: Option<FxHashSet<Ident>> = let mut must_implement_one_of: Option<&[Ident]> =
trait_def.must_implement_one_of.as_deref().map(|slice| slice.iter().copied().collect()); trait_def.must_implement_one_of.as_deref();
for &trait_item_id in tcx.associated_item_def_ids(impl_trait_ref.def_id) { for &trait_item_id in tcx.associated_item_def_ids(impl_trait_ref.def_id) {
let is_implemented = ancestors let is_implemented = ancestors
@ -1020,7 +1020,7 @@ fn check_impl_items_against_trait<'tcx>(
.find(|attr| attr.has_name(sym::rustc_must_implement_one_of)) .find(|attr| attr.has_name(sym::rustc_must_implement_one_of))
.map(|attr| attr.span); .map(|attr| attr.span);
missing_items_must_implement_one_of_err(tcx, impl_span, &missing_items, attr_span); missing_items_must_implement_one_of_err(tcx, impl_span, missing_items, attr_span);
} }
} }
} }

View file

@ -644,7 +644,7 @@ fn missing_items_err(
fn missing_items_must_implement_one_of_err( fn missing_items_must_implement_one_of_err(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
impl_span: Span, impl_span: Span,
missing_items: &FxHashSet<Ident>, missing_items: &[Ident],
annotation_span: Option<Span>, annotation_span: Option<Span>,
) { ) {
let missing_items_msg = let missing_items_msg =

View file

@ -39,6 +39,6 @@ impl Equal for T2 {
} }
impl Equal for T3 {} impl Equal for T3 {}
//~^ not all trait items implemented, missing one of: `neq`, `eq` //~^ not all trait items implemented, missing one of: `eq`, `neq`
fn main() {} fn main() {}

View file

@ -1,8 +1,8 @@
error[E0046]: not all trait items implemented, missing one of: `neq`, `eq` error[E0046]: not all trait items implemented, missing one of: `eq`, `neq`
--> $DIR/rustc_must_implement_one_of.rs:41:1 --> $DIR/rustc_must_implement_one_of.rs:41:1
| |
LL | impl Equal for T3 {} LL | impl Equal for T3 {}
| ^^^^^^^^^^^^^^^^^ missing one of `neq`, `eq` in implementation | ^^^^^^^^^^^^^^^^^ missing one of `eq`, `neq` in implementation
| |
note: required because of this annotation note: required because of this annotation
--> $DIR/rustc_must_implement_one_of.rs:3:1 --> $DIR/rustc_must_implement_one_of.rs:3:1