]> git.lizzy.rs Git - rust.git/blob - src/test/ui/sanitize/leak.rs
Auto merge of #2607 - RalfJung:rustup, r=RalfJung
[rust.git] / src / test / ui / sanitize / leak.rs
1 // needs-sanitizer-support
2 // needs-sanitizer-leak
3 //
4 // compile-flags: -Z sanitizer=leak -O
5 //
6 // run-fail
7 // error-pattern: LeakSanitizer: detected memory leaks
8
9 use std::hint::black_box;
10 use std::mem;
11
12 fn main() {
13     for _ in 0..10 {
14         let xs = vec![1, 2, 3];
15         // Prevent compiler from removing the memory allocation.
16         let xs = black_box(xs);
17         mem::forget(xs);
18     }
19 }