mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
tweak and slightly extend box-box-trait test
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct DroppableStruct;
|
||||
|
||||
static mut DROPPED: bool = false;
|
||||
@@ -13,7 +11,6 @@ fn drop(&mut self) {
|
||||
trait MyTrait { fn dummy(&self) { } }
|
||||
impl MyTrait for Box<DroppableStruct> {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct Whatever { w: Box<dyn MyTrait+'static> }
|
||||
|
||||
impl Whatever {
|
||||
@@ -24,8 +21,9 @@ fn new(w: Box<dyn MyTrait+'static>) -> Whatever {
|
||||
|
||||
fn main() {
|
||||
{
|
||||
let f: Box<_> = box DroppableStruct;
|
||||
let _a = Whatever::new(box f as Box<dyn MyTrait>);
|
||||
let f = Box::new(DroppableStruct);
|
||||
let a = Whatever::new(Box::new(f) as Box<dyn MyTrait>);
|
||||
a.w.dummy();
|
||||
}
|
||||
assert!(unsafe { DROPPED });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user