summaryrefslogtreecommitdiffstats
path: root/src/test/ui/box/new-box.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/box/new-box.rs')
-rw-r--r--src/test/ui/box/new-box.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/box/new-box.rs b/src/test/ui/box/new-box.rs
new file mode 100644
index 000000000..96a3b197f
--- /dev/null
+++ b/src/test/ui/box/new-box.rs
@@ -0,0 +1,30 @@
+// run-pass
+
+fn f(x: Box<isize>) {
+ let y: &isize = &*x;
+ println!("{}", *x);
+ println!("{}", *y);
+}
+
+trait Trait {
+ fn printme(&self);
+}
+
+struct Struct;
+
+impl Trait for Struct {
+ fn printme(&self) {
+ println!("hello world!");
+ }
+}
+
+fn g(x: Box<dyn Trait>) {
+ x.printme();
+ let y: &dyn Trait = &*x;
+ y.printme();
+}
+
+fn main() {
+ f(Box::new(1234));
+ g(Box::new(Struct) as Box<dyn Trait>);
+}