Unverified Commit 217668f6 authored by Mircea Trofin's avatar Mircea Trofin Committed by GitHub
Browse files

[nfc] Allow forwarding `Error` returns from `Expected` callers (#92208)

On a few compilers (clang 11/12 for example [1]), the following does not
result in a copy elision, and since `Error`'s copy dtor is elided,
results in a compile error:

```
  Expect<Something> foobar() {
    ...
    if (Error E = aCallReturningError())
      return E;
    ...
  }
```

Moving `E` would, conversely, result in the pessimizing-move warning on
more recent clangs ("moving a local object in a return statement
prevents copy elision")

We just need to make the `Expected` ctor taking an `Error` take it as a
r-value reference.

[1] https://lab.llvm.org/buildbot/#/builders/54/builds/10505
parent d92c6778
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment