about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-05-25 10:48:29 +0200
committerGitHub <noreply@github.com>2022-05-25 10:48:29 +0200
commitca269b1e797c7d5da4e90ba0bdb06eae7f3dcfd9 (patch)
tree95060a247500ecf86f86697ac0c939fca0f192db /compiler/rustc_llvm/llvm-wrapper
parentc12a36adc6e36a9d177c5bb608f5d29c512b0717 (diff)
parent664e8a9ce541f0921af23dc9e48b6386b34e8bcf (diff)
downloadrust-ca269b1e797c7d5da4e90ba0bdb06eae7f3dcfd9.tar.gz
rust-ca269b1e797c7d5da4e90ba0bdb06eae7f3dcfd9.zip
Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm
[RFC 2011] Library code

CC https://github.com/rust-lang/rust/pull/96496

Based on https://github.com/dtolnay/case-studies/tree/master/autoref-specialization.

Basically creates two traits with the same method name. One trait is generic over any `T` and the other is specialized to any `T: Printable`.

The compiler will then call the corresponding trait method through auto reference.

```rust
fn main() {
    let mut a = Capture::new();
    let mut b = Capture::new();

    (&Wrapper(&1i32)).try_capture(&mut a); // `try_capture` from `TryCapturePrintable`
    (&Wrapper(&vec![1i32])).try_capture(&mut b); // `try_capture` from `TryCaptureGeneric`

    assert_eq!(format!("{:?}", a), "1");
    assert_eq!(format!("{:?}", b), "N/A");
}
```

r? `@scottmcm`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper')
0 files changed, 0 insertions, 0 deletions