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