Clarify that `name` and `decl_id` are mutually exclusive.
Even before this CL, RsType::ToJson and CcType::ToJson would include
only *one* of `name` and `decl_id` fields (i.e. treating them as
mutually exclusive in JSON representation of the IR).
This CL goes one step further:
- Documents the mutual exclusivity in the comments
- Tightens MappedType::WithDeclId method to avoid passing redundant
names.
PiperOrigin-RevId: 434796126
diff --git a/rs_bindings_from_cc/importer.cc b/rs_bindings_from_cc/importer.cc
index 85865a8..05bb5dd 100644
--- a/rs_bindings_from_cc/importer.cc
+++ b/rs_bindings_from_cc/importer.cc
@@ -948,15 +948,8 @@
"No generated bindings found for '$0'", decl->getNameAsString()));
}
- std::optional<Identifier> id = GetTranslatedIdentifier(decl);
- if (!id.has_value()) {
- return absl::UnimplementedError(absl::Substitute(
- "Cannot translate name of '$0'", decl->getNameAsString()));
- }
-
- std::string ident(id->Ident());
DeclId decl_id = GenerateDeclId(decl);
- return MappedType::WithDeclIds(ident, decl_id, ident, decl_id);
+ return MappedType::WithDeclId(decl_id);
}
absl::StatusOr<MappedType> Importer::ConvertType(