Skip to content

Commit 8e6545e

Browse files
Thomas Polasekmeta-codesync[bot]
authored andcommitted
Revert D87118568: Add cpp.NonOrderable annotation to delete operator<
Differential Revision: D87118568 Original commit changeset: 9c9c083a5b6a Original Phabricator Diff: D87118568 fbshipit-source-id: d1d0f1d871f3e0197cd22e809b3c80e6078a80a0
1 parent 6c473bf commit 8e6545e

File tree

119 files changed

+48
-6888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+48
-6888
lines changed

thrift/annotation/cpp.thrift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ struct AllowLegacyDeprecatedTerseWritesRef {}
413413
/**
414414
* If there are custom types in thrift structure (e.g., `std::unordered_map` field),
415415
* We won't define `operator<` automatically (unless URI exists, but that's about
416-
* to change). Note that `operator<` is always declared, unless `@cpp.NonOrderable` is used.
416+
* to change). Note that `operator<` is always declared.
417417
* This annotation ensures the `operator<` is always defined. For types that
418418
* don't have `operator<`, such as `std::unordered_map`, we will convert it to
419419
* a sorted `std::vector<pair<K*, V*>>` to do the comparison.
@@ -428,15 +428,3 @@ struct EnableCustomTypeOrdering {}
428428
*/
429429
@scope.Service
430430
struct GenerateServiceMethodDecorator {}
431-
432-
/**
433-
* Marks a structured type as non-orderable, marking `operator<` as deleted.
434-
* This is useful when types should never be ordered. By default, `operator<` is
435-
* always declared, but depending on whether or not the type's shape is considered
436-
* orderable, it may or may not be defined. See `EnableCustomTypeOrdering` for more
437-
* details.
438-
* Note: The unstructured `cpp_noncomparable` annotation has priority over this one &
439-
* will cause `operator==` && `operator<` to *not* be declared or defined.
440-
*/
441-
@scope.Structured
442-
struct NonOrderable {}

thrift/compiler/ast/uri.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ inline constexpr auto kCppEnableCustomTypeOrdering =
127127
"facebook.com/thrift/annotation/cpp/EnableCustomTypeOrdering";
128128
inline constexpr auto kCppGenerateServiceMethodDecorator =
129129
"facebook.com/thrift/annotation/cpp/GenerateServiceMethodDecorator";
130-
inline constexpr auto kCppNonOrderable =
131-
"facebook.com/thrift/annotation/cpp/NonOrderable";
132130

133131
// Java:
134132
inline constexpr auto kJavaMutableUri =

thrift/compiler/generate/t_mstch_cpp2_generator.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,6 @@ class cpp_mstch_struct : public mstch_struct {
16191619
&cpp_mstch_struct::cpp_declare_equal_to},
16201620
{"struct:cpp_noncopyable", &cpp_mstch_struct::cpp_noncopyable},
16211621
{"struct:cpp_noncomparable", &cpp_mstch_struct::cpp_noncomparable},
1622-
{"struct:cpp_nonorderable?", &cpp_mstch_struct::cpp_nonorderable},
16231622
{"struct:is_eligible_for_constexpr?",
16241623
&cpp_mstch_struct::is_eligible_for_constexpr},
16251624
{"struct:virtual", &cpp_mstch_struct::cpp_virtual},
@@ -1797,11 +1796,6 @@ class cpp_mstch_struct : public mstch_struct {
17971796
return struct_->has_unstructured_annotation(
17981797
{"cpp.noncomparable", "cpp2.noncomparable"});
17991798
}
1800-
1801-
mstch::node cpp_nonorderable() {
1802-
return struct_->has_structured_annotation(kCppNonOrderable);
1803-
}
1804-
18051799
mstch::node is_eligible_for_constexpr() {
18061800
return is_eligible_for_constexpr_(struct_) ||
18071801
struct_->has_unstructured_annotation({"cpp.methods", "cpp2.methods"});

thrift/compiler/generate/templates/cpp2/module_types.cpp.mustache

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ std::string_view {{struct:cpp_underlying_name}}::__fbthrift_get_class_name() {
117117
{{#struct:is_struct_orderable?}}
118118

119119

120-
{{^struct:cpp_nonorderable?}}
121120
{{> module_types_cpp/struct_operator_less}}
122-
{{/struct:cpp_nonorderable?}}
123121
{{/struct:is_struct_orderable?}}
124122
{{/struct:cpp_noncomparable}}
125123

@@ -140,9 +138,7 @@ std::string_view {{struct:cpp_underlying_name}}::__fbthrift_get_class_name() {
140138
{{#struct:is_struct_orderable?}}
141139

142140

143-
{{^struct:cpp_nonorderable?}}
144141
{{> module_types_cpp/union_operator_less}}
145-
{{/struct:cpp_nonorderable?}}
146142
{{/struct:is_struct_orderable?}}
147143
{{/struct:cpp_noncomparable}}
148144

thrift/compiler/generate/templates/cpp2/module_types.h.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class {{#struct:exception?}}FOLLY_EXPORT {{/struct:exception?}}{{struct:cpp_unde
230230
{{^struct:cpp_noncomparable}}
231231
232232
bool operator==(const {{struct:cpp_underlying_name}}&) const;
233-
bool operator<(const {{struct:cpp_underlying_name}}&) const{{#struct:cpp_nonorderable?}} = delete{{/struct:cpp_nonorderable?}};
233+
bool operator<(const {{struct:cpp_underlying_name}}&) const;
234234
{{/struct:cpp_noncomparable}}
235235
{{> module_types_h/union_setters}}
236236
@@ -341,7 +341,7 @@ class {{#struct:exception?}}FOLLY_EXPORT {{/struct:exception?}}{{struct:cpp_unde
341341
{{^struct:cpp_noncomparable}}
342342
343343
bool operator==(const {{struct:cpp_underlying_name}}&) const;
344-
bool operator<(const {{struct:cpp_underlying_name}}&) const{{#struct:cpp_nonorderable?}} = delete{{/struct:cpp_nonorderable?}};
344+
bool operator<(const {{struct:cpp_underlying_name}}&) const;
345345
{{/struct:cpp_noncomparable}}
346346
{{#struct:fields?}}
347347
{{> module_types_h/field_ref}}

thrift/compiler/test/fixtures/adapter/out/android/gen-android/com/facebook/thrift/annotation/cpp_deprecated/EnableCustomTypeOrdering.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* If there are custom types in thrift structure (e.g., `std::unordered_map` field),
2828
* We won't define `operator<` automatically (unless URI exists, but that's about
29-
* to change). Note that `operator<` is always declared, unless `@cpp.NonOrderable` is used.
29+
* to change). Note that `operator<` is always declared.
3030
* This annotation ensures the `operator<` is always defined. For types that
3131
* don't have `operator<`, such as `std::unordered_map`, we will convert it to
3232
* a sorted `std::vector<pair<K*, V*>>` to do the comparison.

thrift/compiler/test/fixtures/adapter/out/android/gen-android/com/facebook/thrift/annotation/cpp_deprecated/NonOrderable.java

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

thrift/compiler/test/fixtures/adapter/out/hack/gen-hack/cpp_types.php

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ public function readFromJson(string $jsonText): void {
24962496
/**
24972497
* If there are custom types in thrift structure (e.g., `std::unordered_map` field),
24982498
* We won't define `operator<` automatically (unless URI exists, but that's about
2499-
* to change). Note that `operator<` is always declared, unless `@cpp.NonOrderable` is used.
2499+
* to change). Note that `operator<` is always declared.
25002500
* This annotation ensures the `operator<` is always defined. For types that
25012501
* don't have `operator<`, such as `std::unordered_map`, we will convert it to
25022502
* a sorted `std::vector<pair<K*, V*>>` to do the comparison.
@@ -2671,93 +2671,3 @@ public function readFromJson(string $jsonText): void {
26712671

26722672
}
26732673

2674-
/**
2675-
* Marks a structured type as non-orderable, marking `operator<` as deleted.
2676-
* This is useful when types should never be ordered. By default, `operator<` is
2677-
* always declared, but depending on whether or not the type's shape is considered
2678-
* orderable, it may or may not be defined. See `EnableCustomTypeOrdering` for more
2679-
* details.
2680-
* Note: The unstructured `cpp_noncomparable` annotation has priority over this one &
2681-
* will cause `operator==` && `operator<` to *not* be declared or defined.
2682-
*
2683-
* Original thrift struct:-
2684-
* NonOrderable
2685-
*/
2686-
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/cpp/NonOrderable'))>>
2687-
class NonOrderable implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
2688-
use \ThriftSerializationTrait;
2689-
2690-
const \ThriftStructTypes::TSpec SPEC = dict[
2691-
];
2692-
const dict<string, int> FIELDMAP = dict[
2693-
];
2694-
2695-
const type TConstructorShape = shape(
2696-
);
2697-
2698-
const type TShape = shape(
2699-
);
2700-
const int STRUCTURAL_ID = 957977401221134810;
2701-
2702-
public function __construct()[] {
2703-
}
2704-
2705-
public static function withDefaultValues()[]: this {
2706-
return new static();
2707-
}
2708-
2709-
public static function fromShape(self::TConstructorShape $shape)[]: this {
2710-
return new static(
2711-
);
2712-
}
2713-
2714-
public function getName()[]: string {
2715-
return 'NonOrderable';
2716-
}
2717-
2718-
public static function getStructMetadata()[]: \tmeta_ThriftStruct {
2719-
return \tmeta_ThriftStruct::fromShape(
2720-
shape(
2721-
"name" => "cpp.NonOrderable",
2722-
"is_union" => false,
2723-
)
2724-
);
2725-
}
2726-
2727-
public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
2728-
return shape(
2729-
'struct' => dict[
2730-
'\facebook\thrift\annotation\Structured' => \facebook\thrift\annotation\Structured::fromShape(
2731-
shape(
2732-
)
2733-
),
2734-
],
2735-
'fields' => dict[
2736-
],
2737-
);
2738-
}
2739-
2740-
public static function __fromShape(self::TShape $shape)[]: this {
2741-
return new static(
2742-
);
2743-
}
2744-
2745-
public function __toShape()[]: self::TShape {
2746-
return shape(
2747-
);
2748-
}
2749-
public function getInstanceKey()[write_props]: string {
2750-
return \TCompactSerializer::serialize($this);
2751-
}
2752-
2753-
public function readFromJson(string $jsonText): void {
2754-
$parsed = json_decode($jsonText, true);
2755-
2756-
if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
2757-
throw new \TProtocolException("Cannot parse the given json string.");
2758-
}
2759-
2760-
}
2761-
2762-
}
2763-

thrift/compiler/test/fixtures/adapter/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/cpp_deprecated/EnableCustomTypeOrdering.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* If there are custom types in thrift structure (e.g., `std::unordered_map` field),
2828
* We won't define `operator<` automatically (unless URI exists, but that's about
29-
* to change). Note that `operator<` is always declared, unless `@cpp.NonOrderable` is used.
29+
* to change). Note that `operator<` is always declared.
3030
* This annotation ensures the `operator<` is always defined. For types that
3131
* don't have `operator<`, such as `std::unordered_map`, we will convert it to
3232
* a sorted `std::vector<pair<K*, V*>>` to do the comparison.

0 commit comments

Comments
 (0)