aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / syn-2.0.119 / tests / test_receiver.rs
| 1 | #![allow( |
| 2 | clippy::elidable_lifetime_names, |
| 3 | clippy::needless_lifetimes, |
| 4 | clippy::uninlined_format_args |
| 5 | )] |
| 6 | |
| 7 | #[macro_use] |
| 8 | mod snapshot; |
| 9 | |
| 10 | mod debug; |
| 11 | |
| 12 | use syn::{parse_quote, TraitItemFn}; |
| 13 | |
| 14 | #[test] |
| 15 | fn test_by_value() { |
| 16 | let TraitItemFn { sig, .. } = parse_quote! { |
| 17 | fn by_value(self: Self); |
| 18 | }; |
| 19 | snapshot!(&sig.inputs[0], @r#" |
| 20 | FnArg::Receiver(Receiver { |
| 21 | colon_token: Some, |
| 22 | ty: Type::Path { |
| 23 | path: Path { |
| 24 | segments: [ |
| 25 | PathSegment { |
| 26 | ident: "Self", |
| 27 | }, |
| 28 | ], |
| 29 | }, |
| 30 | }, |
| 31 | }) |
| 32 | "#); |
| 33 | } |
| 34 | |
| 35 | #[test] |
| 36 | fn test_by_mut_value() { |
| 37 | let TraitItemFn { sig, .. } = parse_quote! { |
| 38 | fn by_mut(mut self: Self); |
| 39 | }; |
| 40 | snapshot!(&sig.inputs[0], @r#" |
| 41 | FnArg::Receiver(Receiver { |
| 42 | mutability: Some, |
| 43 | colon_token: Some, |
| 44 | ty: Type::Path { |
| 45 | path: Path { |
| 46 | segments: [ |
| 47 | PathSegment { |
| 48 | ident: "Self", |
| 49 | }, |
| 50 | ], |
| 51 | }, |
| 52 | }, |
| 53 | }) |
| 54 | "#); |
| 55 | } |
| 56 | |
| 57 | #[test] |
| 58 | fn test_by_ref() { |
| 59 | let TraitItemFn { sig, .. } = parse_quote! { |
| 60 | fn by_ref(self: &Self); |
| 61 | }; |
| 62 | snapshot!(&sig.inputs[0], @r#" |
| 63 | FnArg::Receiver(Receiver { |
| 64 | colon_token: Some, |
| 65 | ty: Type::Reference { |
| 66 | elem: Type::Path { |
| 67 | path: Path { |
| 68 | segments: [ |
| 69 | PathSegment { |
| 70 | ident: "Self", |
| 71 | }, |
| 72 | ], |
| 73 | }, |
| 74 | }, |
| 75 | }, |
| 76 | }) |
| 77 | "#); |
| 78 | } |
| 79 | |
| 80 | #[test] |
| 81 | fn test_by_box() { |
| 82 | let TraitItemFn { sig, .. } = parse_quote! { |
| 83 | fn by_box(self: Box<Self>); |
| 84 | }; |
| 85 | snapshot!(&sig.inputs[0], @r#" |
| 86 | FnArg::Receiver(Receiver { |
| 87 | colon_token: Some, |
| 88 | ty: Type::Path { |
| 89 | path: Path { |
| 90 | segments: [ |
| 91 | PathSegment { |
| 92 | ident: "Box", |
| 93 | arguments: PathArguments::AngleBracketed { |
| 94 | args: [ |
| 95 | GenericArgument::Type(Type::Path { |
| 96 | path: Path { |
| 97 | segments: [ |
| 98 | PathSegment { |
| 99 | ident: "Self", |
| 100 | }, |
| 101 | ], |
| 102 | }, |
| 103 | }), |
| 104 | ], |
| 105 | }, |
| 106 | }, |
| 107 | ], |
| 108 | }, |
| 109 | }, |
| 110 | }) |
| 111 | "#); |
| 112 | } |
| 113 | |
| 114 | #[test] |
| 115 | fn test_by_pin() { |
| 116 | let TraitItemFn { sig, .. } = parse_quote! { |
| 117 | fn by_pin(self: Pin<Self>); |
| 118 | }; |
| 119 | snapshot!(&sig.inputs[0], @r#" |
| 120 | FnArg::Receiver(Receiver { |
| 121 | colon_token: Some, |
| 122 | ty: Type::Path { |
| 123 | path: Path { |
| 124 | segments: [ |
| 125 | PathSegment { |
| 126 | ident: "Pin", |
| 127 | arguments: PathArguments::AngleBracketed { |
| 128 | args: [ |
| 129 | GenericArgument::Type(Type::Path { |
| 130 | path: Path { |
| 131 | segments: [ |
| 132 | PathSegment { |
| 133 | ident: "Self", |
| 134 | }, |
| 135 | ], |
| 136 | }, |
| 137 | }), |
| 138 | ], |
| 139 | }, |
| 140 | }, |
| 141 | ], |
| 142 | }, |
| 143 | }, |
| 144 | }) |
| 145 | "#); |
| 146 | } |
| 147 | |
| 148 | #[test] |
| 149 | fn test_explicit_type() { |
| 150 | let TraitItemFn { sig, .. } = parse_quote! { |
| 151 | fn explicit_type(self: Pin<MyType>); |
| 152 | }; |
| 153 | snapshot!(&sig.inputs[0], @r#" |
| 154 | FnArg::Receiver(Receiver { |
| 155 | colon_token: Some, |
| 156 | ty: Type::Path { |
| 157 | path: Path { |
| 158 | segments: [ |
| 159 | PathSegment { |
| 160 | ident: "Pin", |
| 161 | arguments: PathArguments::AngleBracketed { |
| 162 | args: [ |
| 163 | GenericArgument::Type(Type::Path { |
| 164 | path: Path { |
| 165 | segments: [ |
| 166 | PathSegment { |
| 167 | ident: "MyType", |
| 168 | }, |
| 169 | ], |
| 170 | }, |
| 171 | }), |
| 172 | ], |
| 173 | }, |
| 174 | }, |
| 175 | ], |
| 176 | }, |
| 177 | }, |
| 178 | }) |
| 179 | "#); |
| 180 | } |
| 181 | |
| 182 | #[test] |
| 183 | fn test_value_shorthand() { |
| 184 | let TraitItemFn { sig, .. } = parse_quote! { |
| 185 | fn value_shorthand(self); |
| 186 | }; |
| 187 | snapshot!(&sig.inputs[0], @r#" |
| 188 | FnArg::Receiver(Receiver { |
| 189 | ty: Type::Path { |
| 190 | path: Path { |
| 191 | segments: [ |
| 192 | PathSegment { |
| 193 | ident: "Self", |
| 194 | }, |
| 195 | ], |
| 196 | }, |
| 197 | }, |
| 198 | }) |
| 199 | "#); |
| 200 | } |
| 201 | |
| 202 | #[test] |
| 203 | fn test_mut_value_shorthand() { |
| 204 | let TraitItemFn { sig, .. } = parse_quote! { |
| 205 | fn mut_value_shorthand(mut self); |
| 206 | }; |
| 207 | snapshot!(&sig.inputs[0], @r#" |
| 208 | FnArg::Receiver(Receiver { |
| 209 | mutability: Some, |
| 210 | ty: Type::Path { |
| 211 | path: Path { |
| 212 | segments: [ |
| 213 | PathSegment { |
| 214 | ident: "Self", |
| 215 | }, |
| 216 | ], |
| 217 | }, |
| 218 | }, |
| 219 | }) |
| 220 | "#); |
| 221 | } |
| 222 | |
| 223 | #[test] |
| 224 | fn test_ref_shorthand() { |
| 225 | let TraitItemFn { sig, .. } = parse_quote! { |
| 226 | fn ref_shorthand(&self); |
| 227 | }; |
| 228 | snapshot!(&sig.inputs[0], @r#" |
| 229 | FnArg::Receiver(Receiver { |
| 230 | reference: Some(None), |
| 231 | ty: Type::Reference { |
| 232 | elem: Type::Path { |
| 233 | path: Path { |
| 234 | segments: [ |
| 235 | PathSegment { |
| 236 | ident: "Self", |
| 237 | }, |
| 238 | ], |
| 239 | }, |
| 240 | }, |
| 241 | }, |
| 242 | }) |
| 243 | "#); |
| 244 | } |
| 245 | |
| 246 | #[test] |
| 247 | fn test_ref_shorthand_with_lifetime() { |
| 248 | let TraitItemFn { sig, .. } = parse_quote! { |
| 249 | fn ref_shorthand(&'a self); |
| 250 | }; |
| 251 | snapshot!(&sig.inputs[0], @r#" |
| 252 | FnArg::Receiver(Receiver { |
| 253 | reference: Some(Some(Lifetime { |
| 254 | ident: "a", |
| 255 | })), |
| 256 | ty: Type::Reference { |
| 257 | lifetime: Some(Lifetime { |
| 258 | ident: "a", |
| 259 | }), |
| 260 | elem: Type::Path { |
| 261 | path: Path { |
| 262 | segments: [ |
| 263 | PathSegment { |
| 264 | ident: "Self", |
| 265 | }, |
| 266 | ], |
| 267 | }, |
| 268 | }, |
| 269 | }, |
| 270 | }) |
| 271 | "#); |
| 272 | } |
| 273 | |
| 274 | #[test] |
| 275 | fn test_ref_mut_shorthand() { |
| 276 | let TraitItemFn { sig, .. } = parse_quote! { |
| 277 | fn ref_mut_shorthand(&mut self); |
| 278 | }; |
| 279 | snapshot!(&sig.inputs[0], @r#" |
| 280 | FnArg::Receiver(Receiver { |
| 281 | reference: Some(None), |
| 282 | mutability: Some, |
| 283 | ty: Type::Reference { |
| 284 | mutability: Some, |
| 285 | elem: Type::Path { |
| 286 | path: Path { |
| 287 | segments: [ |
| 288 | PathSegment { |
| 289 | ident: "Self", |
| 290 | }, |
| 291 | ], |
| 292 | }, |
| 293 | }, |
| 294 | }, |
| 295 | }) |
| 296 | "#); |
| 297 | } |
| 298 | |
| 299 | #[test] |
| 300 | fn test_ref_mut_shorthand_with_lifetime() { |
| 301 | let TraitItemFn { sig, .. } = parse_quote! { |
| 302 | fn ref_mut_shorthand(&'a mut self); |
| 303 | }; |
| 304 | snapshot!(&sig.inputs[0], @r#" |
| 305 | FnArg::Receiver(Receiver { |
| 306 | reference: Some(Some(Lifetime { |
| 307 | ident: "a", |
| 308 | })), |
| 309 | mutability: Some, |
| 310 | ty: Type::Reference { |
| 311 | lifetime: Some(Lifetime { |
| 312 | ident: "a", |
| 313 | }), |
| 314 | mutability: Some, |
| 315 | elem: Type::Path { |
| 316 | path: Path { |
| 317 | segments: [ |
| 318 | PathSegment { |
| 319 | ident: "Self", |
| 320 | }, |
| 321 | ], |
| 322 | }, |
| 323 | }, |
| 324 | }, |
| 325 | }) |
| 326 | "#); |
| 327 | } |