]> git.lizzy.rs Git - rust.git/blob - src/librustc_ast/lib.rs
Fix missed same-sized member clash in ClashingExternDeclarations.
[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 // FIXME(#56935): Work around ICEs during cross-compilation.
22 #[allow(unused)]
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 lev_distance;
39     pub mod literal;
40     pub mod parser;
41 }
42
43 pub mod ast;
44 pub mod attr;
45 pub use attr::{with_default_session_globals, with_session_globals, SESSION_GLOBALS};
46 pub mod crate_disambiguator;
47 pub mod entry;
48 pub mod expand;
49 pub mod mut_visit;
50 pub mod node_id;
51 pub mod ptr;
52 pub mod token;
53 pub mod tokenstream;
54 pub mod visit;
55
56 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
57
58 /// Requirements for a `StableHashingContext` to be used in this crate.
59 /// This is a hack to allow using the `HashStable_Generic` derive macro
60 /// instead of implementing everything in librustc_middle.
61 pub trait HashStableContext: rustc_span::HashStableContext {
62     fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
63 }
64
65 impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
66     fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
67         hcx.hash_attr(self, hasher)
68     }
69 }