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:
@ -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
21
examples/setup_warning.rs
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user