Skip to content

Commit

Permalink
Add a test using mem::forget in a const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Dec 14, 2020
1 parent d23d87c commit edb4542
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/core/tests/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,16 @@ fn assume_init_good() {

assert!(TRUE);
}

#[test]
#[cfg(not(bootstrap))]
fn forget_works_in_const_fn() {
const fn forget_arg_and_return_4(x: Vec<i32>) -> i32 {
std::mem::forget(x);
4
}

const FOUR_THE_HARD_WAY: i32 = forget_arg_and_return_4(Vec::new());

assert_eq!(FOUR_THE_HARD_WAY, 4);
}

0 comments on commit edb4542

Please sign in to comment.