Switch to trailing returns in toolchain and related code. (#4919)

Also makes the style guide explicitly comment on void, but this was the
intent IIRC because it matches Carbon's `-> ()` (and "always" versus
"except for void", which we definitely went back and forth on).

Includes adjusting function pointers, which I definitely forget this
syntax works sometimes.

Excludes utils/tree_sitter/src/scanner.c because it claims to be C, but
really we should probably fix that to be cpp.
This commit is contained in:
Jon Ross-Perkins
2025-02-11 18:11:14 +00:00
committed by GitHub
parent 316a6c59e9
commit 2fef1cb713
38 changed files with 289 additions and 251 deletions
+6 -4
View File
@@ -25,7 +25,7 @@ using ::testing::Pair;
using ::testing::UnorderedElementsAreArray;
template <typename MapT, typename MatcherRangeT>
void ExpectMapElementsAre(MapT&& m, MatcherRangeT element_matchers) {
auto ExpectMapElementsAre(MapT&& m, MatcherRangeT element_matchers) -> void {
// Now collect the elements into a container.
using KeyT = typename std::remove_reference<MapT>::type::KeyT;
using ValueT = typename std::remove_reference<MapT>::type::ValueT;
@@ -41,14 +41,16 @@ void ExpectMapElementsAre(MapT&& m, MatcherRangeT element_matchers) {
// Allow directly using an initializer list.
template <typename MapT, typename MatcherT>
void ExpectMapElementsAre(MapT&& m,
std::initializer_list<MatcherT> element_matchers) {
auto ExpectMapElementsAre(MapT&& m,
std::initializer_list<MatcherT> element_matchers)
-> void {
std::vector<MatcherT> element_matchers_storage = element_matchers;
ExpectMapElementsAre(m, element_matchers_storage);
}
template <typename ValueCB, typename RangeT, typename... RangeTs>
auto MakeKeyValues(ValueCB value_cb, RangeT&& range, RangeTs&&... ranges) {
auto MakeKeyValues(ValueCB value_cb, RangeT&& range, RangeTs&&... ranges)
-> auto {
using KeyT = typename RangeT::value_type;
using ValueT = decltype(value_cb(std::declval<KeyT>()));
std::vector<std::pair<KeyT, ValueT>> elements;