Skip to content

Commit c859919

Browse files
committed
Remove rustc_metadata_utils, which contains only one function
1 parent d46246b commit c859919

File tree

9 files changed

+35
-76
lines changed

9 files changed

+35
-76
lines changed

src/Cargo.lock

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ dependencies = [
21442144
"rustc_allocator 0.0.0",
21452145
"rustc_data_structures 0.0.0",
21462146
"rustc_incremental 0.0.0",
2147-
"rustc_metadata_utils 0.0.0",
2147+
"rustc_metadata 0.0.0",
21482148
"rustc_mir 0.0.0",
21492149
"rustc_target 0.0.0",
21502150
"serialize 0.0.0",
@@ -2291,23 +2291,13 @@ dependencies = [
22912291
"rustc 0.0.0",
22922292
"rustc_data_structures 0.0.0",
22932293
"rustc_errors 0.0.0",
2294-
"rustc_metadata_utils 0.0.0",
22952294
"rustc_target 0.0.0",
22962295
"serialize 0.0.0",
22972296
"syntax 0.0.0",
22982297
"syntax_ext 0.0.0",
22992298
"syntax_pos 0.0.0",
23002299
]
23012300

2302-
[[package]]
2303-
name = "rustc_metadata_utils"
2304-
version = "0.0.0"
2305-
dependencies = [
2306-
"rustc 0.0.0",
2307-
"syntax 0.0.0",
2308-
"syntax_pos 0.0.0",
2309-
]
2310-
23112301
[[package]]
23122302
name = "rustc_mir"
23132303
version = "0.0.0"

src/librustc_codegen_utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 30 additions & 1 deletion
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

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/librustc_metadata_utils/lib.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)