Skip to content

Commit ff5cf81

Browse files
committed
use c++23 std::unreachable
1 parent e297232 commit ff5cf81

File tree

10 files changed

+16
-87
lines changed

10 files changed

+16
-87
lines changed

src/iceberg/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ set(ICEBERG_SOURCES
4545
type.cc
4646
util/murmurhash3_internal.cc
4747
util/timepoint.cc
48-
util/unreachable.cc
4948
util/gzip_internal.cc)
5049

5150
set(ICEBERG_STATIC_BUILD_INTERFACE_LIBS)

src/iceberg/file_format.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
/// File format used by Iceberg.
2424

2525
#include <string_view>
26+
#include <utility>
2627

2728
#include "iceberg/iceberg_export.h"
2829
#include "iceberg/result.h"
29-
#include "iceberg/util/unreachable.h"
3030

3131
namespace iceberg {
3232

@@ -50,8 +50,7 @@ ICEBERG_EXPORT inline std::string_view ToString(FileFormatType format_type) {
5050
case FileFormatType::kPuffin:
5151
return "puffin";
5252
}
53-
internal::Unreachable(
54-
std::format("Invalid file format type: {}", static_cast<int>(format_type)));
53+
std::unreachable();
5554
}
5655

5756
/// \brief Convert a string to a FileFormatType

src/iceberg/json_internal.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <regex>
2626
#include <type_traits>
2727
#include <unordered_set>
28+
#include <utility>
2829

2930
#include <nlohmann/json.hpp>
3031

@@ -43,7 +44,6 @@
4344
#include "iceberg/util/formatter.h" // IWYU pragma: keep
4445
#include "iceberg/util/macros.h"
4546
#include "iceberg/util/timepoint.h"
46-
#include "iceberg/util/unreachable.h"
4747

4848
namespace iceberg {
4949

@@ -478,8 +478,7 @@ nlohmann::json ToJson(const Type& type) {
478478
case TypeId::kUuid:
479479
return "uuid";
480480
}
481-
internal::Unreachable(
482-
std::format("Unknown type id: {}", static_cast<int>(type.type_id())));
481+
std::unreachable();
483482
}
484483

485484
nlohmann::json ToJson(const Schema& schema) {

src/iceberg/manifest_list.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
#include <optional>
2626
#include <string>
2727
#include <string_view>
28+
#include <utility>
2829

2930
#include "iceberg/iceberg_export.h"
3031
#include "iceberg/result.h"
3132
#include "iceberg/schema_field.h"
3233
#include "iceberg/type.h"
33-
#include "iceberg/util/unreachable.h"
3434

3535
namespace iceberg {
3636

@@ -216,8 +216,7 @@ ICEBERG_EXPORT constexpr std::string_view ToString(ManifestFile::Content type) n
216216
case ManifestFile::Content::kDeletes:
217217
return "deletes";
218218
}
219-
internal::Unreachable(
220-
std::format("Unknown manifest content type: {}", static_cast<int>(type)));
219+
std::unreachable();
221220
}
222221

223222
/// \brief Get the relative manifest content type from name

src/iceberg/schema_util.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
#include <format>
2323
#include <string_view>
2424
#include <unordered_map>
25+
#include <utility>
2526

2627
#include "iceberg/metadata_columns.h"
2728
#include "iceberg/schema.h"
2829
#include "iceberg/schema_util_internal.h"
2930
#include "iceberg/util/checked_cast.h"
3031
#include "iceberg/util/formatter_internal.h"
3132
#include "iceberg/util/macros.h"
32-
#include "iceberg/util/unreachable.h"
3333

3434
namespace iceberg {
3535

@@ -173,8 +173,7 @@ std::string_view ToString(FieldProjection::Kind kind) {
173173
case FieldProjection::Kind::kNull:
174174
return "null";
175175
}
176-
internal::Unreachable(
177-
std::format("Unknown field projection kind: {}", static_cast<int>(kind)));
176+
std::unreachable();
178177
}
179178

180179
std::string ToString(const FieldProjection& projection) {

src/iceberg/snapshot.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
#include <string>
2424
#include <string_view>
2525
#include <unordered_map>
26+
#include <utility>
2627
#include <variant>
2728

2829
#include "iceberg/iceberg_export.h"
2930
#include "iceberg/result.h"
3031
#include "iceberg/util/timepoint.h"
31-
#include "iceberg/util/unreachable.h"
3232

3333
namespace iceberg {
3434

@@ -51,8 +51,7 @@ ICEBERG_EXPORT constexpr std::string_view SnapshotRefTypeToString(
5151
case SnapshotRefType::kTag:
5252
return "tag";
5353
}
54-
internal::Unreachable(
55-
std::format("Invalid snapshot reference type: {}", static_cast<int>(type)));
54+
std::unreachable();
5655
}
5756
/// \brief Get the relative snapshot reference type from name
5857
ICEBERG_EXPORT constexpr Result<SnapshotRefType> SnapshotRefTypeFromString(

src/iceberg/transform.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
#include <format>
2323
#include <regex>
24+
#include <utility>
2425

2526
#include "iceberg/transform_function.h"
2627
#include "iceberg/type.h"
27-
#include "iceberg/util/unreachable.h"
2828

2929
namespace iceberg {
3030
namespace {
@@ -60,8 +60,7 @@ constexpr std::string_view TransformTypeToString(TransformType type) {
6060
case TransformType::kVoid:
6161
return kVoidName;
6262
}
63-
internal::Unreachable(
64-
std::format("Unknown transform type: {}", static_cast<int>(type)));
63+
std::unreachable();
6564
}
6665

6766
std::shared_ptr<Transform> Transform::Identity() {
@@ -169,8 +168,7 @@ std::string Transform::ToString() const {
169168
return std::format("{}[{}]", TransformTypeToString(transform_type_),
170169
std::get<int32_t>(param_));
171170
}
172-
internal::Unreachable(
173-
std::format("Unknown transform type: {}", static_cast<int>(transform_type_)));
171+
std::unreachable();
174172
}
175173

176174
TransformFunction::TransformFunction(TransformType transform_type,

src/iceberg/util/unreachable.cc

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/iceberg/util/unreachable.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/iceberg/util/visit_type.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
/// Adapted from Apache Arrow
2525
/// https://github.com/apache/arrow/blob/main/cpp/src/arrow/visit_type_inline.h
2626

27+
#include <utility>
28+
2729
#include "iceberg/result.h"
2830
#include "iceberg/type.h"
2931
#include "iceberg/util/checked_cast.h"
30-
#include "iceberg/util/unreachable.h"
3132
#include "iceberg/util/visitor_generate.h"
3233

3334
namespace iceberg {
@@ -93,7 +94,7 @@ inline auto VisitType(const Type& type, VISITOR&& visitor, ARGS&&... args)
9394
switch (type.type_id()) {
9495
ICEBERG_GENERATE_FOR_ALL_TYPES(TYPE_VISIT_INLINE);
9596
default:
96-
internal::Unreachable("Type not implemented");
97+
std::unreachable();
9798
}
9899
}
99100

0 commit comments

Comments
 (0)