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