Skip to content

Commit c986337

Browse files
committed
Update to reflect what was decided
1 parent 0580a69 commit c986337

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

active/0000-assert.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44

55
# Summary
66

7-
Asserts are too expensive for release builds and mess up inlining. There must be a way to turn them off. I propose macros `assert!` and `enforce!`. For test cases, `enforce!` should be used.
7+
Asserts are too expensive for release builds and mess up inlining. There must be a way to turn them off. I propose macros `debug_assert!` and `assert!`. For test cases, `assert!` should be used.
88

99
# Motivation
1010

1111
Asserts are too expensive in release builds.
1212

1313
# Detailed design
1414

15-
There should be two macros, `assert!(EXPR)` and `enforce!(EXPR)`. In debug builds (without `--cfg ndebug`), `assert!()` is the same as `enforce!()`. In release builds (with `--cfg ndebug`), `assert!()` compiles away to nothing. The definition of `enforce!()` is `if (!EXPR) { fail!("assertion failed ({}, {}): {}", file!(), line!(), stringify!(expr) }`
15+
There should be two macros, `debug_assert!(EXPR)` and `assert!(EXPR)`. In debug builds (without `--cfg ndebug`), `debug_assert!()` is the same as `assert!()`. In release builds (with `--cfg ndebug`), `debug_assert!()` compiles away to nothing. The definition of `assert!()` is `if (!EXPR) { fail!("assertion failed ({}, {}): {}", file!(), line!(), stringify!(expr) }`
1616

1717
# Alternatives
1818

19-
Other designs that have been considered are using `assert!` in test cases and not providing `enforce!`, but this doesn't work with separate compilation.
19+
Other designs that have been considered are using `debug_assert!` in test cases and not providing `assert!`, but this doesn't work with separate compilation.
2020

21-
There has been an issue raised that `enforce!` is unintuitive for test cases, but I think all workarounds for this are worse because they add complexity.
22-
23-
The impact of not doing this is that `assert!` will become expensive, prompting people will write their own local `assert!` macros, duplicating functionality that should have been in the standard library.
21+
The impact of not doing this is that `assert!` will be expensive, prompting people will write their own local `debug_assert!` macros, duplicating functionality that should have been in the standard library.
2422

2523
# Unresolved questions
2624

0 commit comments

Comments
 (0)