]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_ast/src/lib.rs
Rollup merge of #84132 - Manishearth:lldb-nonstandard, r=Mark-Simulacrum
[rust.git] / compiler / rustc_ast / src / lib.rs
1 //! The Rust parser and macro expander.
2 //!
3 //! # Note
4 //!
5 //! This API is completely unstable and subject to change.
6
7 #![doc(
8     html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
9     test(attr(deny(warnings)))
10 )]
11 #![feature(box_syntax)]
12 #![feature(box_patterns)]
13 #![cfg_attr(bootstrap, feature(const_fn))] // For the `transmute` in `P::new`
14 #![cfg_attr(not(bootstrap), feature(const_fn_unsize))] // For the `transmute` in `P::new`
15 #![feature(const_fn_transmute)]
16 #![feature(const_panic)]
17 #![feature(crate_visibility_modifier)]
18 #![feature(iter_zip)]
19 #![feature(label_break_value)]
20 #![feature(nll)]
21 #![cfg_attr(bootstrap, feature(or_patterns))]
22 #![recursion_limit = "256"]
23
24 #[macro_use]
25 extern crate rustc_macros;
26
27 #[macro_export]
28 macro_rules! unwrap_or {
29     ($opt:expr, $default:expr) => {
30         match $opt {
31             Some(x) => x,
32             None => $default,
33         }
34     };
35 }
36
37 pub mod util {
38     pub mod classify;
39     pub mod comments;
40     pub mod literal;
41     pub mod parser;
42 }
43
44 pub mod ast;
45 pub mod ast_like;
46 pub mod attr;
47 pub mod entry;
48 pub mod expand;
49 pub mod mut_visit;
50 pub mod node_id;
51 pub mod ptr;
52 pub mod token;
53 pub mod tokenstream;
54 pub mod visit;
55
56 pub use self::ast::*;
57 pub use self::ast_like::AstLike;
58
59 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
60
61 /// Requirements for a `StableHashingContext` to be used in this crate.
62 /// This is a hack to allow using the `HashStable_Generic` derive macro
63 /// instead of implementing everything in `rustc_middle`.
64 pub trait HashStableContext: rustc_span::HashStableContext {
65     fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
66 }
67
68 impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
69     fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
70         hcx.hash_attr(self, hasher)
71     }
72 }