2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2014-05-22 23:57:53 +00:00
|
|
|
struct Wrapper(String);
|
2013-09-28 17:56:31 +00:00
|
|
|
|
|
|
|
impl Wrapper {
|
2014-05-22 23:57:53 +00:00
|
|
|
pub fn new(wrapped: String) -> Wrapper {
|
2013-09-28 17:56:31 +00:00
|
|
|
Wrapper(wrapped)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn say_hi(&self) {
|
2013-11-02 01:06:31 +00:00
|
|
|
let Wrapper(ref s) = *self;
|
|
|
|
println!("hello {}", *s);
|
2013-09-28 17:56:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for Wrapper {
|
|
|
|
fn drop(&mut self) {}
|
|
|
|
}
|
|
|
|
|
2013-10-01 02:40:44 +00:00
|
|
|
pub fn main() {
|
2013-09-28 17:56:31 +00:00
|
|
|
{
|
|
|
|
// This runs without complaint.
|
2014-05-25 10:17:19 +00:00
|
|
|
let x = Wrapper::new("Bob".to_string());
|
2013-09-28 17:56:31 +00:00
|
|
|
x.say_hi();
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// This fails to compile, circa 0.8-89-gc635fba.
|
|
|
|
// error: internal compiler error: drop_ty_immediate: non-box ty
|
2014-05-25 10:17:19 +00:00
|
|
|
Wrapper::new("Bob".to_string()).say_hi();
|
2013-09-28 17:56:31 +00:00
|
|
|
}
|
|
|
|
}
|