1 #![feature(dropck_eyepatch)]
3 // This test ensures that a use of `#[may_dangle]` is rejected if
4 // it is not attached to an `unsafe impl`.
8 struct Dt<A: fmt::Debug>(&'static str, A);
9 struct Dr<'a, B:'a+fmt::Debug>(&'static str, &'a B);
10 struct Pt<A,B: fmt::Debug>(&'static str, A, B);
11 struct Pr<'a, 'b, B:'a+'b+fmt::Debug>(&'static str, &'a B, &'b B);
12 struct St<A: fmt::Debug>(&'static str, A);
13 struct Sr<'a, B:'a+fmt::Debug>(&'static str, &'a B);
15 impl<A: fmt::Debug> Drop for Dt<A> {
16 fn drop(&mut self) { println!("drop {} {:?}", self.0, self.1); }
18 impl<'a, B: fmt::Debug> Drop for Dr<'a, B> {
19 fn drop(&mut self) { println!("drop {} {:?}", self.0, self.1); }
21 impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
22 //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
24 // (unsafe to access self.1 due to #[may_dangle] on A)
25 fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
27 impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
28 //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
30 // (unsafe to access self.1 due to #[may_dangle] on 'a)
31 fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }