]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_ast/src/lib.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / compiler / rustc_ast / src / lib.rs
CommitLineData
1a4d82fc
JJ
1//! The Rust parser and macro expander.
2//!
3//! # Note
4//!
5//! This API is completely unstable and subject to change.
6
1b1a35ee
XL
7#![doc(
8 html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
9 test(attr(deny(warnings)))
10)]
5869c6ff 11#![feature(box_patterns)]
94222f64 12#![cfg_attr(bootstrap, feature(const_fn_transmute))]
8faf50e0 13#![feature(crate_visibility_modifier)]
94222f64 14#![feature(if_let_guard)]
cdc7bbd5 15#![feature(iter_zip)]
9fa01778 16#![feature(label_break_value)]
0bf4aa26 17#![feature(nll)]
17df50a5 18#![feature(min_specialization)]
94222f64 19#![cfg_attr(bootstrap, allow(incomplete_features))] // if_let_guard
dfeec247 20#![recursion_limit = "256"]
1a4d82fc 21
3dfed10e 22#[macro_use]
f9f354fc
XL
23extern crate rustc_macros;
24
cc61c64b
XL
25#[macro_export]
26macro_rules! unwrap_or {
27 ($opt:expr, $default:expr) => {
28 match $opt {
29 Some(x) => x,
30 None => $default,
31 }
dfeec247 32 };
cc61c64b
XL
33}
34
970d7e83 35pub mod util {
60c5eb7d
XL
36 pub mod classify;
37 pub mod comments;
60c5eb7d 38 pub mod literal;
92a42be0 39 pub mod parser;
970d7e83 40}
223e47cc 41
223e47cc 42pub mod ast;
6a06907d 43pub mod ast_like;
1a4d82fc 44pub mod attr;
e9174d1e 45pub mod entry;
dfeec247 46pub mod expand;
9fa01778 47pub mod mut_visit;
74b04a01 48pub mod node_id;
1a4d82fc 49pub mod ptr;
60c5eb7d 50pub mod token;
3157f602 51pub mod tokenstream;
1a4d82fc 52pub mod visit;
223e47cc 53
3dfed10e 54pub use self::ast::*;
6a06907d 55pub use self::ast_like::AstLike;
3dfed10e 56
dfeec247 57use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
60c5eb7d
XL
58
59/// Requirements for a `StableHashingContext` to be used in this crate.
60/// This is a hack to allow using the `HashStable_Generic` derive macro
cdc7bbd5 61/// instead of implementing everything in `rustc_middle`.
dfeec247
XL
62pub trait HashStableContext: rustc_span::HashStableContext {
63 fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
64}
65
66impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
67 fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
68 hcx.hash_attr(self, hasher)
69 }
70}