forked from model-checking/kani
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix types for codegen of intrinsic const (model-checking#268)
- Loading branch information
Showing
3 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that we get the expected results for needs_drop intrinsic | ||
|
||
use std::mem; | ||
|
||
pub struct Foo<T> { | ||
_foo: T, | ||
} | ||
|
||
impl<T> Foo<T> { | ||
fn call_needs_drop(&self) -> bool { | ||
return mem::needs_drop::<T>(); | ||
} | ||
} | ||
|
||
fn main() { | ||
// Integers don't need to be dropped | ||
let int_foo = Foo::<i32> { _foo: 0 }; | ||
assert!(!int_foo.call_needs_drop()); | ||
|
||
// But strings do need to be dropped | ||
let string_foo = Foo::<String> { _foo: "".to_string() }; | ||
assert!(string_foo.call_needs_drop()); | ||
} |