mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
use rvalue-qual Future::unit(): pass 2
Summary: This is part of "the great r-valuification of folly::Future": * This is something we should do for safety in general. * Several of folly::Future's methods are lvalue-qualified even though they act as though they are rvalue-qualified, that is, they provide a postcondition that says, in effect, callers should act as though the method invalidated its `this` object (regardless of whether that invalidation was actual or logical). * This violates the C++ principle to "Express ideas directly in code" (see Core Guidelines), and generally makes it more confusing for callers as well as hiding the actual semantics from tools (linters, compilers, etc.). * This dichotomy and confusion has manifested itself by some failures around D7840699 since lvalue-qualification hides that operation's move-out semantics - leads to some use of future operations that are really not correct, but are not obviously incorrect. * The goal of rvalueification is to make sure methods that are logically rvalue-qualified are actually rvalue-qualified, which forces callsites to acknowledge that rvalueification, e.g., `std::move(f).unit(...)` instead of `f.unit(...)`. This syntactic change in the callsites forces callers to acknowledge the method's rvalue semantics. Codemod changes: * expr.unit(...) ==> std::move(expr).unit(...) // if expr is not already an xvalue * expr->unit(...) ==> std::move(*expr).unit(...) Note: operator precedence of that last step is safe - no need to parenthesize `expr`. Reason: `->` binds more tightly than unary `*`. Reviewed By: LeeHowes Differential Revision: D9347419 fbshipit-source-id: 2773365f3793d977f2bad1c0a85ef394633e7d2c
This commit is contained in:
parent
6394450579
commit
b430d2c094
@ -2960,7 +2960,7 @@ folly::Future<folly::Unit> TreeInode::loadMaterializedChildren(
|
||||
results.emplace_back(
|
||||
recurse == Recurse::DEEP
|
||||
? std::move(future).then(recursivelyLoadMaterializedChildren)
|
||||
: future.unit());
|
||||
: std::move(future).unit());
|
||||
}
|
||||
|
||||
return folly::collectAll(results).unit();
|
||||
|
Loading…
Reference in New Issue
Block a user