]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_ast/src/lib.rs
Auto merge of #89495 - Mark-Simulacrum:add-inlines, r=michaelwoerister
[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_patterns)]
12 #![feature(crate_visibility_modifier)]
13 #![feature(if_let_guard)]
14 #![feature(iter_zip)]
15 #![feature(label_break_value)]
16 #![feature(nll)]
17 #![feature(min_specialization)]
18 #![recursion_limit = "256"]
19
20 #[macro_use]
21 extern crate rustc_macros;
22
23 #[macro_export]
24 macro_rules! unwrap_or {
25     ($opt:expr, $default:expr) => {
26         match $opt {
27             Some(x) => x,
28             None => $default,
29         }
30     };
31 }
32
33 pub mod util {
34     pub mod classify;
35     pub mod comments;
36     pub mod literal;
37     pub mod parser;
38 }
39
40 pub mod ast;
41 pub mod ast_like;
42 pub mod attr;
43 pub mod entry;
44 pub mod expand;
45 pub mod mut_visit;
46 pub mod node_id;
47 pub mod ptr;
48 pub mod token;
49 pub mod tokenstream;
50 pub mod visit;
51
52 pub use self::ast::*;
53 pub use self::ast_like::AstLike;
54
55 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
56
57 /// Requirements for a `StableHashingContext` to be used in this crate.
58 /// This is a hack to allow using the `HashStable_Generic` derive macro
59 /// instead of implementing everything in `rustc_middle`.
60 pub trait HashStableContext: rustc_span::HashStableContext {
61     fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
62 }
63
64 impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
65     fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
66         hcx.hash_attr(self, hasher)
67     }
68 }