error[E0597]: `x` does not live long enough --> src/main.rs:13:20 | 13 | y = MyBox::new(&x); | ^^ borrowed value does not live long enough 14 | } | - | | | `x` dropped here while still borrowed | borrow might be used here, when `y` is dropped and runs the `Drop` code fortype `MyBox` | = note: values in a scope are dropped in the opposite order they are defined
error: Undefined Behavior: pointer to alloc999 was dereferenced after this allocation got freed --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:2116:1 | 2116 | fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to alloc999 was dereferenced after this allocation got freed | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: inside `<&Hello<i32> as std::fmt::Debug>::fmt` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:2106:71 = note: inside `std::fmt::write` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:1168:17 = note: inside `<std::io::StdoutLock as std::io::Write>::write_fmt` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:1653:15 = note: inside `<&std::io::Stdout as std::io::Write>::write_fmt` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/stdio.rs:844:9 = note: inside `<std::io::Stdout as std::io::Write>::write_fmt` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/stdio.rs:818:9 = note: inside `std::io::stdio::print_to::<std::io::Stdout>` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/stdio.rs:1186:21 = note: inside `std::io::_print` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/stdio.rs:1199:5 note: inside `<Hello<&Hello<i32>> as std::ops::Drop>::drop` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/macros.rs:99:9 --> src/main.rs:32:9 | 32 | println!("Drop hello({}, {:?}, {:?})", self.0, self.1, self.2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: inside `std::ptr::drop_in_place::<Hello<&Hello<i32>>> - shim(Some(Hello<&Hello<i32>>))` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1 note: inside `<MyBox<Hello<&Hello<i32>>> as std::ops::Drop>::drop` at src/main.rs:59:13 --> src/main.rs:59:13 | 59 | ptr::drop_in_place(self.v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: inside `std::ptr::drop_in_place::<MyBox<Hello<&Hello<i32>>>> - shim(Some(MyBox<Hello<&Hello<i32>>>))` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1 note: inside `main` at src/main.rs:13:1
#![allow(unused)] #![feature(dropck_eyepatch)] use std::alloc::{GlobalAlloc, Layout, System}; use std::fmt; use std::mem; use std::ptr; use std::marker::PhantomData;
fnmain() { let (y, x); x = Hello::new("x", 13); y = MyBox::new(Hello::new("y", &x)); }
error[E0597]: `x` does not live long enough --> src/main.rs:13:36 | 13 | y = MyBox::new(Hello::new("y", &x)); | ^^ borrowed value does not live long enough 14 | } | - | | | `x` dropped here while still borrowed | borrow might be used here, when `y` is dropped and runs the `Drop` code fortype `MyBox` | = note: values in a scope are dropped in the opposite order they are defined
#![allow(unused)] #![feature(dropck_eyepatch)] use std::alloc::{GlobalAlloc, Layout, System}; use std::fmt; use std::mem; use std::ptr; use std::marker::PhantomData;
fnmain() { let (y, x); x = Hello::new("x", 13); y = MyBox::new(Hello::new("y", &x)); }