]> git.proxmox.com Git - rustc.git/blame - src/libsyntax/lib.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libsyntax / lib.rs
CommitLineData
223e47cc
LB
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
1a4d82fc
JJ
11//! The Rust parser and macro expander.
12//!
13//! # Note
14//!
15//! This API is completely unstable and subject to change.
16
e9174d1e 17#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
62682a34 18 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
92a42be0
SL
19 html_root_url = "https://doc.rust-lang.org/nightly/",
20 test(attr(deny(warnings))))]
32a655c1 21#![deny(warnings)]
1a4d82fc 22
d9579d0f 23#![feature(unicode)]
3157f602 24#![feature(rustc_diagnostic_macros)]
ff7c6d11 25#![feature(match_default_bindings)]
8bb4bdeb 26#![feature(i128_type)]
ff7c6d11 27#![feature(const_atomic_usize_new)]
2c00a5a8 28#![feature(rustc_attrs)]
1a4d82fc 29
ea8adc8c
XL
30// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
31#[allow(unused_extern_crates)]
32extern crate rustc_cratesio_shim;
33
34#[macro_use] extern crate bitflags;
1a4d82fc 35extern crate serialize;
1a4d82fc 36#[macro_use] extern crate log;
476ff2be 37extern crate std_unicode;
3157f602
XL
38pub extern crate rustc_errors as errors;
39extern crate syntax_pos;
476ff2be 40extern crate rustc_data_structures;
1a4d82fc 41
32a655c1 42extern crate serialize as rustc_serialize; // used by deriving
3157f602 43
9cc50fc6
SL
44// A variant of 'try!' that panics on an Err. This is used as a crutch on the
45// way towards a non-panic!-prone parser. It should be used for fatal parsing
46// errors; eventually we plan to convert all code using panictry to just use
47// normal try.
48// Exported for syntax_ext, not meant for general use.
49#[macro_export]
9346a6ac
AL
50macro_rules! panictry {
51 ($e:expr) => ({
52 use std::result::Result::{Ok, Err};
3157f602 53 use errors::FatalError;
9346a6ac
AL
54 match $e {
55 Ok(e) => e,
9cc50fc6
SL
56 Err(mut e) => {
57 e.emit();
2c00a5a8 58 FatalError.raise()
9cc50fc6 59 }
9346a6ac
AL
60 }
61 })
62}
63
cc61c64b
XL
64#[macro_export]
65macro_rules! unwrap_or {
66 ($opt:expr, $default:expr) => {
67 match $opt {
68 Some(x) => x,
69 None => $default,
70 }
71 }
72}
73
3157f602
XL
74#[macro_use]
75pub mod diagnostics {
76 #[macro_use]
77 pub mod macros;
78 pub mod plugin;
79 pub mod metadata;
80}
81
82// NB: This module needs to be declared first so diagnostics are
83// registered before they are used.
84pub mod diagnostic_list;
85
970d7e83 86pub mod util {
92a42be0
SL
87 pub mod lev_distance;
88 pub mod node_count;
89 pub mod parser;
970d7e83
LB
90 #[cfg(test)]
91 pub mod parser_testing;
1a4d82fc 92 pub mod small_vector;
92a42be0 93 pub mod move_map;
1a4d82fc 94
3157f602
XL
95 mod thin_vec;
96 pub use self::thin_vec::ThinVec;
32a655c1
SL
97
98 mod rc_slice;
99 pub use self::rc_slice::RcSlice;
970d7e83 100}
223e47cc 101
3157f602 102pub mod json;
9cc50fc6 103
223e47cc
LB
104pub mod syntax {
105 pub use ext;
106 pub use parse;
1a4d82fc 107 pub use ast;
223e47cc
LB
108}
109
223e47cc
LB
110pub mod abi;
111pub mod ast;
1a4d82fc
JJ
112pub mod attr;
113pub mod codemap;
9e0c209e 114#[macro_use]
1a4d82fc 115pub mod config;
e9174d1e 116pub mod entry;
1a4d82fc 117pub mod feature_gate;
223e47cc 118pub mod fold;
223e47cc 119pub mod parse;
1a4d82fc
JJ
120pub mod ptr;
121pub mod show_span;
122pub mod std_inject;
d9579d0f 123pub mod str;
cc61c64b 124pub use syntax_pos::symbol;
1a4d82fc 125pub mod test;
3157f602 126pub mod tokenstream;
1a4d82fc 127pub mod visit;
223e47cc
LB
128
129pub mod print {
130 pub mod pp;
131 pub mod pprust;
132}
133
134pub mod ext {
cc61c64b 135 pub use syntax_pos::hygiene;
223e47cc 136 pub mod base;
1a4d82fc 137 pub mod build;
8bb4bdeb 138 pub mod derive;
223e47cc 139 pub mod expand;
9e0c209e 140 pub mod placeholders;
223e47cc 141 pub mod quote;
1a4d82fc 142 pub mod source_util;
223e47cc
LB
143
144 pub mod tt {
145 pub mod transcribe;
146 pub mod macro_parser;
147 pub mod macro_rules;
8bb4bdeb 148 pub mod quoted;
223e47cc 149 }
223e47cc 150}
3157f602 151
476ff2be
SL
152#[cfg(test)]
153mod test_snippet;
154
2c00a5a8 155#[cfg(not(stage0))] // remove after the next snapshot
3b2f2976 156__build_diagnostic_array! { libsyntax, DIAGNOSTICS }