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