mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 18:04:13 +00:00
![Ramon de C Valle](/assets/img/avatar_default.png)
Moves the sanitizer ui tests to the sanitizer directory and removes the sanitizer prefix from tests file names similarly to how the sanitizer codegen tests are organized.
20 lines
405 B
Rust
20 lines
405 B
Rust
//@ needs-sanitizer-support
|
|
//@ needs-sanitizer-leak
|
|
//
|
|
//@ compile-flags: -Z sanitizer=leak -O
|
|
//
|
|
//@ run-fail
|
|
//@ error-pattern: LeakSanitizer: detected memory leaks
|
|
|
|
use std::hint::black_box;
|
|
use std::mem;
|
|
|
|
fn main() {
|
|
for _ in 0..10 {
|
|
let xs = vec![1, 2, 3];
|
|
// Prevent compiler from removing the memory allocation.
|
|
let xs = black_box(xs);
|
|
mem::forget(xs);
|
|
}
|
|
}
|