Use proto2::internal::Unreachable() to avoid control flow warnings in msvc when we have no return after an ABSL_LOG(FATAL)

PiperOrigin-RevId: 668010802
pull/17962/head
Protobuf Team Bot 3 months ago committed by Copybara-Service
parent e9b04b1f8f
commit 0056835a0d
  1. 1
      src/google/protobuf/compiler/rust/BUILD.bazel
  2. 1
      src/google/protobuf/compiler/rust/accessors/BUILD.bazel
  3. 5
      src/google/protobuf/compiler/rust/accessors/accessors.cc
  4. 4
      src/google/protobuf/compiler/rust/accessors/default_value.cc
  5. 7
      src/google/protobuf/compiler/rust/naming.cc
  6. 4
      src/google/protobuf/compiler/rust/rust_field_type.cc

@ -233,6 +233,7 @@ cc_library(
],
deps = [
"//src/google/protobuf",
"//src/google/protobuf:port",
"@com_google_absl//absl/log:absl_log",
],
)

@ -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",

@ -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<AccessorGenerator> AccessorGeneratorFor(
return std::make_unique<SingularMessage>();
}
ABSL_LOG(FATAL) << "Unexpected field type: " << field.type();
return nullptr;
ABSL_LOG(ERROR) << "Unknown field type: " << field.type();
internal::Unreachable();
}
} // namespace

@ -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

@ -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,

@ -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

Loading…
Cancel
Save