Joshua Nelson 2020-12-29 20:28:08 -05:00
parent dc6121ca68
commit edeac1778c
27 changed files with 46 additions and 46 deletions

View File

@ -1716,7 +1716,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
self.arena.alloc_from_iter(inputs.iter().map(|param| match param.pat.kind {
PatKind::Ident(_, ident, _) => ident,
_ => Ident::new(kw::Invalid, param.pat.span),
_ => Ident::new(kw::Empty, param.pat.span),
}))
}

View File

@ -184,7 +184,7 @@ impl<'a> AstValidator<'a> {
}
fn check_lifetime(&self, ident: Ident) {
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Invalid];
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Empty];
if !valid_names.contains(&ident.name) && ident.without_first_quote().is_reserved() {
self.err_handler().span_err(ident.span, "lifetimes cannot use keyword names");
}

View File

@ -2787,7 +2787,7 @@ impl<'a> State<'a> {
self.print_explicit_self(&eself);
} else {
let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind {
ident.name == kw::Invalid
ident.name == kw::Empty
} else {
false
};

View File

@ -93,7 +93,7 @@ fn parse_inline_asm<'a>(
})
.unwrap_or(tts.len());
let mut p = cx.new_parser_from_tts(tts.trees().skip(first_colon).collect());
let mut asm = kw::Invalid;
let mut asm = kw::Empty;
let mut asm_str_style = None;
let mut outputs = Vec::new();
let mut inputs = Vec::new();

View File

@ -170,7 +170,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// (after #67586 gets fixed).
None
} else {
let name = kw::Invalid;
let name = kw::Empty;
let decl = &self.mir.local_decls[local];
let dbg_var = if full_debug_info {
self.adjusted_span_and_dbg_scope(decl.source_info).map(
@ -204,7 +204,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
None
} else {
Some(match whole_local_var.or(fallback_var) {
Some(var) if var.name != kw::Invalid => var.name.to_string(),
Some(var) if var.name != kw::Empty => var.name.to_string(),
_ => format!("{:?}", local),
})
};

View File

@ -28,7 +28,7 @@ pub struct Lifetime {
pub span: Span,
/// Either "`'a`", referring to a named lifetime definition,
/// or "``" (i.e., `kw::Invalid`), for elision placeholders.
/// or "``" (i.e., `kw::Empty`), for elision placeholders.
///
/// HIR lowering inserts these placeholders in type paths that
/// refer to type definitions needing lifetime parameters,

View File

@ -868,7 +868,7 @@ impl EarlyLintPass for AnonymousParameters {
if let ast::AssocItemKind::Fn(_, ref sig, _, _) = it.kind {
for arg in sig.decl.inputs.iter() {
if let ast::PatKind::Ident(_, ident, None) = arg.pat.kind {
if ident.name == kw::Invalid {
if ident.name == kw::Empty {
cx.struct_span_lint(ANONYMOUS_PARAMETERS, arg.pat.span, |lint| {
let ty_snip = cx.sess.source_map().span_to_snippet(arg.ty.span);

View File

@ -728,7 +728,7 @@ impl<'tcx> LateContext<'tcx> {
/// Check if a `DefId`'s path matches the given absolute type path usage.
///
/// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`;
/// Anonymous scopes such as `extern` imports are matched with `kw::Empty`;
/// inherent `impl` blocks are matched with the name of the type.
///
/// Instead of using this method, it is often preferable to instead use

View File

@ -132,7 +132,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
impl Collector<'tcx> {
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLib) {
if lib.name.as_ref().map(|&s| s == kw::Invalid).unwrap_or(false) {
if lib.name.as_ref().map(|&s| s == kw::Empty).unwrap_or(false) {
match span {
Some(span) => {
struct_span_err!(

View File

@ -379,7 +379,7 @@ impl<'hir> Map<'hir> {
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
self.body(id).params.iter().map(|arg| match arg.pat.kind {
PatKind::Binding(_, _, ident, _) => ident,
_ => Ident::new(kw::Invalid, rustc_span::DUMMY_SP),
_ => Ident::new(kw::Empty, rustc_span::DUMMY_SP),
})
}

View File

@ -1481,7 +1481,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
// FIXME(eddyb) `name` should never be empty, but it
// currently is for `extern { ... }` "foreign modules".
let name = disambiguated_data.data.name();
if name != DefPathDataName::Named(kw::Invalid) {
if name != DefPathDataName::Named(kw::Empty) {
if !self.empty_path {
write!(self, "::")?;
}
@ -1608,14 +1608,14 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
match *region {
ty::ReEarlyBound(ref data) => {
data.name != kw::Invalid && data.name != kw::UnderscoreLifetime
data.name != kw::Empty && data.name != kw::UnderscoreLifetime
}
ty::ReLateBound(_, ty::BoundRegion { kind: br })
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
if let ty::BrNamed(_, name) = br {
if name != kw::Invalid && name != kw::UnderscoreLifetime {
if name != kw::Empty && name != kw::UnderscoreLifetime {
return true;
}
}
@ -1685,7 +1685,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
// `explain_region()` or `note_and_explain_region()`.
match *region {
ty::ReEarlyBound(ref data) => {
if data.name != kw::Invalid {
if data.name != kw::Empty {
p!(write("{}", data.name));
return Ok(self);
}
@ -1694,7 +1694,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
if let ty::BrNamed(_, name) = br {
if name != kw::Invalid && name != kw::UnderscoreLifetime {
if name != kw::Empty && name != kw::UnderscoreLifetime {
p!(write("{}", name));
return Ok(self);
}

View File

@ -854,7 +854,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let mut mutability = Mutability::Not;
// FIXME(project-rfc-2229#8): Store more precise information
let mut name = kw::Invalid;
let mut name = kw::Empty;
if let Some(Node::Binding(pat)) = tcx_hir.find(var_id) {
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
name = ident.name;

View File

@ -494,7 +494,7 @@ impl<'a> Parser<'a> {
let polarity = self.parse_polarity();
// Parse both types and traits as a type, then reinterpret if necessary.
let err_path = |span| ast::Path::from_ident(Ident::new(kw::Invalid, span));
let err_path = |span| ast::Path::from_ident(Ident::new(kw::Empty, span));
let ty_first = if self.token.is_keyword(kw::For) && self.look_ahead(1, |t| t != &token::Lt)
{
let span = self.prev_token.span.between(self.token.span);
@ -1699,7 +1699,7 @@ impl<'a> Parser<'a> {
// Skip every token until next possible arg or end.
p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(token::Paren)]);
// Create a placeholder argument for proper arg count (issue #34264).
Ok(dummy_arg(Ident::new(kw::Invalid, lo.to(p.prev_token.span))))
Ok(dummy_arg(Ident::new(kw::Empty, lo.to(p.prev_token.span))))
});
// ...now that we've parsed the first argument, `self` is no longer allowed.
first_param = false;
@ -1759,7 +1759,7 @@ impl<'a> Parser<'a> {
}
match ty {
Ok(ty) => {
let ident = Ident::new(kw::Invalid, self.prev_token.span);
let ident = Ident::new(kw::Empty, self.prev_token.span);
let bm = BindingMode::ByValue(Mutability::Not);
let pat = self.mk_pat_ident(ty.span, bm, ident);
(pat, ty)

View File

@ -1385,7 +1385,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
fn should_warn(&self, var: Variable) -> Option<String> {
let name = self.ir.variable_name(var);
if name == kw::Invalid {
if name == kw::Empty {
return None;
}
let name: &str = &name.as_str();

View File

@ -959,7 +959,7 @@ impl<'tcx> NamePrivacyVisitor<'tcx> {
in_update_syntax: bool,
) {
// definition of the field
let ident = Ident::new(kw::Invalid, use_ctxt);
let ident = Ident::new(kw::Empty, use_ctxt);
let current_hir = self.current_item.unwrap();
let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did, current_hir).1;
if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) {

View File

@ -342,7 +342,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
let field_names = vdata
.fields()
.iter()
.map(|field| respan(field.span, field.ident.map_or(kw::Invalid, |ident| ident.name)))
.map(|field| respan(field.span, field.ident.map_or(kw::Empty, |ident| ident.name)))
.collect();
self.insert_field_names(def_id, field_names);
}
@ -527,7 +527,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
// HACK(eddyb) unclear how good this is, but keeping `$crate`
// in `source` breaks `src/test/compile-fail/import-crate-var.rs`,
// while the current crate doesn't have a valid `crate_name`.
if crate_name != kw::Invalid {
if crate_name != kw::Empty {
// `crate_name` should not be interpreted as relative.
module_path.push(Segment {
ident: Ident { name: kw::PathRoot, span: source.ident.span },
@ -656,7 +656,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
/// Constructs the reduced graph for one item.
fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
if matches!(item.kind, ItemKind::Mod(..)) && item.ident.name == kw::Invalid {
if matches!(item.kind, ItemKind::Mod(..)) && item.ident.name == kw::Empty {
// Fake crate root item from expand.
return;
}

View File

@ -74,7 +74,7 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
// information we encapsulate into, the better
let def_data = match &i.kind {
ItemKind::Impl { .. } => DefPathData::Impl,
ItemKind::Mod(..) if i.ident.name == kw::Invalid => {
ItemKind::Mod(..) if i.ident.name == kw::Empty => {
// Fake crate root item from expand.
return visit::walk_item(self, i);
}

View File

@ -1641,7 +1641,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
}
// Record as bound if it's valid:
let ident_valid = ident.name != kw::Invalid;
let ident_valid = ident.name != kw::Empty;
if ident_valid {
bindings.last_mut().unwrap().1.insert(ident);
}

View File

@ -1182,12 +1182,12 @@ impl<'a> Resolver<'a> {
) -> Resolver<'a> {
let root_local_def_id = LocalDefId { local_def_index: CRATE_DEF_INDEX };
let root_def_id = root_local_def_id.to_def_id();
let root_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Invalid);
let root_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Empty);
let graph_root = arenas.alloc_module(ModuleData {
no_implicit_prelude: session.contains_name(&krate.attrs, sym::no_implicit_prelude),
..ModuleData::new(None, root_module_kind, root_def_id, ExpnId::root(), krate.span)
});
let empty_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Invalid);
let empty_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Empty);
let empty_module = arenas.alloc_module(ModuleData {
no_implicit_prelude: true,
..ModuleData::new(
@ -1797,7 +1797,7 @@ impl<'a> Resolver<'a> {
ribs: &[Rib<'a>],
) -> Option<LexicalScopeBinding<'a>> {
assert!(ns == TypeNS || ns == ValueNS);
if ident.name == kw::Invalid {
if ident.name == kw::Empty {
return Some(LexicalScopeBinding::Res(Res::Err));
}
let (general_span, normalized_span) = if ident.name == kw::SelfUpper {

View File

@ -160,7 +160,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
hygiene::update_dollar_crate_names(|ctxt| {
let ident = Ident::new(kw::DollarCrate, DUMMY_SP.with_ctxt(ctxt));
match self.resolve_crate_root(ident).kind {
ModuleKind::Def(.., name) if name != kw::Invalid => name,
ModuleKind::Def(.., name) if name != kw::Empty => name,
_ => kw::Crate,
}
});

View File

@ -1065,7 +1065,7 @@ pub fn decode_syntax_context<
parent: SyntaxContext::root(),
opaque: SyntaxContext::root(),
opaque_and_semitransparent: SyntaxContext::root(),
dollar_crate_name: kw::Invalid,
dollar_crate_name: kw::Empty,
});
let mut ctxts = outer_ctxts.lock();
let new_len = raw_id as usize + 1;
@ -1092,7 +1092,7 @@ pub fn decode_syntax_context<
ctxt_data,
);
// Make sure nothing weird happening while `decode_data` was running
assert_eq!(dummy.dollar_crate_name, kw::Invalid);
assert_eq!(dummy.dollar_crate_name, kw::Empty);
});
Ok(new_ctxt)

View File

@ -25,7 +25,7 @@ symbols! {
Keywords {
// Special reserved identifiers used internally for elided lifetimes,
// unnamed method parameters, crate root module, error recovery etc.
Invalid: "",
Empty: "",
PathRoot: "{{root}}",
DollarCrate: "$crate",
Underscore: "_",
@ -1273,7 +1273,7 @@ impl Ident {
#[inline]
pub fn invalid() -> Ident {
Ident::with_dummy_span(kw::Invalid)
Ident::with_dummy_span(kw::Empty)
}
/// Maps a string to an identifier with a dummy span.
@ -1470,7 +1470,7 @@ impl Symbol {
}
pub fn is_empty(self) -> bool {
self == kw::Invalid
self == kw::Empty
}
/// This method is supposed to be used in error messages, so it's expected to be
@ -1654,7 +1654,7 @@ impl Symbol {
/// Returns `true` if this symbol can be a raw identifier.
pub fn can_be_raw(self) -> bool {
self != kw::Invalid && self != kw::Underscore && !self.is_path_segment_keyword()
self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword()
}
}

View File

@ -883,7 +883,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ok(method)
}
Err(error) => {
if segment.ident.name != kw::Invalid {
if segment.ident.name != kw::Empty {
self.report_extended_method_error(segment, span, args, rcvr_t, error);
}
Err(())
@ -1547,7 +1547,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return field_ty;
}
if field.name == kw::Invalid {
if field.name == kw::Empty {
} else if self.method_exists(field, expr_t, expr.hir_id, true) {
self.ban_take_value_of_method(expr, expr_t, field);
} else if !expr_t.is_primitive_ty() {

View File

@ -914,7 +914,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
method::MethodError::PrivateMatch(kind, def_id, _) => Ok((kind, def_id)),
_ => Err(ErrorReported),
};
if item_name.name != kw::Invalid {
if item_name.name != kw::Empty {
if let Some(mut e) = self.report_method_error(
span,
ty,

View File

@ -941,7 +941,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], &'a [Ident]) {
.iter()
.enumerate()
.map(|(i, ty)| {
let mut name = self.1.get(i).map(|ident| ident.name).unwrap_or(kw::Invalid);
let mut name = self.1.get(i).map(|ident| ident.name).unwrap_or(kw::Empty);
if name.is_empty() {
name = kw::Underscore;
}
@ -1000,7 +1000,7 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
.iter()
.map(|t| Argument {
type_: t.clean(cx),
name: names.next().map(|i| i.name).unwrap_or(kw::Invalid),
name: names.next().map(|i| i.name).unwrap_or(kw::Empty),
})
.collect(),
},

View File

@ -2086,8 +2086,8 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
(true, false) => return Ordering::Greater,
}
}
let lhs = i1.name.unwrap_or(kw::Invalid).as_str();
let rhs = i2.name.unwrap_or(kw::Invalid).as_str();
let lhs = i1.name.unwrap_or(kw::Empty).as_str();
let rhs = i2.name.unwrap_or(kw::Empty).as_str();
compare_names(&lhs, &rhs)
}
@ -4206,7 +4206,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache:
ty: \"{ty}\", \
relpath: \"{path}\"\
}};</script>",
name = it.name.unwrap_or(kw::Invalid),
name = it.name.unwrap_or(kw::Empty),
ty = it.type_(),
path = relpath
);

View File

@ -501,7 +501,7 @@ impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
if lifetime.name.ident().name != kw::Invalid && lifetime.name.ident().name != kw::StaticLifetime {
if lifetime.name.ident().name != kw::Empty && lifetime.name.ident().name != kw::StaticLifetime {
self.lifetimes_used_in_body = true;
}
}