diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2018-10-25 15:11:59 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2018-11-03 14:31:09 +0100 |
| commit | c8599191e874ffced8035f4e899505a7e2dafbfa (patch) | |
| tree | 04f991e37455bf7704a5538e93e8ba6ffd38688f /src/librustc_metadata | |
| parent | d46246b14adb519a80cf00d36e72a49a26484eee (diff) | |
| download | rust-c8599191e874ffced8035f4e899505a7e2dafbfa.tar.gz rust-c8599191e874ffced8035f4e899505a7e2dafbfa.zip | |
Remove rustc_metadata_utils, which contains only one function
Diffstat (limited to 'src/librustc_metadata')
| -rw-r--r-- | src/librustc_metadata/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/librustc_metadata/creader.rs | 4 | ||||
| -rw-r--r-- | src/librustc_metadata/lib.rs | 31 |
3 files changed, 31 insertions, 5 deletions
diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 6142fe78149..338824d5efe 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -20,4 +20,3 @@ serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } syntax_pos = { path = "../libsyntax_pos" } -rustc_metadata_utils = { path = "../librustc_metadata_utils" } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 4b96735eb77..7733ab2e246 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -30,8 +30,6 @@ use rustc::util::common::record_time; use rustc::util::nodemap::FxHashSet; use rustc::hir::map::Definitions; -use rustc_metadata_utils::validate_crate_name; - use std::ops::Deref; use std::path::PathBuf; use std::{cmp, fs}; @@ -1106,7 +1104,7 @@ impl<'a> CrateLoader<'a> { item.ident, orig_name); let orig_name = match orig_name { Some(orig_name) => { - validate_crate_name(Some(self.sess), &orig_name.as_str(), + ::validate_crate_name(Some(self.sess), &orig_name.as_str(), Some(item.span)); orig_name } diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 7008166b903..0cc0707a3a5 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -38,7 +38,6 @@ extern crate serialize as rustc_serialize; // used by deriving extern crate rustc_errors as errors; extern crate syntax_ext; extern crate proc_macro; -extern crate rustc_metadata_utils; #[macro_use] extern crate rustc; @@ -64,4 +63,34 @@ pub mod cstore; pub mod dynamic_lib; pub mod locator; +pub fn validate_crate_name( + sess: Option<&rustc::session::Session>, + s: &str, + sp: Option<syntax_pos::Span> +) { + let mut err_count = 0; + { + let mut say = |s: &str| { + match (sp, sess) { + (_, None) => bug!("{}", s), + (Some(sp), Some(sess)) => sess.span_err(sp, s), + (None, Some(sess)) => sess.err(s), + } + err_count += 1; + }; + if s.is_empty() { + say("crate name must not be empty"); + } + for c in s.chars() { + if c.is_alphanumeric() { continue } + if c == '_' { continue } + say(&format!("invalid character `{}` in crate name: `{}`", c, s)); + } + } + + if err_count > 0 { + sess.unwrap().abort_if_errors(); + } +} + __build_diagnostic_array! { librustc_metadata, DIAGNOSTICS } |
