File tree Expand file tree Collapse file tree 9 files changed +35
-76
lines changed Expand file tree Collapse file tree 9 files changed +35
-76
lines changed Original file line number Diff line number Diff 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 ]]
23122302name = " rustc_mir"
23132303version = " 0.0.0"
Original file line number Diff line number Diff line change @@ -20,6 +20,6 @@ rustc = { path = "../librustc" }
2020rustc_allocator = { path = " ../librustc_allocator" }
2121rustc_target = { path = " ../librustc_target" }
2222rustc_data_structures = { path = " ../librustc_data_structures" }
23+ rustc_metadata = { path = " ../librustc_metadata" }
2324rustc_mir = { path = " ../librustc_mir" }
2425rustc_incremental = { path = " ../librustc_incremental" }
25- rustc_metadata_utils = { path = " ../librustc_metadata_utils" }
Original file line number Diff line number Diff line change @@ -35,12 +35,12 @@ extern crate serialize;
3535extern crate rustc;
3636extern crate rustc_allocator;
3737extern crate rustc_target;
38+ extern crate rustc_metadata;
3839extern crate rustc_mir;
3940extern crate rustc_incremental;
4041extern crate syntax;
4142extern crate syntax_pos;
4243#[ macro_use] extern crate rustc_data_structures;
43- extern crate rustc_metadata_utils;
4444
4545use std:: path:: PathBuf ;
4646
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ use rustc::session::Session;
1313use std:: path:: { Path , PathBuf } ;
1414use syntax:: { ast, attr} ;
1515use syntax_pos:: Span ;
16- use rustc_metadata_utils:: validate_crate_name;
1716
1817pub 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
Original file line number Diff line number Diff line change @@ -20,4 +20,3 @@ serialize = { path = "../libserialize" }
2020syntax = { path = " ../libsyntax" }
2121syntax_ext = { path = " ../libsyntax_ext" }
2222syntax_pos = { path = " ../libsyntax_pos" }
23- rustc_metadata_utils = { path = " ../librustc_metadata_utils" }
Original file line number Diff line number Diff line change @@ -30,8 +30,6 @@ use rustc::util::common::record_time;
3030use rustc:: util:: nodemap:: FxHashSet ;
3131use rustc:: hir:: map:: Definitions ;
3232
33- use rustc_metadata_utils:: validate_crate_name;
34-
3533use std:: ops:: Deref ;
3634use std:: path:: PathBuf ;
3735use 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 }
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ extern crate serialize as rustc_serialize; // used by deriving
3838extern crate rustc_errors as errors;
3939extern crate syntax_ext;
4040extern crate proc_macro;
41- extern crate rustc_metadata_utils;
4241
4342#[ macro_use]
4443extern crate rustc;
@@ -64,4 +63,34 @@ pub mod cstore;
6463pub mod dynamic_lib;
6564pub 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 }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments