| 1 |
mod argument { |
| 2 |
use std::pin::Pin; |
| 3 |
|
| 4 |
use pin_project::{pin_project, pinned_drop}; |
| 5 |
|
| 6 |
#[pin_project(PinnedDrop)] |
| 7 |
struct UnexpectedArg1(()); |
| 8 |
|
| 9 |
#[pinned_drop(foo)] //~ ERROR unexpected argument |
| 10 |
impl PinnedDrop for UnexpectedArg1 { |
| 11 |
fn drop(self: Pin<&mut Self>) {} |
| 12 |
} |
| 13 |
|
| 14 |
#[pin_project(PinnedDrop)] |
| 15 |
struct UnexpectedArg2(()); |
| 16 |
|
| 17 |
#[pinned_drop()] // Ok |
| 18 |
impl PinnedDrop for UnexpectedArg2 { |
| 19 |
fn drop(self: Pin<&mut Self>) {} |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
mod attribute { |
| 24 |
use pin_project::{pin_project, pinned_drop}; |
| 25 |
|
| 26 |
#[pin_project(PinnedDrop)] |
| 27 |
struct Duplicate(()); |
| 28 |
|
| 29 |
#[pinned_drop] |
| 30 |
#[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute |
| 31 |
impl PinnedDrop for Duplicate { |
| 32 |
fn drop(self: Pin<&mut Self>) {} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
mod item { |
| 37 |
use pin_project::{pin_project, pinned_drop}; |
| 38 |
|
| 39 |
#[pin_project(PinnedDrop)] |
| 40 |
struct TraitImpl(()); |
| 41 |
|
| 42 |
#[pinned_drop] |
| 43 |
impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait |
| 44 |
|
| 45 |
#[pin_project(PinnedDrop)] |
| 46 |
struct InherentImpl(()); |
| 47 |
|
| 48 |
#[pinned_drop] |
| 49 |
impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait |
| 50 |
|
| 51 |
#[pinned_drop] |
| 52 |
fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl` |
| 53 |
} |
| 54 |
|
| 55 |
mod unsafety { |
| 56 |
use pin_project::{pin_project, pinned_drop}; |
| 57 |
|
| 58 |
#[pin_project(PinnedDrop)] |
| 59 |
struct Impl(()); |
| 60 |
|
| 61 |
#[pinned_drop] |
| 62 |
unsafe impl PinnedDrop for Impl { |
| 63 |
//~^ ERROR implementing the trait `PinnedDrop` is not unsafe |
| 64 |
fn drop(self: Pin<&mut Self>) {} |
| 65 |
} |
| 66 |
|
| 67 |
#[pin_project(PinnedDrop)] |
| 68 |
struct Method(()); |
| 69 |
|
| 70 |
#[pinned_drop] |
| 71 |
impl PinnedDrop for Method { |
| 72 |
unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
mod assoc_item { |
| 77 |
use pin_project::{pin_project, pinned_drop}; |
| 78 |
|
| 79 |
#[pin_project(PinnedDrop)] |
| 80 |
struct Empty(()); |
| 81 |
|
| 82 |
#[pinned_drop] |
| 83 |
impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop` |
| 84 |
|
| 85 |
#[pin_project(PinnedDrop)] |
| 86 |
struct Const1(()); |
| 87 |
|
| 88 |
#[pinned_drop] |
| 89 |
impl PinnedDrop for Const1 { |
| 90 |
const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop` |
| 91 |
fn drop(self: Pin<&mut Self>) {} |
| 92 |
} |
| 93 |
|
| 94 |
#[pin_project(PinnedDrop)] |
| 95 |
struct Const2(()); |
| 96 |
|
| 97 |
#[pinned_drop] |
| 98 |
impl PinnedDrop for Const2 { |
| 99 |
fn drop(self: Pin<&mut Self>) {} |
| 100 |
const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop` |
| 101 |
} |
| 102 |
|
| 103 |
#[pin_project(PinnedDrop)] |
| 104 |
struct Type1(()); |
| 105 |
|
| 106 |
#[pinned_drop] |
| 107 |
impl PinnedDrop for Type1 { |
| 108 |
type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop` |
| 109 |
fn drop(self: Pin<&mut Self>) {} |
| 110 |
} |
| 111 |
|
| 112 |
#[pin_project(PinnedDrop)] |
| 113 |
struct Type2(()); |
| 114 |
|
| 115 |
#[pinned_drop] |
| 116 |
impl PinnedDrop for Type2 { |
| 117 |
fn drop(self: Pin<&mut Self>) {} |
| 118 |
type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop` |
| 119 |
} |
| 120 |
|
| 121 |
#[pin_project(PinnedDrop)] |
| 122 |
struct Duplicate(()); |
| 123 |
|
| 124 |
#[pinned_drop] |
| 125 |
impl PinnedDrop for Duplicate { |
| 126 |
fn drop(self: Pin<&mut Self>) {} |
| 127 |
fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop` |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
mod method { |
| 132 |
use std::pin::Pin; |
| 133 |
|
| 134 |
use pin_project::{pin_project, pinned_drop}; |
| 135 |
|
| 136 |
#[pin_project(PinnedDrop)] |
| 137 |
struct RetUnit(()); |
| 138 |
|
| 139 |
#[pinned_drop] |
| 140 |
impl PinnedDrop for RetUnit { |
| 141 |
fn drop(self: Pin<&mut Self>) -> () {} // Ok |
| 142 |
} |
| 143 |
|
| 144 |
#[pin_project(PinnedDrop)] |
| 145 |
struct RetTy(()); |
| 146 |
|
| 147 |
#[pinned_drop] |
| 148 |
impl PinnedDrop for RetTy { |
| 149 |
fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type |
| 150 |
} |
| 151 |
|
| 152 |
#[pin_project(PinnedDrop)] |
| 153 |
struct NoArg(()); |
| 154 |
|
| 155 |
#[pinned_drop] |
| 156 |
impl PinnedDrop for NoArg { |
| 157 |
fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` |
| 158 |
} |
| 159 |
|
| 160 |
#[pin_project(PinnedDrop)] |
| 161 |
struct MultiArg(()); |
| 162 |
|
| 163 |
#[pinned_drop] |
| 164 |
impl PinnedDrop for MultiArg { |
| 165 |
fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` |
| 166 |
} |
| 167 |
|
| 168 |
#[pin_project(PinnedDrop)] |
| 169 |
struct InvalidArg1(()); |
| 170 |
|
| 171 |
#[pinned_drop] |
| 172 |
impl PinnedDrop for InvalidArg1 { |
| 173 |
fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` |
| 174 |
} |
| 175 |
|
| 176 |
#[pin_project(PinnedDrop)] |
| 177 |
struct InvalidArg2(()); |
| 178 |
|
| 179 |
#[pinned_drop] |
| 180 |
impl PinnedDrop for InvalidArg2 { |
| 181 |
fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` |
| 182 |
} |
| 183 |
|
| 184 |
#[pin_project(PinnedDrop)] |
| 185 |
struct InvalidArg3(()); |
| 186 |
|
| 187 |
#[pinned_drop] |
| 188 |
impl PinnedDrop for InvalidArg3 { |
| 189 |
fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` |
| 190 |
} |
| 191 |
|
| 192 |
#[pin_project(PinnedDrop)] |
| 193 |
struct InvalidArg4(()); |
| 194 |
|
| 195 |
#[pinned_drop] |
| 196 |
impl PinnedDrop for InvalidArg4 { |
| 197 |
fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` |
| 198 |
} |
| 199 |
|
| 200 |
#[pin_project(PinnedDrop)] |
| 201 |
struct InvalidName(()); |
| 202 |
|
| 203 |
#[pinned_drop] |
| 204 |
impl PinnedDrop for InvalidName { |
| 205 |
fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
mod self_ty { |
| 210 |
use pin_project::pinned_drop; |
| 211 |
|
| 212 |
#[pinned_drop] |
| 213 |
impl PinnedDrop for () { |
| 214 |
//~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported |
| 215 |
fn drop(self: Pin<&mut Self>) {} |
| 216 |
} |
| 217 |
|
| 218 |
#[pinned_drop] |
| 219 |
impl PinnedDrop for &mut A { |
| 220 |
//~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported |
| 221 |
fn drop(self: Pin<&mut Self>) {} |
| 222 |
} |
| 223 |
|
| 224 |
#[pinned_drop] |
| 225 |
impl PinnedDrop for [A] { |
| 226 |
//~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported |
| 227 |
fn drop(self: Pin<&mut Self>) {} |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
fn main() {} |