2014-06-09 20:12:30 +00:00
|
|
|
//! The Rust parser and macro expander.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2013-03-29 19:51:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
|
2019-10-08 00:14:42 +00:00
|
|
|
#![feature(bool_to_option)]
|
2019-06-12 06:36:12 +00:00
|
|
|
#![feature(box_syntax)]
|
2020-01-11 01:40:57 +00:00
|
|
|
#![feature(const_fn)] // For the `transmute` in `P::new`
|
2020-03-10 20:41:33 +00:00
|
|
|
#![feature(const_panic)]
|
2020-07-16 13:12:59 +00:00
|
|
|
#![feature(const_fn_transmute)]
|
2018-06-22 22:05:07 +00:00
|
|
|
#![feature(crate_visibility_modifier)]
|
2019-01-01 23:21:05 +00:00
|
|
|
#![feature(label_break_value)]
|
2019-02-10 07:13:30 +00:00
|
|
|
#![feature(nll)]
|
2020-04-17 00:38:52 +00:00
|
|
|
#![feature(or_patterns)]
|
2018-08-20 00:51:02 +00:00
|
|
|
#![feature(try_trait)]
|
2018-06-22 22:05:07 +00:00
|
|
|
#![feature(unicode_internals)]
|
2019-12-22 22:42:04 +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;
|
|
|
|
|
2017-03-03 09:23:59 +00:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! unwrap_or {
|
|
|
|
($opt:expr, $default:expr) => {
|
|
|
|
match $opt {
|
|
|
|
Some(x) => x,
|
|
|
|
None => $default,
|
|
|
|
}
|
2019-12-22 22:42:04 +00:00
|
|
|
};
|
2017-03-03 09:23:59 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2015-11-25 23:21:38 +00:00
|
|
|
pub mod lev_distance;
|
2019-10-15 20:48:13 +00:00
|
|
|
pub mod literal;
|
2015-11-11 05:26:14 +00:00
|
|
|
pub mod parser;
|
2013-04-03 16:41:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 22:41:40 +00:00
|
|
|
pub mod ast;
|
2014-07-01 16:39:41 +00:00
|
|
|
pub mod attr;
|
2020-03-21 03:30:30 +00:00
|
|
|
pub mod crate_disambiguator;
|
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::*;
|
|
|
|
|
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
|
2020-03-29 13:24:45 +00:00
|
|
|
/// instead of implementing everything in librustc_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)
|
|
|
|
}
|
|
|
|
}
|