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