1
0
mirror of https://github.com/bspeice/qadapt synced 2025-07-01 05:46:16 -04:00

Warning message if guards without allocator enabled

This commit is contained in:
2018-11-22 11:19:31 -05:00
parent e68316527f
commit 095fd797c4
4 changed files with 40 additions and 2 deletions

View File

@ -14,6 +14,7 @@ fn does_allocate() -> Box<u8> {
fn main() {
// If you were to run `cargo run --example release_mode`, this program blows up.
// If, however, you ran `cargo run --release --example release_mode`,
// nothing interesting will happen.
// nothing interesting will happen since panic-related code is stripped
// for release builds.
does_allocate();
}

21
examples/setup_warning.rs Normal file
View File

@ -0,0 +1,21 @@
extern crate env_logger;
extern crate qadapt;
use qadapt::allocate_panic;
// Note that we're missing the `#[global_allocator]` attribute
#[allocate_panic]
fn does_allocate() -> Box<u8> {
Box::new(0)
}
fn main() {
// This code will warn that QADAPT isn't being used, but won't trigger a panic.
// Run with `RUST_LOG=warn cargo run --example setup_warning`
env_logger::init();
does_allocate();
// The warning will only trigger once though
does_allocate();
}