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