Fix a rebasing issue and addressed reviewer comment
This commit is contained in:
parent
ff009d1d36
commit
43b3681588
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user