2021-11-03 02:10:31 +00:00
|
|
|
//! The Rust Abstract Syntax Tree (AST).
|
2014-06-09 20:12:30 +00:00
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2013-03-29 19:51:10 +00:00
|
|
|
|
2020-09-23 20:08:30 +00:00
|
|
|
#![doc(
|
|
|
|
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
|
|
|
test(attr(deny(warnings)))
|
|
|
|
)]
|
2022-05-01 17:58:24 +00:00
|
|
|
#![feature(associated_type_bounds)]
|
2021-01-29 07:31:08 +00:00
|
|
|
#![feature(box_patterns)]
|
2022-04-11 18:44:13 +00:00
|
|
|
#![feature(const_default_impls)]
|
|
|
|
#![feature(const_trait_impl)]
|
2021-08-16 15:29:49 +00:00
|
|
|
#![feature(if_let_guard)]
|
2019-01-01 23:21:05 +00:00
|
|
|
#![feature(label_break_value)]
|
2021-04-02 04:58:45 +00:00
|
|
|
#![feature(min_specialization)]
|
2022-05-01 17:58:24 +00:00
|
|
|
#![feature(negative_impls)]
|
2021-11-04 22:31:42 +00:00
|
|
|
#![feature(slice_internals)]
|
2022-02-24 05:49:37 +00:00
|
|
|
#![feature(stmt_expr_attributes)]
|
2022-02-26 16:45:36 +00:00
|
|
|
#![recursion_limit = "256"]
|
2014-01-09 13:05:33 +00:00
|
|
|
|
2020-06-11 14:49:57 +00:00
|
|
|
#[macro_use]
|
2020-05-08 15:38:18 +00:00
|
|
|
extern crate rustc_macros;
|
|
|
|
|
2013-04-03 16:41:40 +00:00
|
|
|
pub mod util {
|
2019-10-15 20:48:13 +00:00
|
|
|
pub mod classify;
|
2019-10-11 12:39:52 +00:00
|
|
|
pub mod comments;
|
2019-10-15 20:48:13 +00:00
|
|
|
pub mod literal;
|
2015-11-11 05:26:14 +00:00
|
|
|
pub mod parser;
|
2021-11-04 22:31:42 +00:00
|
|
|
pub mod unicode;
|
2013-04-03 16:41:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:41:40 +00:00
|
|
|
pub mod ast;
|
2022-05-01 17:58:24 +00:00
|
|
|
pub mod ast_traits;
|
2014-07-01 16:39:41 +00:00
|
|
|
pub mod attr;
|
2015-08-23 18:12:39 +00:00
|
|
|
pub mod entry;
|
2020-01-01 18:25:28 +00:00
|
|
|
pub mod expand;
|
2019-02-05 22:10:05 +00:00
|
|
|
pub mod mut_visit;
|
2020-01-11 14:03:15 +00:00
|
|
|
pub mod node_id;
|
2014-05-17 21:46:40 +00:00
|
|
|
pub mod ptr;
|
2019-10-11 10:46:32 +00:00
|
|
|
pub mod token;
|
2016-06-20 15:49:33 +00:00
|
|
|
pub mod tokenstream;
|
2014-07-01 16:39:41 +00:00
|
|
|
pub mod visit;
|
2013-01-29 22:41:40 +00:00
|
|
|
|
2020-04-27 17:56:11 +00:00
|
|
|
pub use self::ast::*;
|
2022-05-01 17:58:24 +00:00
|
|
|
pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasSpan, HasTokens};
|
2020-04-27 17:56:11 +00:00
|
|
|
|
2020-01-02 04:18:45 +00:00
|
|
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
|
|
|
|
2019-11-10 16:19:08 +00:00
|
|
|
/// Requirements for a `StableHashingContext` to be used in this crate.
|
|
|
|
/// This is a hack to allow using the `HashStable_Generic` derive macro
|
2021-04-07 19:47:01 +00:00
|
|
|
/// instead of implementing everything in `rustc_middle`.
|
2020-01-02 04:18:45 +00:00
|
|
|
pub trait HashStableContext: rustc_span::HashStableContext {
|
|
|
|
fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
|
|
|
|
fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
|
|
|
|
hcx.hash_attr(self, hasher)
|
|
|
|
}
|
|
|
|
}
|