]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_ast/src/lib.rs
Add unit test to ensure that both parts of a DefPathHash depend on the defining crate...
[rust.git] / compiler / rustc_ast / src / 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(
8     html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
9     test(attr(deny(warnings)))
10 )]
11 #![feature(box_syntax)]
12 #![feature(const_fn)] // For the `transmute` in `P::new`
13 #![feature(const_fn_transmute)]
14 #![feature(const_panic)]
15 #![feature(crate_visibility_modifier)]
16 #![feature(iterator_fold_self)]
17 #![feature(label_break_value)]
18 #![feature(nll)]
19 #![feature(or_patterns)]
20 #![recursion_limit = "256"]
21
22 #[macro_use]
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 literal;
39     pub mod parser;
40 }
41
42 pub mod ast;
43 pub mod attr;
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 pub use self::ast::*;
54
55 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
56
57 /// Requirements for a `StableHashingContext` to be used in this crate.
58 /// This is a hack to allow using the `HashStable_Generic` derive macro
59 /// instead of implementing everything in librustc_middle.
60 pub trait HashStableContext: rustc_span::HashStableContext {
61     fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
62 }
63
64 impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
65     fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
66         hcx.hash_attr(self, hasher)
67     }
68 }