]> git.lizzy.rs Git - rust.git/blob - src/libsyntax/lib.rs
(hopefully) fix pprust error
[rust.git] / src / libsyntax / lib.rs
1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! The Rust parser and macro expander.
12 //!
13 //! # Note
14 //!
15 //! This API is completely unstable and subject to change.
16
17 #![crate_name = "syntax"]
18 #![unstable(feature = "rustc_private", issue = "27812")]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23        html_root_url = "https://doc.rust-lang.org/nightly/",
24        test(attr(deny(warnings))))]
25 #![deny(warnings)]
26
27 #![feature(rustc_private)]
28 #![feature(staged_api)]
29 #![feature(unicode)]
30 #![feature(rustc_diagnostic_macros)]
31 #![feature(i128_type)]
32
33 extern crate serialize;
34 #[macro_use] extern crate log;
35 #[macro_use] extern crate bitflags;
36 extern crate std_unicode;
37 pub extern crate rustc_errors as errors;
38 extern crate syntax_pos;
39 extern crate rustc_data_structures;
40
41 extern crate serialize as rustc_serialize; // used by deriving
42
43 // A variant of 'try!' that panics on an Err. This is used as a crutch on the
44 // way towards a non-panic!-prone parser. It should be used for fatal parsing
45 // errors; eventually we plan to convert all code using panictry to just use
46 // normal try.
47 // Exported for syntax_ext, not meant for general use.
48 #[macro_export]
49 macro_rules! panictry {
50     ($e:expr) => ({
51         use std::result::Result::{Ok, Err};
52         use errors::FatalError;
53         match $e {
54             Ok(e) => e,
55             Err(mut e) => {
56                 e.emit();
57                 panic!(FatalError);
58             }
59         }
60     })
61 }
62
63 #[macro_export]
64 macro_rules! unwrap_or {
65     ($opt:expr, $default:expr) => {
66         match $opt {
67             Some(x) => x,
68             None => $default,
69         }
70     }
71 }
72
73 #[macro_use]
74 pub mod diagnostics {
75     #[macro_use]
76     pub mod macros;
77     pub mod plugin;
78     pub mod metadata;
79 }
80
81 // NB: This module needs to be declared first so diagnostics are
82 // registered before they are used.
83 pub mod diagnostic_list;
84
85 pub mod util {
86     pub mod lev_distance;
87     pub mod node_count;
88     pub mod parser;
89     #[cfg(test)]
90     pub mod parser_testing;
91     pub mod small_vector;
92     pub mod move_map;
93
94     mod thin_vec;
95     pub use self::thin_vec::ThinVec;
96
97     mod rc_slice;
98     pub use self::rc_slice::RcSlice;
99 }
100
101 pub mod json;
102
103 pub mod syntax {
104     pub use ext;
105     pub use parse;
106     pub use ast;
107 }
108
109 pub mod abi;
110 pub mod ast;
111 pub mod attr;
112 pub mod codemap;
113 #[macro_use]
114 pub mod config;
115 pub mod entry;
116 pub mod feature_gate;
117 pub mod fold;
118 pub mod parse;
119 pub mod ptr;
120 pub mod show_span;
121 pub mod std_inject;
122 pub mod str;
123 pub use syntax_pos::symbol;
124 pub mod test;
125 pub mod tokenstream;
126 pub mod visit;
127
128 pub mod print {
129     pub mod pp;
130     pub mod pprust;
131 }
132
133 pub mod ext {
134     pub use syntax_pos::hygiene;
135     pub mod base;
136     pub mod build;
137     pub mod derive;
138     pub mod expand;
139     pub mod placeholders;
140     pub mod quote;
141     pub mod source_util;
142
143     pub mod tt {
144         pub mod transcribe;
145         pub mod macro_parser;
146         pub mod macro_rules;
147         pub mod quoted;
148     }
149 }
150
151 #[cfg(test)]
152 mod test_snippet;
153
154 // __build_diagnostic_array! { libsyntax, DIAGNOSTICS }