| 1 | |
| 2 |
|
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 |
|
| 253 | |
| 254 | #![doc(html_root_url = "https://docs.rs/syn/2.0.106")]
|
| 255 | #![cfg_attr(docsrs, feature(doc_cfg))]
|
| 256 | #![deny(unsafe_op_in_unsafe_fn)]
|
| 257 | #![allow(non_camel_case_types)]
|
| 258 | #![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
| 259 | #![allow(
|
| 260 | clippy::bool_to_int_with_if,
|
| 261 | clippy::cast_lossless,
|
| 262 | clippy::cast_possible_truncation,
|
| 263 | clippy::cast_possible_wrap,
|
| 264 | clippy::cast_ptr_alignment,
|
| 265 | clippy::default_trait_access,
|
| 266 | clippy::derivable_impls,
|
| 267 | clippy::diverging_sub_expression,
|
| 268 | clippy::doc_markdown,
|
| 269 | clippy::elidable_lifetime_names,
|
| 270 | clippy::enum_glob_use,
|
| 271 | clippy::expl_impl_clone_on_copy,
|
| 272 | clippy::explicit_auto_deref,
|
| 273 | clippy::fn_params_excessive_bools,
|
| 274 | clippy::if_not_else,
|
| 275 | clippy::inherent_to_string,
|
| 276 | clippy::into_iter_without_iter,
|
| 277 | clippy::items_after_statements,
|
| 278 | clippy::large_enum_variant,
|
| 279 | clippy::let_underscore_untyped, // https://github.com/rust-lang/rust-clippy/issues/10410
|
| 280 | clippy::manual_assert,
|
| 281 | clippy::manual_let_else,
|
| 282 | clippy::manual_map,
|
| 283 | clippy::match_like_matches_macro,
|
| 284 | clippy::match_same_arms,
|
| 285 | clippy::match_wildcard_for_single_variants, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
|
| 286 | clippy::missing_errors_doc,
|
| 287 | clippy::missing_panics_doc,
|
| 288 | clippy::module_name_repetitions,
|
| 289 | clippy::must_use_candidate,
|
| 290 | clippy::needless_doctest_main,
|
| 291 | clippy::needless_lifetimes,
|
| 292 | clippy::needless_pass_by_value,
|
| 293 | clippy::needless_update,
|
| 294 | clippy::never_loop,
|
| 295 | clippy::range_plus_one,
|
| 296 | clippy::redundant_else,
|
| 297 | clippy::ref_option,
|
| 298 | clippy::return_self_not_must_use,
|
| 299 | clippy::similar_names,
|
| 300 | clippy::single_match_else,
|
| 301 | clippy::struct_excessive_bools,
|
| 302 | clippy::too_many_arguments,
|
| 303 | clippy::too_many_lines,
|
| 304 | clippy::trivially_copy_pass_by_ref,
|
| 305 | clippy::unconditional_recursion, // https://github.com/rust-lang/rust-clippy/issues/12133
|
| 306 | clippy::uninhabited_references,
|
| 307 | clippy::uninlined_format_args,
|
| 308 | clippy::unnecessary_box_returns,
|
| 309 | clippy::unnecessary_unwrap,
|
| 310 | clippy::used_underscore_binding,
|
| 311 | clippy::wildcard_imports,
|
| 312 | )]
|
| 313 | #![allow(unknown_lints, mismatched_lifetime_syntaxes)]
|
| 314 |
|
| 315 | extern crate self as syn;
|
| 316 |
|
| 317 | #[cfg(feature = "proc-macro")]
|
| 318 | extern crate proc_macro;
|
| 319 |
|
| 320 | #[macro_use]
|
| 321 | mod macros;
|
| 322 |
|
| 323 | #[cfg(feature = "parsing")]
|
| 324 | #[macro_use]
|
| 325 | mod group;
|
| 326 |
|
| 327 | #[macro_use]
|
| 328 | pub mod token;
|
| 329 |
|
| 330 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 331 | mod attr;
|
| 332 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 333 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 334 | pub use crate::attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue};
|
| 335 |
|
| 336 | mod bigint;
|
| 337 |
|
| 338 | #[cfg(feature = "parsing")]
|
| 339 | #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
|
| 340 | pub mod buffer;
|
| 341 |
|
| 342 | #[cfg(any(
|
| 343 | all(feature = "parsing", feature = "full"),
|
| 344 | all(feature = "printing", any(feature = "full", feature = "derive")),
|
| 345 | ))]
|
| 346 | mod classify;
|
| 347 |
|
| 348 | mod custom_keyword;
|
| 349 |
|
| 350 | mod custom_punctuation;
|
| 351 |
|
| 352 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 353 | mod data;
|
| 354 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 355 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 356 | pub use crate::data::{Field, Fields, FieldsNamed, FieldsUnnamed, Variant};
|
| 357 |
|
| 358 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 359 | mod derive;
|
| 360 | #[cfg(feature = "derive")]
|
| 361 | #[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
|
| 362 | pub use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput};
|
| 363 |
|
| 364 | mod drops;
|
| 365 |
|
| 366 | mod error;
|
| 367 | pub use crate::error::{Error, Result};
|
| 368 |
|
| 369 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 370 | mod expr;
|
| 371 | #[cfg(feature = "full")]
|
| 372 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 373 | pub use crate::expr::{Arm, Label, PointerMutability, RangeLimits};
|
| 374 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 375 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 376 | pub use crate::expr::{
|
| 377 | Expr, ExprBinary, ExprCall, ExprCast, ExprField, ExprIndex, ExprLit, ExprMacro, ExprMethodCall,
|
| 378 | ExprParen, ExprPath, ExprReference, ExprStruct, ExprUnary, FieldValue, Index, Member,
|
| 379 | };
|
| 380 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 381 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 382 | pub use crate::expr::{
|
| 383 | ExprArray, ExprAssign, ExprAsync, ExprAwait, ExprBlock, ExprBreak, ExprClosure, ExprConst,
|
| 384 | ExprContinue, ExprForLoop, ExprGroup, ExprIf, ExprInfer, ExprLet, ExprLoop, ExprMatch,
|
| 385 | ExprRange, ExprRawAddr, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprTuple, ExprUnsafe,
|
| 386 | ExprWhile, ExprYield,
|
| 387 | };
|
| 388 |
|
| 389 | #[cfg(feature = "parsing")]
|
| 390 | #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
|
| 391 | pub mod ext;
|
| 392 |
|
| 393 | #[cfg(feature = "full")]
|
| 394 | mod file;
|
| 395 | #[cfg(feature = "full")]
|
| 396 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 397 | pub use crate::file::File;
|
| 398 |
|
| 399 | #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
|
| 400 | mod fixup;
|
| 401 |
|
| 402 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 403 | mod generics;
|
| 404 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 405 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 406 | pub use crate::generics::{
|
| 407 | BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeParam, PredicateLifetime,
|
| 408 | PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound, WhereClause,
|
| 409 | WherePredicate,
|
| 410 | };
|
| 411 | #[cfg(feature = "full")]
|
| 412 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 413 | pub use crate::generics::{CapturedParam, PreciseCapture};
|
| 414 | #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
|
| 415 | #[cfg_attr(
|
| 416 | docsrs,
|
| 417 | doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
|
| 418 | )]
|
| 419 | pub use crate::generics::{ImplGenerics, Turbofish, TypeGenerics};
|
| 420 |
|
| 421 | mod ident;
|
| 422 | #[doc(inline)]
|
| 423 | pub use crate::ident::Ident;
|
| 424 |
|
| 425 | #[cfg(feature = "full")]
|
| 426 | mod item;
|
| 427 | #[cfg(feature = "full")]
|
| 428 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 429 | pub use crate::item::{
|
| 430 | FnArg, ForeignItem, ForeignItemFn, ForeignItemMacro, ForeignItemStatic, ForeignItemType,
|
| 431 | ImplItem, ImplItemConst, ImplItemFn, ImplItemMacro, ImplItemType, ImplRestriction, Item,
|
| 432 | ItemConst, ItemEnum, ItemExternCrate, ItemFn, ItemForeignMod, ItemImpl, ItemMacro, ItemMod,
|
| 433 | ItemStatic, ItemStruct, ItemTrait, ItemTraitAlias, ItemType, ItemUnion, ItemUse, Receiver,
|
| 434 | Signature, StaticMutability, TraitItem, TraitItemConst, TraitItemFn, TraitItemMacro,
|
| 435 | TraitItemType, UseGlob, UseGroup, UseName, UsePath, UseRename, UseTree, Variadic,
|
| 436 | };
|
| 437 |
|
| 438 | mod lifetime;
|
| 439 | #[doc(inline)]
|
| 440 | pub use crate::lifetime::Lifetime;
|
| 441 |
|
| 442 | mod lit;
|
| 443 | #[doc(hidden)] |
| 444 | pub use crate::lit::StrStyle;
|
| 445 | #[doc(inline)]
|
| 446 | pub use crate::lit::{
|
| 447 | Lit, LitBool, LitByte, LitByteStr, LitCStr, LitChar, LitFloat, LitInt, LitStr,
|
| 448 | };
|
| 449 |
|
| 450 | #[cfg(feature = "parsing")]
|
| 451 | mod lookahead;
|
| 452 |
|
| 453 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 454 | mod mac;
|
| 455 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 456 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 457 | pub use crate::mac::{Macro, MacroDelimiter};
|
| 458 |
|
| 459 | #[cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))]
|
| 460 | #[cfg_attr(
|
| 461 | docsrs,
|
| 462 | doc(cfg(all(feature = "parsing", any(feature = "full", feature = "derive"))))
|
| 463 | )]
|
| 464 | pub mod meta;
|
| 465 |
|
| 466 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 467 | mod op;
|
| 468 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 469 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 470 | pub use crate::op::{BinOp, UnOp};
|
| 471 |
|
| 472 | #[cfg(feature = "parsing")]
|
| 473 | #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
|
| 474 | pub mod parse;
|
| 475 |
|
| 476 | #[cfg(all(feature = "parsing", feature = "proc-macro"))]
|
| 477 | mod parse_macro_input;
|
| 478 |
|
| 479 | #[cfg(all(feature = "parsing", feature = "printing"))]
|
| 480 | mod parse_quote;
|
| 481 |
|
| 482 | #[cfg(feature = "full")]
|
| 483 | mod pat;
|
| 484 | #[cfg(feature = "full")]
|
| 485 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 486 | pub use crate::pat::{
|
| 487 | FieldPat, Pat, PatConst, PatIdent, PatLit, PatMacro, PatOr, PatParen, PatPath, PatRange,
|
| 488 | PatReference, PatRest, PatSlice, PatStruct, PatTuple, PatTupleStruct, PatType, PatWild,
|
| 489 | };
|
| 490 |
|
| 491 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 492 | mod path;
|
| 493 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 494 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 495 | pub use crate::path::{
|
| 496 | AngleBracketedGenericArguments, AssocConst, AssocType, Constraint, GenericArgument,
|
| 497 | ParenthesizedGenericArguments, Path, PathArguments, PathSegment, QSelf,
|
| 498 | };
|
| 499 |
|
| 500 | #[cfg(all(
|
| 501 | any(feature = "full", feature = "derive"),
|
| 502 | any(feature = "parsing", feature = "printing")
|
| 503 | ))]
|
| 504 | mod precedence;
|
| 505 |
|
| 506 | #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
|
| 507 | mod print;
|
| 508 |
|
| 509 | pub mod punctuated;
|
| 510 |
|
| 511 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 512 | mod restriction;
|
| 513 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 514 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 515 | pub use crate::restriction::{FieldMutability, VisRestricted, Visibility};
|
| 516 |
|
| 517 | mod sealed;
|
| 518 |
|
| 519 | #[cfg(all(feature = "parsing", feature = "derive", not(feature = "full")))]
|
| 520 | mod scan_expr;
|
| 521 |
|
| 522 | mod span;
|
| 523 |
|
| 524 | #[cfg(all(feature = "parsing", feature = "printing"))]
|
| 525 | #[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "printing"))))]
|
| 526 | pub mod spanned;
|
| 527 |
|
| 528 | #[cfg(feature = "full")]
|
| 529 | mod stmt;
|
| 530 | #[cfg(feature = "full")]
|
| 531 | #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
|
| 532 | pub use crate::stmt::{Block, Local, LocalInit, Stmt, StmtMacro};
|
| 533 |
|
| 534 | mod thread;
|
| 535 |
|
| 536 | #[cfg(all(any(feature = "full", feature = "derive"), feature = "extra-traits"))]
|
| 537 | mod tt;
|
| 538 |
|
| 539 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 540 | mod ty;
|
| 541 | #[cfg(any(feature = "full", feature = "derive"))]
|
| 542 | #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))]
|
| 543 | pub use crate::ty::{
|
| 544 | Abi, BareFnArg, BareVariadic, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup,
|
| 545 | TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference,
|
| 546 | TypeSlice, TypeTraitObject, TypeTuple,
|
| 547 | };
|
| 548 |
|
| 549 | #[cfg(all(any(feature = "full", feature = "derive"), feature = "parsing"))]
|
| 550 | mod verbatim;
|
| 551 |
|
| 552 | #[cfg(all(feature = "parsing", feature = "full"))]
|
| 553 | mod whitespace;
|
| 554 |
|
| 555 | #[rustfmt::skip] |
| 556 | mod gen {
|
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | #[cfg(feature = "fold")]
|
| 638 | #[cfg_attr(docsrs, doc(cfg(feature = "fold")))]
|
| 639 | #[rustfmt::skip]
|
| 640 | pub mod fold;
|
| 641 |
|
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | #[cfg(feature = "visit")]
|
| 757 | #[cfg_attr(docsrs, doc(cfg(feature = "visit")))]
|
| 758 | #[rustfmt::skip]
|
| 759 | pub mod visit;
|
| 760 |
|
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | #[cfg(feature = "visit-mut")]
|
| 851 | #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
|
| 852 | #[rustfmt::skip]
|
| 853 | pub mod visit_mut;
|
| 854 |
|
| 855 | #[cfg(feature = "clone-impls")]
|
| 856 | #[rustfmt::skip]
|
| 857 | mod clone;
|
| 858 |
|
| 859 | #[cfg(feature = "extra-traits")]
|
| 860 | #[rustfmt::skip]
|
| 861 | mod debug;
|
| 862 |
|
| 863 | #[cfg(feature = "extra-traits")]
|
| 864 | #[rustfmt::skip]
|
| 865 | mod eq;
|
| 866 |
|
| 867 | #[cfg(feature = "extra-traits")]
|
| 868 | #[rustfmt::skip]
|
| 869 | mod hash;
|
| 870 | }
|
| 871 |
|
| 872 | #[cfg(feature = "fold")]
|
| 873 | #[cfg_attr(docsrs, doc(cfg(feature = "fold")))]
|
| 874 | pub use crate::gen::fold;
|
| 875 |
|
| 876 | #[cfg(feature = "visit")]
|
| 877 | #[cfg_attr(docsrs, doc(cfg(feature = "visit")))]
|
| 878 | pub use crate::gen::visit;
|
| 879 |
|
| 880 | #[cfg(feature = "visit-mut")]
|
| 881 | #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
|
| 882 | pub use crate::gen::visit_mut;
|
| 883 |
|
| 884 | |
| 885 | #[doc(hidden)]
|
| 886 | #[path = "export.rs"]
|
| 887 | pub mod __private;
|
| 888 |
|
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | #[cfg(all(feature = "parsing", feature = "proc-macro"))]
|
| 905 | #[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "proc-macro"))))]
|
| 906 | pub fn parse<T: parse::Parse>(tokens: proc_macro::TokenStream) -> Result<T> {
|
| 907 | parse::Parser::parse(T::parse, tokens)
|
| 908 | }
|
| 909 |
|
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | |
| 918 | |
| 919 | |
| 920 | |
| 921 | |
| 922 | #[cfg(feature = "parsing")]
|
| 923 | #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
|
| 924 | pub fn parse2<T: parse::Parse>(tokens: proc_macro2::TokenStream) -> Result<T> {
|
| 925 | parse::Parser::parse2(T::parse, tokens)
|
| 926 | }
|
| 927 |
|
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| 936 | |
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | #[cfg(feature = "parsing")]
|
| 953 | #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
|
| 954 | pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> {
|
| 955 | parse::Parser::parse_str(T::parse, s)
|
| 956 | }
|
| 957 |
|
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | #[cfg(all(feature = "parsing", feature = "full"))]
|
| 988 | #[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "full"))))]
|
| 989 | pub fn parse_file(mut content: &str) -> Result<File> {
|
| 990 | |
| 991 | const BOM: &str = "\u{feff}";
|
| 992 | if content.starts_with(BOM) {
|
| 993 | content = &content[BOM.len()..];
|
| 994 | }
|
| 995 |
|
| 996 | let mut shebang = None;
|
| 997 | if content.starts_with("#!") {
|
| 998 | let rest = whitespace::skip(&content[2..]);
|
| 999 | if !rest.starts_with('[') {
|
| 1000 | if let Some(idx) = content.find('\n') {
|
| 1001 | shebang = Some(content[..idx].to_string());
|
| 1002 | content = &content[idx..];
|
| 1003 | } else {
|
| 1004 | shebang = Some(content.to_string());
|
| 1005 | content = "";
|
| 1006 | }
|
| 1007 | }
|
| 1008 | }
|
| 1009 |
|
| 1010 | let mut file: File = parse_str(content)?;
|
| 1011 | file.shebang = shebang;
|
| 1012 | Ok(file)
|
| 1013 | }
|