rust/compiler/rustc_builtin_macros/src
Dylan DPC ec8477fea1
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````
2022-06-28 15:30:02 +05:30
..
assert [RFC 2011] Optimize non-consuming operators 2022-06-21 10:56:26 -03:00
deriving Optimize the code produced by derive(Debug). 2022-06-24 09:40:15 +10:00
format_foreign update tests 2021-12-31 12:51:27 -05:00
asm.rs remove unnecessary to_string and String::new for tool_only_span_suggestion 2022-06-13 16:01:16 +09:00
assert.rs remove unnecessary to_string and String::new 2022-06-13 15:48:40 +09:00
cfg.rs macros: use typed identifiers in diag derive 2022-06-24 09:08:25 +01:00
cfg_accessible.rs Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
cfg_eval.rs rustc_parse: Move AST -> TokenStream conversion logic to rustc_ast 2022-05-22 12:01:07 +03:00
cmdline_attrs.rs Unconditionally capture tokens for attributes. 2020-10-21 18:57:29 -04:00
compile_error.rs check_doc_keyword: don't alloc string for emptiness check 2022-04-08 11:45:57 +03:00
concat.rs Adopt let else in more places 2022-02-19 17:27:43 +01:00
concat_bytes.rs Adopt let else in more places 2022-02-19 17:27:43 +01:00
concat_idents.rs Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
derive.rs remove unnecessary to_string and String::new 2022-06-13 15:48:40 +09:00
edition_panic.rs Spellchecking some comments 2022-03-30 01:39:38 -04:00
env.rs check_doc_keyword: don't alloc string for emptiness check 2022-04-08 11:45:57 +03:00
format.rs Rename some ExtCtxt methods. 2022-06-23 11:10:43 +10:00
format_foreign.rs [rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape 2021-12-31 12:42:15 -05:00
global_allocator.rs Point at type when a static #[global_allocator] doesn't impl GlobalAlloc 2021-12-15 01:40:08 +00:00
lib.rs [RFC 2011] Minimal initial implementation 2022-06-15 07:37:40 -03:00
log_syntax.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
proc_macro_harness.rs Rename some ExtCtxt methods. 2022-06-23 11:10:43 +10:00
source_util.rs Add support for a new attribute #[debugger_visualizer] to support embedding debugger visualizers into a generated PDB. 2022-05-03 10:53:54 -07:00
standard_library_imports.rs Create 2024 edition 2022-04-02 02:45:49 -04:00
test.rs remove unnecessary to_string and String::new 2022-06-13 15:48:40 +09:00
test_harness.rs Auto merge of #98190 - nnethercote:optimize-derive-Debug-code, r=scottmcm 2022-06-26 15:00:04 +00:00
trace_macros.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
util.rs Add a lint for duplicated attributes. 2021-12-15 23:43:13 +01:00