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