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;
32 pub const MACRO_ARGUMENTS: Option<&'static str> = Some("macro arguments");
35 macro_rules! unwrap_or {
36 ($opt:expr, $default:expr) => {
45 used_attrs: Lock<GrowableBitSet<AttrId>>,
46 known_attrs: Lock<GrowableBitSet<AttrId>>,
47 syntax_pos_globals: syntax_pos::Globals,
51 fn new(edition: Edition) -> Globals {
53 // We have no idea how many attributes there will be, so just
54 // initiate the vectors with 0 bits. We'll grow them as necessary.
55 used_attrs: Lock::new(GrowableBitSet::new_empty()),
56 known_attrs: Lock::new(GrowableBitSet::new_empty()),
57 syntax_pos_globals: syntax_pos::Globals::new(edition),
62 pub fn with_globals<F, R>(edition: Edition, f: F) -> R
63 where F: FnOnce() -> R
65 let globals = Globals::new(edition);
66 GLOBALS.set(&globals, || {
67 syntax_pos::GLOBALS.set(&globals.syntax_pos_globals, f)
71 pub fn with_default_globals<F, R>(f: F) -> R
72 where F: FnOnce() -> R
74 with_globals(edition::DEFAULT_EDITION, f)
77 scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
100 #[macro_use] pub mod config;
102 pub mod feature_gate;
107 pub use syntax_pos::edition;
108 pub use syntax_pos::symbol;
119 pub mod early_buffered_lints;