]> git.proxmox.com Git - rustc.git/blame - src/librustc_ast/lib.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_ast / 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
dfeec247 7#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
60c5eb7d 8#![feature(bool_to_option)]
416331ca 9#![feature(box_syntax)]
ba9703b0 10#![feature(const_if_match)]
dfeec247 11#![feature(const_fn)] // For the `transmute` in `P::new`
ba9703b0 12#![feature(const_panic)]
dc9dc135 13#![feature(const_transmute)]
8faf50e0 14#![feature(crate_visibility_modifier)]
9fa01778 15#![feature(label_break_value)]
0bf4aa26 16#![feature(nll)]
ba9703b0 17#![feature(or_patterns)]
b7449926 18#![feature(try_trait)]
8faf50e0 19#![feature(unicode_internals)]
dfeec247 20#![recursion_limit = "256"]
1a4d82fc 21
cc61c64b
XL
22#[macro_export]
23macro_rules! unwrap_or {
24 ($opt:expr, $default:expr) => {
25 match $opt {
26 Some(x) => x,
27 None => $default,
28 }
dfeec247 29 };
cc61c64b
XL
30}
31
970d7e83 32pub mod util {
60c5eb7d
XL
33 pub mod classify;
34 pub mod comments;
92a42be0 35 pub mod lev_distance;
60c5eb7d 36 pub mod literal;
92a42be0 37 pub mod parser;
970d7e83 38}
223e47cc 39
223e47cc 40pub mod ast;
1a4d82fc 41pub mod attr;
74b04a01 42pub use attr::{with_default_globals, with_globals, GLOBALS};
ba9703b0 43pub mod crate_disambiguator;
e9174d1e 44pub mod entry;
dfeec247 45pub mod expand;
9fa01778 46pub mod mut_visit;
74b04a01 47pub mod node_id;
1a4d82fc 48pub mod ptr;
60c5eb7d 49pub mod token;
3157f602 50pub mod tokenstream;
1a4d82fc 51pub mod visit;
223e47cc 52
dfeec247 53use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
60c5eb7d
XL
54
55/// Requirements for a `StableHashingContext` to be used in this crate.
56/// This is a hack to allow using the `HashStable_Generic` derive macro
ba9703b0 57/// instead of implementing everything in librustc_middle.
dfeec247
XL
58pub trait HashStableContext: rustc_span::HashStableContext {
59 fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
60}
61
62impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
63 fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
64 hcx.hash_attr(self, hasher)
65 }
66}