diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 756d708732a4e..973fd65beb3d8 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -267,20 +267,28 @@ impl InlinedItem { // FIXME: find a better place for this? pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option) { - let say = |s: &str| { - match (sp, sess) { - (_, None) => panic!("{}", s), - (Some(sp), Some(sess)) => sess.span_fatal(sp, s), - (None, Some(sess)) => sess.fatal(s), + let mut err_count = 0; + { + let mut say = |s: &str| { + match (sp, sess) { + (_, None) => panic!("{}", 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 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(); } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index e30fafda63cb4..c698f72955320 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3038,7 +3038,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { record_used: bool) -> Option { if identifier.name == special_idents::invalid.name { - return Some(LocalDef::from_def(DefErr)); + return Some(LocalDef::from_def(Def::Err)); } // First, check to see whether the name is a primitive type.