2 // aux-build:dropck_eyepatch_extern_crate.rs
4 extern crate dropck_eyepatch_extern_crate as other;
6 use other::{Dt,Dr,Pt,Pr,St,Sr};
9 use std::cell::RefCell;
11 struct CheckOnDrop(RefCell<String>, &'static str);
12 impl Drop for CheckOnDrop {
13 fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); }
17 let (c, dt, dr, pt, pr, st, sr)
18 : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>);
19 c_long = CheckOnDrop(RefCell::new("c_long".to_string()),
20 "c_long|pr|pt|dr|dt");
21 c = CheckOnDrop(RefCell::new("c".to_string()),
24 // No error: sufficiently long-lived state can be referenced in dtors
25 dt = Dt("dt", &c_long.0);
26 dr = Dr("dr", &c_long.0);
28 // No error: Drop impl asserts .1 (A and &'a _) are not accessed
29 pt = Pt("pt", &c.0, &c_long.0);
30 pr = Pr("pr", &c.0, &c_long.0);
32 // No error: St and Sr have no destructor.
36 println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
37 assert_eq!(*c_long.0.borrow(), "c_long");
38 assert_eq!(*c.0.borrow(), "c");