diff --git a/src/google/protobuf/compiler/rust/BUILD.bazel b/src/google/protobuf/compiler/rust/BUILD.bazel index 7adde60df1..7eb964fa38 100644 --- a/src/google/protobuf/compiler/rust/BUILD.bazel +++ b/src/google/protobuf/compiler/rust/BUILD.bazel @@ -233,6 +233,7 @@ cc_library( ], deps = [ "//src/google/protobuf", + "//src/google/protobuf:port", "@com_google_absl//absl/log:absl_log", ], ) diff --git a/src/google/protobuf/compiler/rust/accessors/BUILD.bazel b/src/google/protobuf/compiler/rust/accessors/BUILD.bazel index e293025645..ccd7f7b94a 100644 --- a/src/google/protobuf/compiler/rust/accessors/BUILD.bazel +++ b/src/google/protobuf/compiler/rust/accessors/BUILD.bazel @@ -35,6 +35,7 @@ cc_library( ], deps = [ "//src/google/protobuf", + "//src/google/protobuf:port", "//src/google/protobuf/compiler/cpp:names_internal", "//src/google/protobuf/compiler/rust:context", "//src/google/protobuf/compiler/rust:naming", diff --git a/src/google/protobuf/compiler/rust/accessors/accessors.cc b/src/google/protobuf/compiler/rust/accessors/accessors.cc index 87c88406c6..ed1e7fcfdf 100644 --- a/src/google/protobuf/compiler/rust/accessors/accessors.cc +++ b/src/google/protobuf/compiler/rust/accessors/accessors.cc @@ -16,6 +16,7 @@ #include "google/protobuf/compiler/rust/rust_field_type.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/port.h" namespace google { namespace protobuf { @@ -64,8 +65,8 @@ std::unique_ptr AccessorGeneratorFor( return std::make_unique(); } - ABSL_LOG(FATAL) << "Unexpected field type: " << field.type(); - return nullptr; + ABSL_LOG(ERROR) << "Unknown field type: " << field.type(); + internal::Unreachable(); } } // namespace diff --git a/src/google/protobuf/compiler/rust/accessors/default_value.cc b/src/google/protobuf/compiler/rust/accessors/default_value.cc index c31bf751c1..a143c2b9aa 100644 --- a/src/google/protobuf/compiler/rust/accessors/default_value.cc +++ b/src/google/protobuf/compiler/rust/accessors/default_value.cc @@ -20,6 +20,7 @@ #include "google/protobuf/compiler/rust/rust_field_type.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/io/strtod.h" +#include "google/protobuf/port.h" namespace google { namespace protobuf { @@ -86,7 +87,8 @@ std::string DefaultValue(Context& ctx, const FieldDescriptor& field) { case RustFieldType::MESSAGE: ABSL_LOG(FATAL) << "Messages can't have defaults: " << field.type_name(); } - ABSL_LOG(FATAL) << "unreachable"; + ABSL_LOG(ERROR) << "unreachable"; + internal::Unreachable(); } } // namespace rust diff --git a/src/google/protobuf/compiler/rust/naming.cc b/src/google/protobuf/compiler/rust/naming.cc index 5a907e3866..b44f4f7ff9 100644 --- a/src/google/protobuf/compiler/rust/naming.cc +++ b/src/google/protobuf/compiler/rust/naming.cc @@ -28,6 +28,7 @@ #include "google/protobuf/compiler/rust/rust_field_type.h" #include "google/protobuf/compiler/rust/rust_keywords.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/port.h" // Must be included last. #include "google/protobuf/port_def.inc" @@ -211,8 +212,8 @@ std::string RsTypePath(Context& ctx, const FieldDescriptor& field) { case RustFieldType::ENUM: return GetFullyQualifiedPath(ctx, *field.enum_type()); } - ABSL_LOG(FATAL) << "Unsupported field type: " << field.type_name(); - return ""; + ABSL_LOG(ERROR) << "Unknown field type: " << field.type_name(); + internal::Unreachable(); } std::string RsViewType(Context& ctx, const FieldDescriptor& field, @@ -244,7 +245,7 @@ std::string RsViewType(Context& ctx, const FieldDescriptor& field, } } ABSL_LOG(FATAL) << "Unsupported field type: " << field.type_name(); - return ""; + internal::Unreachable(); } std::string RustModuleForContainingType(Context& ctx, diff --git a/src/google/protobuf/compiler/rust/rust_field_type.cc b/src/google/protobuf/compiler/rust/rust_field_type.cc index ddd7252e6c..154da915ff 100644 --- a/src/google/protobuf/compiler/rust/rust_field_type.cc +++ b/src/google/protobuf/compiler/rust/rust_field_type.cc @@ -2,6 +2,7 @@ #include "absl/log/absl_log.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/port.h" namespace google { namespace protobuf { @@ -44,7 +45,8 @@ RustFieldType GetRustFieldType(FieldDescriptor::Type type) { case FieldDescriptor::TYPE_ENUM: return RustFieldType::ENUM; } - ABSL_LOG(FATAL) << "Unknown field type: " << type; + ABSL_LOG(ERROR) << "Unknown field type: " << type; + internal::Unreachable(); } } // namespace rust