1 //! The Rust parser and macro expander.
5 //! This API is completely unstable and subject to change.
7 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
8 test(attr(deny(warnings))))]
10 #![feature(box_syntax)]
12 #![feature(const_transmute)]
13 #![feature(crate_visibility_modifier)]
14 #![feature(label_break_value)]
16 #![feature(try_trait)]
17 #![feature(slice_patterns)]
18 #![feature(unicode_internals)]
20 #![recursion_limit="256"]
23 use rustc_data_structures::sync::Lock;
24 use rustc_index::bit_set::GrowableBitSet;
25 pub use rustc_data_structures::thin_vec::ThinVec;
27 use syntax_pos::edition::Edition;
30 macro_rules! unwrap_or {
31 ($opt:expr, $default:expr) => {
40 used_attrs: Lock<GrowableBitSet<AttrId>>,
41 known_attrs: Lock<GrowableBitSet<AttrId>>,
42 syntax_pos_globals: syntax_pos::Globals,
46 fn new(edition: Edition) -> Globals {
48 // We have no idea how many attributes there will be, so just
49 // initiate the vectors with 0 bits. We'll grow them as necessary.
50 used_attrs: Lock::new(GrowableBitSet::new_empty()),
51 known_attrs: Lock::new(GrowableBitSet::new_empty()),
52 syntax_pos_globals: syntax_pos::Globals::new(edition),
57 pub fn with_globals<F, R>(edition: Edition, f: F) -> R
58 where F: FnOnce() -> R
60 let globals = Globals::new(edition);
61 GLOBALS.set(&globals, || {
62 syntax_pos::GLOBALS.set(&globals.syntax_pos_globals, f)
66 pub fn with_default_globals<F, R>(f: F) -> R
67 where F: FnOnce() -> R
69 with_globals(edition::DEFAULT_EDITION, f)
72 scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
93 pub use syntax_pos::source_map;
95 pub mod feature_gate {
98 check_crate, check_attribute, get_features, feature_err, emit_feature_err,
99 GateIssue, UnstableFeatures,
105 pub use syntax_pos::edition;
106 pub use syntax_pos::symbol;
118 pub mod early_buffered_lints;
120 /// Requirements for a `StableHashingContext` to be used in this crate.
121 /// This is a hack to allow using the `HashStable_Generic` derive macro
122 /// instead of implementing everything in librustc.
123 pub trait HashStableContext: syntax_pos::HashStableContext {}