]> git.lizzy.rs Git - rust.git/blob - src/librustc_metadata/lib.rs
Rollup merge of #58096 - h-michael:linkchecker-2018, r=Centril
[rust.git] / src / librustc_metadata / lib.rs
1 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
3        html_root_url = "https://doc.rust-lang.org/nightly/")]
4
5 #![feature(box_patterns)]
6 #![feature(libc)]
7 #![feature(nll)]
8 #![feature(proc_macro_internals)]
9 #![feature(proc_macro_quote)]
10 #![feature(rustc_diagnostic_macros)]
11 #![feature(slice_sort_by_cached_key)]
12 #![feature(crate_visibility_modifier)]
13 #![feature(specialization)]
14 #![feature(rustc_private)]
15
16 #![recursion_limit="256"]
17
18 extern crate libc;
19 #[macro_use]
20 extern crate log;
21 extern crate memmap;
22 extern crate stable_deref_trait;
23 #[macro_use]
24 extern crate syntax;
25 extern crate syntax_pos;
26 extern crate flate2;
27 extern crate serialize as rustc_serialize; // used by deriving
28 extern crate rustc_errors as errors;
29 extern crate syntax_ext;
30 extern crate proc_macro;
31
32 #[macro_use]
33 extern crate rustc;
34 extern crate rustc_target;
35 #[macro_use]
36 extern crate rustc_data_structures;
37
38 mod diagnostics;
39
40 mod index_builder;
41 mod index;
42 mod encoder;
43 mod decoder;
44 mod cstore_impl;
45 mod isolated_encoder;
46 mod schema;
47 mod native_libs;
48 mod link_args;
49 mod foreign_modules;
50
51 pub mod creader;
52 pub mod cstore;
53 pub mod dynamic_lib;
54 pub mod locator;
55
56 pub fn validate_crate_name(
57     sess: Option<&rustc::session::Session>,
58     s: &str,
59     sp: Option<syntax_pos::Span>
60 ) {
61     let mut err_count = 0;
62     {
63         let mut say = |s: &str| {
64             match (sp, sess) {
65                 (_, None) => bug!("{}", s),
66                 (Some(sp), Some(sess)) => sess.span_err(sp, s),
67                 (None, Some(sess)) => sess.err(s),
68             }
69             err_count += 1;
70         };
71         if s.is_empty() {
72             say("crate name must not be empty");
73         }
74         for c in s.chars() {
75             if c.is_alphanumeric() { continue }
76             if c == '_'  { continue }
77             say(&format!("invalid character `{}` in crate name: `{}`", c, s));
78         }
79     }
80
81     if err_count > 0 {
82         sess.unwrap().abort_if_errors();
83     }
84 }
85
86 __build_diagnostic_array! { librustc_metadata, DIAGNOSTICS }