c1cda0793e
Some compile-fail tests illustrated cases to be rejected by dropck, including ones that check cyclic data cases designed to exposed bugs if they are actually tricked into running by an unsound analysis. E.g. these exposed bugs in earlier broken ways of handling `Vec<T>`. (Note that all the uses of `unsafe_destructor` are just placating the simple analysis used for that feature, which will eventually go away once we have put the dropck through its paces.)
22 lines
705 B
Rust
22 lines
705 B
Rust
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
// Tests the new destructor semantics.
|
|
|
|
use std::cell::RefCell;
|
|
|
|
fn main() {
|
|
let b = {
|
|
let a = Box::new(RefCell::new(4i8));
|
|
*a.borrow() + 1i8 //~ ERROR `*a` does not live long enough
|
|
};
|
|
println!("{}", b);
|
|
}
|