Commit Graph

70 Commits

Author SHA1 Message Date
Mara Bos afe5335b97 Use correct edition for panic in [debug_]assert!() etc. 2021-10-07 14:27:08 +02:00
Mark Rousskov b4e7649d6d Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
Cameron Steffen 975bc18481 Make Arguments constructors unsafe 2021-08-16 16:28:16 +00:00
Amanieu d'Antras 4dd933cdc2 Deprecate llvm_asm! 2021-08-15 13:14:32 +01:00
bors 24bbf7ac2f Auto merge of #85272 - ChayimFriedman2:matches-leading-pipe, r=m-ou-se
Allow leading pipe in `matches!()` patterns.

This is allowed in `match` statement, and stated in https://internals.rust-lang.org/t/leading-pipe-in-core-matches/14699/2 that it should be allowed in these macros too.
2021-08-02 00:13:40 +00:00
Pietro Albini 24f9de5a44 bump bootstrap compiler to 1.55 2021-08-01 11:19:24 -04:00
Mara Bos 312bf8e0b8 Extend documentation of const_format_args!(). 2021-07-28 16:18:38 +02:00
Mara Bos 38bf5b0412 Make const_fmt_args!() work during bootstrap. 2021-07-28 16:12:31 +02:00
Mara Bos b64c4f9560 Add new const_format_args!() macro and use it in panics. 2021-07-28 16:12:25 +02:00
Jonas Schievink 04634e88a3 Mark format_args_nl as #[doc(hidden)] 2021-07-23 19:04:07 +02:00
bstrie f26fbe2453 Move asm! and global_asm! to core::arch 2021-07-18 18:30:58 -04:00
Jane Lusby d0e8de68c4 i sweat to god 2021-07-16 13:25:11 -07:00
Jane Lusby 085d52c588 pls this time 2021-07-16 12:16:39 -07:00
Chayim Refael Friedman f10da9f50a Allow leading pipe in matches!() patterns.
This is allowed in `match` statement, and stated in https://internals.rust-lang.org/t/leading-pipe-in-core-matches/14699/2 that it should be allowed in these macros too.
2021-07-15 22:05:45 +03:00
Yuki Okushi a5acb7b4ba Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc
Move assert_matches to an inner module

Fixes #82913
2021-07-15 21:19:16 +09:00
Vadim Petrochenkov 6c9ea1e8a9 expand: Support helper attributes for built-in derive macros 2021-07-13 21:59:22 +03:00
Mara Bos e3044432c7 Move [debug_]assert_matches to mod {core, std}::assert. 2021-07-08 02:33:36 +02:00
Lukas Markeffsky 3ed90e2424 fix matches! and assert_matches! on edition 2021 2021-05-25 16:44:20 +02:00
Nick Lamb 54ccf95af2 Better English for documenting when to use unimplemented!() 2021-05-24 22:21:05 +01:00
Amanieu d'Antras 5918ee4317 Add support for const operands and options to global_asm!
On x86, the default syntax is also switched to Intel to match asm!
2021-05-13 22:31:57 +01:00
Mark Rousskov b3a4f91b8d Bump cfgs 2021-04-04 14:57:05 -04:00
J. Frimmel 19bd0669b4 Apply suggestions from code review
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-03-18 21:15:19 +01:00
Julian Frimmel d5e45b50cd Incorporate review feedback #2 2021-03-18 15:15:28 +01:00
Julian Frimmel 61e5d549b4 Add more information about panicking
This includes the description of the default `std` behavior and mentions
the `panic::set_hook()` function.
2021-03-18 14:24:13 +01:00
Julian Frimmel 55d9e0f601 Include output stream in panic!() documentation 2021-03-18 09:52:21 +01:00
Mara Bos 924e522d16 Deprecate RustcEncodable and RustcDecodable. 2021-03-15 20:16:16 +01:00
Vadim Petrochenkov 5dad6c2575 Implement built-in attribute macro #[cfg_eval] 2021-03-06 23:03:19 +03:00
Mara Bos 80fcdef3b5 Add tracking issue for assert_matches. 2021-03-04 21:33:31 +01:00
Mara Bos f223affd7a Don't consume the expression in assert_matches!()'s failure case. 2021-03-04 19:36:36 +01:00
Mara Bos 5bd1204fc2 Fix assert_matches doc examples. 2021-03-04 18:41:43 +01:00
Mara Bos 0a8e401188 Add debug_assert_matches macro. 2021-03-04 18:12:33 +01:00
Mara Bos cfce60ea37 Allow for multiple patterns and a guard in assert_matches. 2021-03-04 18:12:26 +01:00
Mara Bos eb18746bc6 Add assert_matches!(expr, pat). 2021-03-04 18:07:20 +01:00
LeSeulArtichaut a6eb836ff0 Use #[doc = include_str!()] in std 2021-02-23 15:54:55 +01:00
bors cd64446196 Auto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrum
Update the bootstrap compiler

This updates the bootstrap compiler, notably leaving out a change to enable semicolon in macro expressions lint, because stdarch still depends on the old behavior.
2021-02-23 07:19:41 +00:00
bors ed58a2b03b Auto merge of #79100 - a1phyr:better_assert_eq, r=m-ou-se
Improve assert_eq! and assert_ne!

This PR improves `assert_eq!` and `assert_ne!` by moving the panicking code in an external function.

It does not change the fast path, but the move of the formatting in the cold path (the panic) may have a positive effect on in instruction cache use and with inlining.

Moreover, the use of trait objects instead of generic may improve compile times for `assert_eq!`-heavy code.

Godbolt link: ~~https://rust.godbolt.org/z/TYa9MT~~ \
Updated: https://rust.godbolt.org/z/bzE84x
2021-02-21 05:41:09 +00:00
Joshua Nelson 3733275854 Update the bootstrap compiler
Note this does not change `core::derive` since it was merged after the
beta bump.
2021-02-20 17:19:30 -05:00
Guillaume Gomez 16481a2857 Rollup merge of #82169 - not-an-aardvark:assert-lazy-format-expressions, r=sfackler
Document that `assert!` format arguments are evaluated lazily

It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:

```rust
assert!(
    some_condition,
    "The state is invalid. Details: {}",
    expensive_call_to_get_debugging_info(),
);
```

It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
2021-02-17 20:38:00 +01:00
Teddy Katz cb653b100c Document that assert! format arguments are evaluated lazily
It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:

```rust
assert!(
    some_condition,
    "The state is invalid. Details: {}",
    expensive_call_to_get_debugging_info(),
);
```

It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
2021-02-16 00:55:46 -05:00
Benoît du Garreau 546d062820 Apply suggestions
- Move `assert_failed` to core::panicking`
- Make `assert_failed` use an enum instead of a string
2021-02-14 23:39:42 +01:00
Benoît du Garreau f138e260a0 Apply suggestion 2021-02-14 23:39:42 +01:00
Benoît du Garreau 52197d356c Fix UI tests and merge assert_eq and assert_ne internal functions 2021-02-14 23:39:31 +01:00
lukaslueg 3d7fcfff76 Update library/core/src/macros/mod.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-14 23:33:43 +01:00
Benoît du Garreau bbad2b2182 Improve assert_eq! and assert_ne!
It should improve compile times and reduce instruction cache use by moving the
panic formatting to a monomorphised function
2021-02-14 23:04:41 +01:00
Lukas Lueg dee54244a6 Add missing env!-decl variant
Resolves #82117
2021-02-14 22:39:47 +01:00
Vadim Petrochenkov dbdbd30bf2 expand/resolve: Turn #[derive] into a regular macro attribute 2021-02-07 20:08:45 +03:00
Mara Bos 753b0b0b80 Update panic!() documentation about non-string panics. 2021-02-03 23:15:51 +01:00
Mara Bos ed1de99b4f Fix bug with assert!() calling the wrong edition of panic!().
The span of `panic!` produced by the `assert` macro did not carry the
right edition. This changes `assert` to call the right version.
2021-02-01 23:23:27 +01:00
Mara Bos d5414f9a9f Implement new panic!() behaviour for Rust 2021. 2021-01-25 13:48:11 +01:00
Mara Bos dec5cfbaba Remove unused allow_internal_unstable on core::panic. 2021-01-25 13:48:10 +01:00