You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: posts/2024-05-02-Rust-1.78.0.md
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -84,20 +84,21 @@ For more information, see the reference section on [the `diagnostic` tool attrib
84
84
85
85
### Asserting `unsafe` preconditions
86
86
87
-
The Rust standard library has a number of assertions for the preconditions of `unsafe` functions, but historically they have only been enabled in `#[cfg(debug_assertions)]` builds to avoid affecting release performance. However, since the standard library is usually compiled and distributed in release mode, most Rust developers weren't ever executing these checks at all.
87
+
The Rust standard library has a number of assertions for the preconditions of `unsafe` functions, but historically they have only been enabled in `#[cfg(debug_assertions)]` builds of the standard library to avoid affecting release performance. However, since the standard library is usually compiled and distributed in release mode, most Rust developers weren't ever executing these checks at all.
88
88
89
89
Now, the condition for these assertions is delayed until code generation, so they will be checked depending on the user's own setting for debug assertions -- enabled by default in debug and test builds. This change helps users catch undefined behavior in their code, though the details of how much is checked are generally not stable.
90
90
91
-
For example, [`slice::from_raw_parts`](https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html) requires an aligned non-null pointer. The following use of a purposely-misaligned pointer has undefined behavior, _which may or may not cause noticeable ill effect otherwise_, but the debug assertion can now catch it:
91
+
For example, [`slice::from_raw_parts`](https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html) requires an aligned non-null pointer. The following use of a purposely-misaligned pointer has undefined behavior, and while that may not have obvious effects, the debug assertion can now catch it:
0 commit comments