Commit Graph

6 Commits

Author SHA1 Message Date
Jeremy Fitzhardinge
473f262c65 tp2/rust: update to rust-1.30.0
Summary:
rustc-1.30.0 tries to work out what the linker actually is from the name, and
gets confused because the script we pass it is actually gcc (or clang), but has
`ld` in the name. Update the command-line options to also pass
`-Zlinker-flavor=gcc` to override the linker flavor inference.

proc_macros are now stable. The `quote` crate has a dependency on the `proc_macro`
which is now a shared object as part of the rustc distribution, which means that things
using `quote` must have a runtime linkage with the rustc libraries. The Thrift `codegen`
binary is the main thing affected by this, and I've hacked around it by putting an
`LD_LIBRARY_PATH` in the Buck macros. Need to find a nicer fix though.

rustc 1.30 now implements `#[macro_export(local_inner_macros)]`, which has
strict semantics around namespaces and symbol hygiene, which doesn't work with
common/rust/sql's macros. Work around this for now by just exporting
everything.

Reviewed By: kulshrax

Differential Revision: D12811597

fbshipit-source-id: f18d12e6d99994876c29d3a6bd6ae43f1f37dd17
2018-11-06 16:17:18 -08:00
Jeremy Fitzhardinge
4f7f38c1a0 rust/failure_ext: add .chain()/Chain
Summary:
Add a type to explicitly model a causal chain of errors, akin to
error_chain. This looks a lot like Context, but is intended to show the entire
stack of errors rather than deciding that only the top-level one is
interesting.

This adds a `ChainExt` trait, which adds a `.chain_ext(OuterError)` method to
add another step to the causal chain. This is implemented for:
- `F` where `F: Fail`
- `Error`
- `Result<_, F>` where `F: Fail`
- `Result<_, Error>`
- `Future`/`Stream<Error=F>` where `F: Fail`
- `Future`/`Stream<Error=Error>`
- `Chain`

Using it is simple:
```
let res = something_faily().chain_err(LocalError::new("Something amiss"))?;
```
where `something_faily()` returns any of the above types.

(This is done by adding an extra dummy marker type parameter to the `ChainExt`
trait so that it can avoid problems with the coherence rules - thanks for the idea @[100000771202578:kulshrax]!)

Reviewed By: lukaspiatkowski

Differential Revision: D9394192

fbshipit-source-id: 0817844d283b3900d2555f526c2683231ca7fe12
2018-09-06 14:24:08 -07:00
Jeremy Fitzhardinge
b44055a6b3 rust/failure_ext: add err_downcast/err_downcast_ref macros
Summary:
Add a pair of macros to make downcasting errors less tedious:
```
let res = err_downcast! {
    err, // failure::Error
    foo: FooError => { println!("err is an FooError! {:?}", foo) },
    bar: BarError => { println!("err is a BarError! {:?}", bar) },
};
```

`err_downcast` takes `failure::Error` and deconstructs it into one of the
desired types and returns `Ok(match action)`, or returning it as `Err(Error)`
if nothing matches.

`err_downcast_ref` takes `&failure::Error` and gives a reference type. It
returns `Some(match action)` or `None` if nothing matches.

The error types are required to implement `failure::Fail`.

`err_downcast_ref` also matches each error type `E` as `Context<E>`.

Reviewed By: lukaspiatkowski

Differential Revision: D9394193

fbshipit-source-id: c56d91362d5bed8ab3e254bc44bb6f8a0eb376a2
2018-09-06 14:24:06 -07:00
Jeremy Fitzhardinge
916d8b6813 rust/failure_ext: move slogkv into submodule
Summary: Avoid cluttering top-level module.

Reviewed By: farnz

Differential Revision: D9394195

fbshipit-source-id: ae7b6e7c182eaf50cfad075cee4b0775c1df0e68
2018-08-20 12:37:04 -07:00
Jeremy Fitzhardinge
3d24be22aa tp2/rust: rust-crates-io update
Summary: Update rust-crates-io. Small changes needed for failure 0.1.2 update.

Reviewed By: rahulg

Differential Revision: D9125235

fbshipit-source-id: fd98af065b54e207fcb2c3cfc9dd9a2d325cc6c8
2018-08-02 10:06:47 -07:00
Lukas Piatkowski
b03d5cf630 'Re-sync with internal repository' 2018-07-26 09:09:45 -07:00