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");
34 // A variant of 'panictry!' that works on a Vec<Diagnostic> instead of a single DiagnosticBuilder.
35 macro_rules! panictry_buffer {
36 ($handler:expr, $e:expr) => ({
37 use std::result::Result::{Ok, Err};
38 use errors::FatalError;
43 $handler.emit_diagnostic(&e);
52 macro_rules! unwrap_or {
53 ($opt:expr, $default:expr) => {
62 used_attrs: Lock<GrowableBitSet<AttrId>>,
63 known_attrs: Lock<GrowableBitSet<AttrId>>,
64 syntax_pos_globals: syntax_pos::Globals,
68 fn new(edition: Edition) -> Globals {
70 // We have no idea how many attributes their will be, so just
71 // initiate the vectors with 0 bits. We'll grow them as necessary.
72 used_attrs: Lock::new(GrowableBitSet::new_empty()),
73 known_attrs: Lock::new(GrowableBitSet::new_empty()),
74 syntax_pos_globals: syntax_pos::Globals::new(edition),
79 pub fn with_globals<F, R>(edition: Edition, f: F) -> R
80 where F: FnOnce() -> R
82 let globals = Globals::new(edition);
83 GLOBALS.set(&globals, || {
84 syntax_pos::GLOBALS.set(&globals.syntax_pos_globals, f)
88 pub fn with_default_globals<F, R>(f: F) -> R
89 where F: FnOnce() -> R
91 with_globals(edition::DEFAULT_EDITION, f)
94 scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
105 pub mod lev_distance;
108 pub mod map_in_place;
119 pub mod feature_gate;
124 pub use syntax_pos::edition;
125 pub use syntax_pos::symbol;
136 pub mod early_buffered_lints;