Skip to content

Commit

Permalink
Remove rustc_metadata_utils, which contains only one function
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 3, 2018
1 parent d46246b commit c859919
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 76 deletions.
12 changes: 1 addition & 11 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ dependencies = [
"rustc_allocator 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_incremental 0.0.0",
"rustc_metadata_utils 0.0.0",
"rustc_metadata 0.0.0",
"rustc_mir 0.0.0",
"rustc_target 0.0.0",
"serialize 0.0.0",
Expand Down Expand Up @@ -2291,23 +2291,13 @@ dependencies = [
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_metadata_utils 0.0.0",
"rustc_target 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
"syntax_ext 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_metadata_utils"
version = "0.0.0"
dependencies = [
"rustc 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_mir"
version = "0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ rustc = { path = "../librustc" }
rustc_allocator = { path = "../librustc_allocator" }
rustc_target = { path = "../librustc_target" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_metadata = { path = "../librustc_metadata" }
rustc_mir = { path = "../librustc_mir" }
rustc_incremental = { path = "../librustc_incremental" }
rustc_metadata_utils = { path = "../librustc_metadata_utils" }
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ extern crate serialize;
extern crate rustc;
extern crate rustc_allocator;
extern crate rustc_target;
extern crate rustc_metadata;
extern crate rustc_mir;
extern crate rustc_incremental;
extern crate syntax;
extern crate syntax_pos;
#[macro_use] extern crate rustc_data_structures;
extern crate rustc_metadata_utils;

use std::path::PathBuf;

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_codegen_utils/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use rustc::session::Session;
use std::path::{Path, PathBuf};
use syntax::{ast, attr};
use syntax_pos::Span;
use rustc_metadata_utils::validate_crate_name;

pub fn out_filename(sess: &Session,
crate_type: config::CrateType,
Expand Down Expand Up @@ -52,7 +51,7 @@ pub fn find_crate_name(sess: Option<&Session>,
attrs: &[ast::Attribute],
input: &Input) -> String {
let validate = |s: String, span: Option<Span>| {
validate_crate_name(sess, &s, span);
::rustc_metadata::validate_crate_name(sess, &s, span);
s
};

Expand Down
1 change: 0 additions & 1 deletion src/librustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
4 changes: 1 addition & 3 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
}
Expand Down
31 changes: 30 additions & 1 deletion src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 }
14 changes: 0 additions & 14 deletions src/librustc_metadata_utils/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions src/librustc_metadata_utils/lib.rs

This file was deleted.

0 comments on commit c859919

Please sign in to comment.