about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2019-10-22 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2019-12-01 09:03:35 +0100
commitc703ff26555bc25739384b2104dfb538ec7435c7 (patch)
tree7b0f97002a7356faa17d75e45ceb0ada77072ba0 /src/doc
parent135ccbaca86ed4b9c0efaf0cd31442eae57ffad7 (diff)
downloadrust-c703ff26555bc25739384b2104dfb538ec7435c7.tar.gz
rust-c703ff26555bc25739384b2104dfb538ec7435c7.zip
Conditional compilation for sanitizers
Configure sanitize option when compiling with a sanitizer to make
it possible to execute different code depending on whether given
sanitizer is enabled or not.
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/language-features/cfg-sanitize.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/cfg-sanitize.md b/src/doc/unstable-book/src/language-features/cfg-sanitize.md
new file mode 100644
index 00000000000..949f24ab9c1
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/cfg-sanitize.md
@@ -0,0 +1,36 @@
+# `cfg_sanitize`
+
+The tracking issue for this feature is: [#39699]
+
+[#39699]: https://github.com/rust-lang/rust/issues/39699
+
+------------------------
+
+The `cfg_sanitize` feature makes it possible to execute different code
+depending on whether a particular sanitizer is enabled or not.
+
+## Examples
+
+``` rust
+#![feature(cfg_sanitize)]
+
+#[cfg(sanitize = "thread")]
+fn a() {
+  // ...
+}
+
+#[cfg(not(sanitize = "thread"))]
+fn a() {
+  // ...
+}
+
+fn b() {
+  if cfg!(sanitize = "leak") {
+    // ...
+  } else {
+    // ...
+  }
+}
+
+```
+