diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-21 08:51:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-21 08:51:14 +0100 |
| commit | 0b99489a89a10b5bd4e69ca9d9c32d03582c4aea (patch) | |
| tree | 50de525c3b0fcd9749e2216621f6eddd0bb143bb /src/librustc_metadata | |
| parent | 426a4cc930476a557b1e8b3d708a8bec97bad92a (diff) | |
| parent | 2d75a339ca9e7cd11338b165311927e6eb73cca4 (diff) | |
| download | rust-0b99489a89a10b5bd4e69ca9d9c32d03582c4aea.tar.gz rust-0b99489a89a10b5bd4e69ca9d9c32d03582c4aea.zip | |
Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddyb
Refactorings to get rid of rustc_codegen_utils r? @eddyb cc #45276 After this, the only modules left in `rustc_codegen_utils` are - `link`: a bunch of linking-related functions (many dealing with file names). These are mostly consumed by save analysis, rustc_driver, rustc_interface, and of course codegen. I assume they live here because we don't want a dependency of save analysis on codegen... Perhaps they can be moved to librustc? - ~`symbol_names` and `symbol_names_test`: honestly it seems odd that `symbol_names_test` is not a submodule of `symbol_names`. It seems like these could honestly live in their own crate or move to librustc. Already name mangling is exported as the `symbol_name` query.~ (move it to its own crate) I don't mind doing either of the above as part of this PR or a followup if you want.
Diffstat (limited to 'src/librustc_metadata')
| -rw-r--r-- | src/librustc_metadata/creader.rs | 7 | ||||
| -rw-r--r-- | src/librustc_metadata/lib.rs | 34 |
2 files changed, 2 insertions, 39 deletions
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 9b6e427abc1..1f551583b0c 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -16,6 +16,7 @@ use rustc_expand::base::SyntaxExtension; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_index::vec::IndexVec; use rustc_session::config; +use rustc_session::output::validate_crate_name; use rustc_session::search_paths::PathKind; use rustc_session::{CrateDisambiguator, Session}; use rustc_span::edition::Edition; @@ -852,11 +853,7 @@ impl<'a> CrateLoader<'a> { ); let name = match orig_name { Some(orig_name) => { - crate::validate_crate_name( - Some(self.sess), - &orig_name.as_str(), - Some(item.span), - ); + validate_crate_name(Some(self.sess), &orig_name.as_str(), Some(item.span)); orig_name } None => item.ident.name, diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index e401dc0f6e7..2993aed2f8a 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -29,37 +29,3 @@ mod rmeta; pub mod creader; pub mod dynamic_lib; pub mod locator; - -pub fn validate_crate_name( - sess: Option<&rustc_session::Session>, - s: &str, - sp: Option<rustc_span::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(); - } -} |
