diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-28 15:30:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-28 15:30:02 +0530 |
| commit | ec8477fea1989bb187ec026b2dad3e4b89d60e91 (patch) | |
| tree | 9570e2eae5c4947563dfad2ab41a39743755f052 /compiler/rustc_codegen_llvm/src | |
| parent | 9b3dbb8200154d3432c6ba4c4094f96102494330 (diff) | |
| parent | a0eba6634f1430e29637257fd1416f896bcf9edc (diff) | |
| download | rust-ec8477fea1989bb187ec026b2dad3e4b89d60e91.tar.gz rust-ec8477fea1989bb187ec026b2dad3e4b89d60e91.zip | |
Rollup merge of #98337 - c410-f3r:assert-compiler, r=oli-obk
[RFC 2011] Optimize non-consuming operators
Tracking issue: https://github.com/rust-lang/rust/issues/44838
Fifth step of https://github.com/rust-lang/rust/pull/96496
The most non-invasive approach that will probably have very little to no performance impact.
## Current behaviour
Captures are handled "on-the-fly", i.e., they are performed in the same place expressions are located.
```rust
// `let a = 1; let b = 2; assert!(a > 1 && b < 100);`
if !(
{ ***try capture `a` and then return `a`*** } > 1 && { ***try capture `b` and then return `b`*** } < 100
) {
panic!( ... );
}
```
As such, some overhead is likely to occur (Specially with very large chains of conditions).
## New behaviour for non-consuming operators
When an operator is known to not take `self`, then it is possible to capture variables **AFTER** the condition.
```rust
// `let a = 1; let b = 2; assert!(a > 1 && b < 100);`
if !( a > 1 && b < 100 ) {
{ ***try capture `a`*** }
{ ***try capture `b`*** }
panic!( ... );
}
```
So the possible impact on the runtime execution time will be diminished.
r? ````@oli-obk````
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
