Auto merge of #27261 - arielb1:drop-sanity-check, r=pnkfelix
This fixes multiple bugs, and as several of these are soundness issue, is a [breaking-change]. r? @pnkfelix
This commit is contained in:
commit
d576ef3d7b
6 changed files with 331 additions and 270 deletions
29
src/test/run-pass/issue-24086.rs
Normal file
29
src/test/run-pass/issue-24086.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
pub struct Registry<'a> {
|
||||
listener: &'a mut (),
|
||||
}
|
||||
|
||||
pub struct Listener<'a> {
|
||||
pub announce: Option<Box<FnMut(&mut Registry) + 'a>>,
|
||||
pub remove: Option<Box<FnMut(&mut Registry) + 'a>>,
|
||||
}
|
||||
|
||||
impl<'a> Drop for Registry<'a> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut registry_listener = Listener {
|
||||
announce: None,
|
||||
remove: None,
|
||||
};
|
||||
}
|
||||
15
src/test/run-pass/issue-26641.rs
Normal file
15
src/test/run-pass/issue-26641.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
struct Parser<'a>(Box<FnMut(Parser) + 'a>);
|
||||
|
||||
fn main() {
|
||||
let _x = Parser(Box::new(|_|{}));
|
||||
}
|
||||
33
src/test/run-pass/issue-27240.rs
Normal file
33
src/test/run-pass/issue-27240.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
use std::fmt;
|
||||
struct NoisyDrop<T: fmt::Debug>(T);
|
||||
impl<T: fmt::Debug> Drop for NoisyDrop<T> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
struct Bar<T: fmt::Debug>([*const NoisyDrop<T>; 2]);
|
||||
|
||||
fn fine() {
|
||||
let (u,b);
|
||||
u = vec![43];
|
||||
b = Bar([&NoisyDrop(&u), &NoisyDrop(&u)]);
|
||||
}
|
||||
|
||||
struct Bar2<T: fmt::Debug>(*const NoisyDrop<T>, *const NoisyDrop<T>);
|
||||
|
||||
fn lolwut() {
|
||||
let (u,v);
|
||||
u = vec![43];
|
||||
v = Bar2(&NoisyDrop(&u), &NoisyDrop(&u));
|
||||
}
|
||||
|
||||
fn main() { fine(); lolwut() }
|
||||
Loading…
Add table
Add a link
Reference in a new issue