rust/tests/ui/issues/issue-9446.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
619 B
Rust
Raw Normal View History

// run-pass
struct Wrapper(String);
2013-09-28 17:56:31 +00:00
impl Wrapper {
pub fn new(wrapped: String) -> Wrapper {
2013-09-28 17:56:31 +00:00
Wrapper(wrapped)
}
pub fn say_hi(&self) {
let Wrapper(ref s) = *self;
println!("hello {}", *s);
2013-09-28 17:56:31 +00:00
}
}
impl Drop for Wrapper {
fn drop(&mut self) {}
}
pub fn main() {
2013-09-28 17:56:31 +00:00
{
// This runs without complaint.
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
Wrapper::new("Bob".to_string()).say_hi();
2013-09-28 17:56:31 +00:00
}
}