]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | //! The Rust parser and macro expander. |
2 | //! | |
3 | //! # Note | |
4 | //! | |
5 | //! This API is completely unstable and subject to change. | |
6 | ||
1b1a35ee XL |
7 | #![doc( |
8 | html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/", | |
9 | test(attr(deny(warnings))) | |
10 | )] | |
416331ca | 11 | #![feature(box_syntax)] |
5869c6ff | 12 | #![feature(box_patterns)] |
3dfed10e | 13 | #![feature(const_fn_transmute)] |
8faf50e0 | 14 | #![feature(crate_visibility_modifier)] |
cdc7bbd5 | 15 | #![feature(iter_zip)] |
9fa01778 | 16 | #![feature(label_break_value)] |
0bf4aa26 | 17 | #![feature(nll)] |
17df50a5 | 18 | #![feature(min_specialization)] |
dfeec247 | 19 | #![recursion_limit = "256"] |
1a4d82fc | 20 | |
3dfed10e | 21 | #[macro_use] |
f9f354fc XL |
22 | extern crate rustc_macros; |
23 | ||
cc61c64b XL |
24 | #[macro_export] |
25 | macro_rules! unwrap_or { | |
26 | ($opt:expr, $default:expr) => { | |
27 | match $opt { | |
28 | Some(x) => x, | |
29 | None => $default, | |
30 | } | |
dfeec247 | 31 | }; |
cc61c64b XL |
32 | } |
33 | ||
970d7e83 | 34 | pub mod util { |
60c5eb7d XL |
35 | pub mod classify; |
36 | pub mod comments; | |
60c5eb7d | 37 | pub mod literal; |
92a42be0 | 38 | pub mod parser; |
970d7e83 | 39 | } |
223e47cc | 40 | |
223e47cc | 41 | pub mod ast; |
6a06907d | 42 | pub mod ast_like; |
1a4d82fc | 43 | pub mod attr; |
e9174d1e | 44 | pub mod entry; |
dfeec247 | 45 | pub mod expand; |
9fa01778 | 46 | pub mod mut_visit; |
74b04a01 | 47 | pub mod node_id; |
1a4d82fc | 48 | pub mod ptr; |
60c5eb7d | 49 | pub mod token; |
3157f602 | 50 | pub mod tokenstream; |
1a4d82fc | 51 | pub mod visit; |
223e47cc | 52 | |
3dfed10e | 53 | pub use self::ast::*; |
6a06907d | 54 | pub use self::ast_like::AstLike; |
3dfed10e | 55 | |
dfeec247 | 56 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
60c5eb7d XL |
57 | |
58 | /// Requirements for a `StableHashingContext` to be used in this crate. | |
59 | /// This is a hack to allow using the `HashStable_Generic` derive macro | |
cdc7bbd5 | 60 | /// instead of implementing everything in `rustc_middle`. |
dfeec247 XL |
61 | pub trait HashStableContext: rustc_span::HashStableContext { |
62 | fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher); | |
63 | } | |
64 | ||
65 | impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute { | |
66 | fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) { | |
67 | hcx.hash_attr(self, hasher) | |
68 | } | |
69 | } |