]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_ast/src/lib.rs
Rollup merge of #101151 - jethrogb:jb/sgx-platform, r=JohnTitor
[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 #![cfg_attr(bootstrap, feature(label_break_value))]
17 #![feature(let_chains)]
18 #![cfg_attr(bootstrap, feature(let_else))]
19 #![feature(min_specialization)]
20 #![feature(negative_impls)]
21 #![feature(slice_internals)]
22 #![feature(stmt_expr_attributes)]
23 #![recursion_limit = "256"]
24 #![deny(rustc::untranslatable_diagnostic)]
25 #![deny(rustc::diagnostic_outside_of_impl)]
26
27 #[macro_use]
28 extern crate rustc_macros;
29
30 #[macro_use]
31 extern crate tracing;
32
33 pub mod util {
34     pub mod classify;
35     pub mod comments;
36     pub mod literal;
37     pub mod parser;
38     pub mod unicode;
39 }
40
41 pub mod ast;
42 pub mod ast_traits;
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 pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasSpan, HasTokens};
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 `rustc_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 }