From ebdf933621189db132d0bebec475937f02fbf6a5 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Thu, 15 Jul 2021 14:13:49 +0100 Subject: Only error for missing trait items. Some trait items can be optional such as constants with an expression or functions with a body. This change only warns when there are non optional items missing. --- gcc/rust/typecheck/rust-hir-type-check-item.h | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.h b/gcc/rust/typecheck/rust-hir-type-check-item.h index f1ae82d..8d770f0 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.h +++ b/gcc/rust/typecheck/rust-hir-type-check-item.h @@ -104,21 +104,24 @@ public: missing_trait_items.push_back (trait_item_ref); } - std::string missing_items_buf; - RichLocation r (impl_block.get_locus ()); - for (size_t i = 0; i < missing_trait_items.size (); i++) + if (missing_trait_items.size () > 0) { - bool has_more = (i + 1) < missing_trait_items.size (); - const TraitItemReference &missing_trait_item - = missing_trait_items.at (i); - missing_items_buf - += missing_trait_item.get_identifier () + (has_more ? ", " : ""); - r.add_range (missing_trait_item.get_locus ()); - } + std::string missing_items_buf; + RichLocation r (impl_block.get_locus ()); + for (size_t i = 0; i < missing_trait_items.size (); i++) + { + bool has_more = (i + 1) < missing_trait_items.size (); + const TraitItemReference &missing_trait_item + = missing_trait_items.at (i); + missing_items_buf += missing_trait_item.get_identifier () + + (has_more ? ", " : ""); + r.add_range (missing_trait_item.get_locus ()); + } - rust_error_at (r, "missing %s in implementation of trait %<%s%>", - missing_items_buf.c_str (), - trait_reference.get_name ().c_str ()); + rust_error_at (r, "missing %s in implementation of trait %<%s%>", + missing_items_buf.c_str (), + trait_reference.get_name ().c_str ()); + } } } -- cgit v1.1