diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-07-15 14:13:49 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-07-15 14:13:49 +0100 |
commit | ebdf933621189db132d0bebec475937f02fbf6a5 (patch) | |
tree | 616164691fa6ad034d3cc257b519ac8212b06fb5 /gcc | |
parent | 089e62f33c328afea756ec4b92f5823584b08a3a (diff) | |
download | gcc-ebdf933621189db132d0bebec475937f02fbf6a5.zip gcc-ebdf933621189db132d0bebec475937f02fbf6a5.tar.gz gcc-ebdf933621189db132d0bebec475937f02fbf6a5.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-item.h | 29 |
1 files changed, 16 insertions, 13 deletions
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 ()); + } } } |