]> git.lizzy.rs Git - rust.git/blob - src/librustc_ast/lib.rs
Rollup merge of #75485 - RalfJung:pin, r=nagisa
[rust.git] / src / librustc_ast / 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(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
8 #![feature(bool_to_option)]
9 #![feature(box_syntax)]
10 #![feature(const_fn)] // For the `transmute` in `P::new`
11 #![feature(const_panic)]
12 #![feature(const_fn_transmute)]
13 #![feature(crate_visibility_modifier)]
14 #![feature(label_break_value)]
15 #![feature(nll)]
16 #![feature(or_patterns)]
17 #![feature(try_trait)]
18 #![feature(unicode_internals)]
19 #![recursion_limit = "256"]
20
21 #[macro_use]
22 extern crate rustc_macros;
23
24 #[macro_export]
25 macro_rules! unwrap_or {
26     ($opt:expr, $default:expr) => {
27         match $opt {
28             Some(x) => x,
29             None => $default,
30         }
31     };
32 }
33
34 pub mod util {
35     pub mod classify;
36     pub mod comments;
37     pub mod lev_distance;
38     pub mod literal;
39     pub mod parser;
40 }
41
42 pub mod ast;
43 pub mod attr;
44 pub mod crate_disambiguator;
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 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
55
56 /// Requirements for a `StableHashingContext` to be used in this crate.
57 /// This is a hack to allow using the `HashStable_Generic` derive macro
58 /// instead of implementing everything in librustc_middle.
59 pub trait HashStableContext: rustc_span::HashStableContext {
60     fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
61 }
62
63 impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
64     fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
65         hcx.hash_attr(self, hasher)
66     }
67 }