Skip to content

Commit 06695c2

Browse files
committed
Remove rustc_metadata_utils, which contains only one function
1 parent 029cf2f commit 06695c2

File tree

9 files changed

+35
-76
lines changed

9 files changed

+35
-76
lines changed

src/Cargo.lock

+1-11
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ dependencies = [
21382138
"rustc_allocator 0.0.0",
21392139
"rustc_data_structures 0.0.0",
21402140
"rustc_incremental 0.0.0",
2141-
"rustc_metadata_utils 0.0.0",
2141+
"rustc_metadata 0.0.0",
21422142
"rustc_mir 0.0.0",
21432143
"rustc_target 0.0.0",
21442144
"serialize 0.0.0",
@@ -2284,23 +2284,13 @@ dependencies = [
22842284
"rustc 0.0.0",
22852285
"rustc_data_structures 0.0.0",
22862286
"rustc_errors 0.0.0",
2287-
"rustc_metadata_utils 0.0.0",
22882287
"rustc_target 0.0.0",
22892288
"serialize 0.0.0",
22902289
"syntax 0.0.0",
22912290
"syntax_ext 0.0.0",
22922291
"syntax_pos 0.0.0",
22932292
]
22942293

2295-
[[package]]
2296-
name = "rustc_metadata_utils"
2297-
version = "0.0.0"
2298-
dependencies = [
2299-
"rustc 0.0.0",
2300-
"syntax 0.0.0",
2301-
"syntax_pos 0.0.0",
2302-
]
2303-
23042294
[[package]]
23052295
name = "rustc_mir"
23062296
version = "0.0.0"

src/librustc_codegen_utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ rustc = { path = "../librustc" }
2020
rustc_allocator = { path = "../librustc_allocator" }
2121
rustc_target = { path = "../librustc_target" }
2222
rustc_data_structures = { path = "../librustc_data_structures" }
23+
rustc_metadata = { path = "../librustc_metadata" }
2324
rustc_mir = { path = "../librustc_mir" }
2425
rustc_incremental = { path = "../librustc_incremental" }
25-
rustc_metadata_utils = { path = "../librustc_metadata_utils" }

src/librustc_codegen_utils/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ extern crate serialize;
3535
extern crate rustc;
3636
extern crate rustc_allocator;
3737
extern crate rustc_target;
38+
extern crate rustc_metadata;
3839
extern crate rustc_mir;
3940
extern crate rustc_incremental;
4041
extern crate syntax;
4142
extern crate syntax_pos;
4243
#[macro_use] extern crate rustc_data_structures;
43-
extern crate rustc_metadata_utils;
4444

4545
use std::path::PathBuf;
4646

src/librustc_codegen_utils/link.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc::session::Session;
1313
use std::path::{Path, PathBuf};
1414
use syntax::{ast, attr};
1515
use syntax_pos::Span;
16-
use rustc_metadata_utils::validate_crate_name;
1716

1817
pub fn out_filename(sess: &Session,
1918
crate_type: config::CrateType,
@@ -52,7 +51,7 @@ pub fn find_crate_name(sess: Option<&Session>,
5251
attrs: &[ast::Attribute],
5352
input: &Input) -> String {
5453
let validate = |s: String, span: Option<Span>| {
55-
validate_crate_name(sess, &s, span);
54+
::rustc_metadata::validate_crate_name(sess, &s, span);
5655
s
5756
};
5857

src/librustc_metadata/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ serialize = { path = "../libserialize" }
2020
syntax = { path = "../libsyntax" }
2121
syntax_ext = { path = "../libsyntax_ext" }
2222
syntax_pos = { path = "../libsyntax_pos" }
23-
rustc_metadata_utils = { path = "../librustc_metadata_utils" }

src/librustc_metadata/creader.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ use rustc::util::common::record_time;
3030
use rustc::util::nodemap::FxHashSet;
3131
use rustc::hir::map::Definitions;
3232

33-
use rustc_metadata_utils::validate_crate_name;
34-
3533
use std::ops::Deref;
3634
use std::path::PathBuf;
3735
use std::{cmp, fs};
@@ -1106,7 +1104,7 @@ impl<'a> CrateLoader<'a> {
11061104
item.ident, orig_name);
11071105
let orig_name = match orig_name {
11081106
Some(orig_name) => {
1109-
validate_crate_name(Some(self.sess), &orig_name.as_str(),
1107+
::validate_crate_name(Some(self.sess), &orig_name.as_str(),
11101108
Some(item.span));
11111109
orig_name
11121110
}

src/librustc_metadata/lib.rs

+30-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ extern crate serialize as rustc_serialize; // used by deriving
3838
extern crate rustc_errors as errors;
3939
extern crate syntax_ext;
4040
extern crate proc_macro;
41-
extern crate rustc_metadata_utils;
4241

4342
#[macro_use]
4443
extern crate rustc;
@@ -64,4 +63,34 @@ pub mod cstore;
6463
pub mod dynamic_lib;
6564
pub mod locator;
6665

66+
pub fn validate_crate_name(
67+
sess: Option<&rustc::session::Session>,
68+
s: &str,
69+
sp: Option<syntax_pos::Span>
70+
) {
71+
let mut err_count = 0;
72+
{
73+
let mut say = |s: &str| {
74+
match (sp, sess) {
75+
(_, None) => bug!("{}", s),
76+
(Some(sp), Some(sess)) => sess.span_err(sp, s),
77+
(None, Some(sess)) => sess.err(s),
78+
}
79+
err_count += 1;
80+
};
81+
if s.is_empty() {
82+
say("crate name must not be empty");
83+
}
84+
for c in s.chars() {
85+
if c.is_alphanumeric() { continue }
86+
if c == '_' { continue }
87+
say(&format!("invalid character `{}` in crate name: `{}`", c, s));
88+
}
89+
}
90+
91+
if err_count > 0 {
92+
sess.unwrap().abort_if_errors();
93+
}
94+
}
95+
6796
__build_diagnostic_array! { librustc_metadata, DIAGNOSTICS }

src/librustc_metadata_utils/Cargo.toml

-14
This file was deleted.

src/librustc_metadata_utils/lib.rs

-42
This file was deleted.

0 commit comments

Comments
 (0)