]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_ast/src/lib.rs
Rollup merge of #100559 - nnethercote:parser-simplifications, r=compiler-errors
[rust.git] / compiler / rustc_ast / src / lib.rs
1 //! The Rust Abstract Syntax Tree (AST).
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(associated_type_bounds)]
12 #![feature(box_patterns)]
13 #![feature(const_default_impls)]
14 #![feature(const_trait_impl)]
15 #![feature(if_let_guard)]
16 #![feature(label_break_value)]
17 #![feature(min_specialization)]
18 #![feature(negative_impls)]
19 #![feature(slice_internals)]
20 #![feature(stmt_expr_attributes)]
21 #![recursion_limit = "256"]
22
23 #[macro_use]
24 extern crate rustc_macros;
25
26 pub mod util {
27     pub mod classify;
28     pub mod comments;
29     pub mod literal;
30     pub mod parser;
31     pub mod unicode;
32 }
33
34 pub mod ast;
35 pub mod ast_traits;
36 pub mod attr;
37 pub mod entry;
38 pub mod expand;
39 pub mod mut_visit;
40 pub mod node_id;
41 pub mod ptr;
42 pub mod token;
43 pub mod tokenstream;
44 pub mod visit;
45
46 pub use self::ast::*;
47 pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasSpan, HasTokens};
48
49 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
50
51 /// Requirements for a `StableHashingContext` to be used in this crate.
52 /// This is a hack to allow using the `HashStable_Generic` derive macro
53 /// instead of implementing everything in `rustc_middle`.
54 pub trait HashStableContext: rustc_span::HashStableContext {
55     fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
56 }
57
58 impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
59     fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
60         hcx.hash_attr(self, hasher)
61     }
62 }