Fix a rebasing issue and addressed reviewer comment

This commit is contained in:
Nick Cameron 2016-01-22 08:55:54 +13:00
parent ff009d1d36
commit 43b3681588
2 changed files with 21 additions and 13 deletions

View File

@ -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<Span>) {
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();
}
}

View File

@ -3038,7 +3038,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
record_used: bool)
-> Option<LocalDef> {
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.