Skip to content

Commit edeac17

Browse files

File tree

27 files changed

+46
-46
lines changed

27 files changed

+46
-46
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17161716
}
17171717
self.arena.alloc_from_iter(inputs.iter().map(|param| match param.pat.kind {
17181718
PatKind::Ident(_, ident, _) => ident,
1719-
_ => Ident::new(kw::Invalid, param.pat.span),
1719+
_ => Ident::new(kw::Empty, param.pat.span),
17201720
}))
17211721
}
17221722

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'a> AstValidator<'a> {
184184
}
185185

186186
fn check_lifetime(&self, ident: Ident) {
187-
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Invalid];
187+
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Empty];
188188
if !valid_names.contains(&ident.name) && ident.without_first_quote().is_reserved() {
189189
self.err_handler().span_err(ident.span, "lifetimes cannot use keyword names");
190190
}

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,7 @@ impl<'a> State<'a> {
27872787
self.print_explicit_self(&eself);
27882788
} else {
27892789
let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind {
2790-
ident.name == kw::Invalid
2790+
ident.name == kw::Empty
27912791
} else {
27922792
false
27932793
};

compiler/rustc_builtin_macros/src/llvm_asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn parse_inline_asm<'a>(
9393
})
9494
.unwrap_or(tts.len());
9595
let mut p = cx.new_parser_from_tts(tts.trees().skip(first_colon).collect());
96-
let mut asm = kw::Invalid;
96+
let mut asm = kw::Empty;
9797
let mut asm_str_style = None;
9898
let mut outputs = Vec::new();
9999
let mut inputs = Vec::new();

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
170170
// (after #67586 gets fixed).
171171
None
172172
} else {
173-
let name = kw::Invalid;
173+
let name = kw::Empty;
174174
let decl = &self.mir.local_decls[local];
175175
let dbg_var = if full_debug_info {
176176
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> {
204204
None
205205
} else {
206206
Some(match whole_local_var.or(fallback_var) {
207-
Some(var) if var.name != kw::Invalid => var.name.to_string(),
207+
Some(var) if var.name != kw::Empty => var.name.to_string(),
208208
_ => format!("{:?}", local),
209209
})
210210
};

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct Lifetime {
2828
pub span: Span,
2929

3030
/// Either "`'a`", referring to a named lifetime definition,
31-
/// or "``" (i.e., `kw::Invalid`), for elision placeholders.
31+
/// or "``" (i.e., `kw::Empty`), for elision placeholders.
3232
///
3333
/// HIR lowering inserts these placeholders in type paths that
3434
/// refer to type definitions needing lifetime parameters,

compiler/rustc_lint/src/builtin.rs

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

compiler/rustc_lint/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'tcx> LateContext<'tcx> {
728728

729729
/// Check if a `DefId`'s path matches the given absolute type path usage.
730730
///
731-
/// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`;
731+
/// Anonymous scopes such as `extern` imports are matched with `kw::Empty`;
732732
/// inherent `impl` blocks are matched with the name of the type.
733733
///
734734
/// Instead of using this method, it is often preferable to instead use

compiler/rustc_metadata/src/native_libs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
132132

133133
impl Collector<'tcx> {
134134
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLib) {
135-
if lib.name.as_ref().map(|&s| s == kw::Invalid).unwrap_or(false) {
135+
if lib.name.as_ref().map(|&s| s == kw::Empty).unwrap_or(false) {
136136
match span {
137137
Some(span) => {
138138
struct_span_err!(

compiler/rustc_middle/src/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<'hir> Map<'hir> {
379379
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
380380
self.body(id).params.iter().map(|arg| match arg.pat.kind {
381381
PatKind::Binding(_, _, ident, _) => ident,
382-
_ => Ident::new(kw::Invalid, rustc_span::DUMMY_SP),
382+
_ => Ident::new(kw::Empty, rustc_span::DUMMY_SP),
383383
})
384384
}
385385

compiler/rustc_middle/src/ty/print/pretty.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
14811481
// FIXME(eddyb) `name` should never be empty, but it
14821482
// currently is for `extern { ... }` "foreign modules".
14831483
let name = disambiguated_data.data.name();
1484-
if name != DefPathDataName::Named(kw::Invalid) {
1484+
if name != DefPathDataName::Named(kw::Empty) {
14851485
if !self.empty_path {
14861486
write!(self, "::")?;
14871487
}
@@ -1608,14 +1608,14 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
16081608

16091609
match *region {
16101610
ty::ReEarlyBound(ref data) => {
1611-
data.name != kw::Invalid && data.name != kw::UnderscoreLifetime
1611+
data.name != kw::Empty && data.name != kw::UnderscoreLifetime
16121612
}
16131613

16141614
ty::ReLateBound(_, ty::BoundRegion { kind: br })
16151615
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
16161616
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
16171617
if let ty::BrNamed(_, name) = br {
1618-
if name != kw::Invalid && name != kw::UnderscoreLifetime {
1618+
if name != kw::Empty && name != kw::UnderscoreLifetime {
16191619
return true;
16201620
}
16211621
}
@@ -1685,7 +1685,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
16851685
// `explain_region()` or `note_and_explain_region()`.
16861686
match *region {
16871687
ty::ReEarlyBound(ref data) => {
1688-
if data.name != kw::Invalid {
1688+
if data.name != kw::Empty {
16891689
p!(write("{}", data.name));
16901690
return Ok(self);
16911691
}
@@ -1694,7 +1694,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
16941694
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
16951695
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
16961696
if let ty::BrNamed(_, name) = br {
1697-
if name != kw::Invalid && name != kw::UnderscoreLifetime {
1697+
if name != kw::Empty && name != kw::UnderscoreLifetime {
16981698
p!(write("{}", name));
16991699
return Ok(self);
17001700
}

compiler/rustc_mir_build/src/build/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
854854
let mut mutability = Mutability::Not;
855855

856856
// FIXME(project-rfc-2229#8): Store more precise information
857-
let mut name = kw::Invalid;
857+
let mut name = kw::Empty;
858858
if let Some(Node::Binding(pat)) = tcx_hir.find(var_id) {
859859
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
860860
name = ident.name;

compiler/rustc_parse/src/parser/item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl<'a> Parser<'a> {
494494
let polarity = self.parse_polarity();
495495

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

compiler/rustc_passes/src/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
13851385

13861386
fn should_warn(&self, var: Variable) -> Option<String> {
13871387
let name = self.ir.variable_name(var);
1388-
if name == kw::Invalid {
1388+
if name == kw::Empty {
13891389
return None;
13901390
}
13911391
let name: &str = &name.as_str();

compiler/rustc_privacy/src/lib.rs

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

compiler/rustc_resolve/src/build_reduced_graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
342342
let field_names = vdata
343343
.fields()
344344
.iter()
345-
.map(|field| respan(field.span, field.ident.map_or(kw::Invalid, |ident| ident.name)))
345+
.map(|field| respan(field.span, field.ident.map_or(kw::Empty, |ident| ident.name)))
346346
.collect();
347347
self.insert_field_names(def_id, field_names);
348348
}
@@ -527,7 +527,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
527527
// HACK(eddyb) unclear how good this is, but keeping `$crate`
528528
// in `source` breaks `src/test/compile-fail/import-crate-var.rs`,
529529
// while the current crate doesn't have a valid `crate_name`.
530-
if crate_name != kw::Invalid {
530+
if crate_name != kw::Empty {
531531
// `crate_name` should not be interpreted as relative.
532532
module_path.push(Segment {
533533
ident: Ident { name: kw::PathRoot, span: source.ident.span },
@@ -656,7 +656,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
656656

657657
/// Constructs the reduced graph for one item.
658658
fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
659-
if matches!(item.kind, ItemKind::Mod(..)) && item.ident.name == kw::Invalid {
659+
if matches!(item.kind, ItemKind::Mod(..)) && item.ident.name == kw::Empty {
660660
// Fake crate root item from expand.
661661
return;
662662
}

compiler/rustc_resolve/src/def_collector.rs

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

compiler/rustc_resolve/src/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
16411641
}
16421642

16431643
// Record as bound if it's valid:
1644-
let ident_valid = ident.name != kw::Invalid;
1644+
let ident_valid = ident.name != kw::Empty;
16451645
if ident_valid {
16461646
bindings.last_mut().unwrap().1.insert(ident);
16471647
}

compiler/rustc_resolve/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1182,12 +1182,12 @@ impl<'a> Resolver<'a> {
11821182
) -> Resolver<'a> {
11831183
let root_local_def_id = LocalDefId { local_def_index: CRATE_DEF_INDEX };
11841184
let root_def_id = root_local_def_id.to_def_id();
1185-
let root_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Invalid);
1185+
let root_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Empty);
11861186
let graph_root = arenas.alloc_module(ModuleData {
11871187
no_implicit_prelude: session.contains_name(&krate.attrs, sym::no_implicit_prelude),
11881188
..ModuleData::new(None, root_module_kind, root_def_id, ExpnId::root(), krate.span)
11891189
});
1190-
let empty_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Invalid);
1190+
let empty_module_kind = ModuleKind::Def(DefKind::Mod, root_def_id, kw::Empty);
11911191
let empty_module = arenas.alloc_module(ModuleData {
11921192
no_implicit_prelude: true,
11931193
..ModuleData::new(
@@ -1797,7 +1797,7 @@ impl<'a> Resolver<'a> {
17971797
ribs: &[Rib<'a>],
17981798
) -> Option<LexicalScopeBinding<'a>> {
17991799
assert!(ns == TypeNS || ns == ValueNS);
1800-
if ident.name == kw::Invalid {
1800+
if ident.name == kw::Empty {
18011801
return Some(LexicalScopeBinding::Res(Res::Err));
18021802
}
18031803
let (general_span, normalized_span) = if ident.name == kw::SelfUpper {

compiler/rustc_resolve/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
160160
hygiene::update_dollar_crate_names(|ctxt| {
161161
let ident = Ident::new(kw::DollarCrate, DUMMY_SP.with_ctxt(ctxt));
162162
match self.resolve_crate_root(ident).kind {
163-
ModuleKind::Def(.., name) if name != kw::Invalid => name,
163+
ModuleKind::Def(.., name) if name != kw::Empty => name,
164164
_ => kw::Crate,
165165
}
166166
});

compiler/rustc_span/src/hygiene.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ pub fn decode_syntax_context<
10651065
parent: SyntaxContext::root(),
10661066
opaque: SyntaxContext::root(),
10671067
opaque_and_semitransparent: SyntaxContext::root(),
1068-
dollar_crate_name: kw::Invalid,
1068+
dollar_crate_name: kw::Empty,
10691069
});
10701070
let mut ctxts = outer_ctxts.lock();
10711071
let new_len = raw_id as usize + 1;
@@ -1092,7 +1092,7 @@ pub fn decode_syntax_context<
10921092
ctxt_data,
10931093
);
10941094
// Make sure nothing weird happening while `decode_data` was running
1095-
assert_eq!(dummy.dollar_crate_name, kw::Invalid);
1095+
assert_eq!(dummy.dollar_crate_name, kw::Empty);
10961096
});
10971097

10981098
Ok(new_ctxt)

compiler/rustc_span/src/symbol.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ symbols! {
2525
Keywords {
2626
// Special reserved identifiers used internally for elided lifetimes,
2727
// unnamed method parameters, crate root module, error recovery etc.
28-
Invalid: "",
28+
Empty: "",
2929
PathRoot: "{{root}}",
3030
DollarCrate: "$crate",
3131
Underscore: "_",
@@ -1273,7 +1273,7 @@ impl Ident {
12731273

12741274
#[inline]
12751275
pub fn invalid() -> Ident {
1276-
Ident::with_dummy_span(kw::Invalid)
1276+
Ident::with_dummy_span(kw::Empty)
12771277
}
12781278

12791279
/// Maps a string to an identifier with a dummy span.
@@ -1470,7 +1470,7 @@ impl Symbol {
14701470
}
14711471

14721472
pub fn is_empty(self) -> bool {
1473-
self == kw::Invalid
1473+
self == kw::Empty
14741474
}
14751475

14761476
/// This method is supposed to be used in error messages, so it's expected to be
@@ -1654,7 +1654,7 @@ impl Symbol {
16541654

16551655
/// Returns `true` if this symbol can be a raw identifier.
16561656
pub fn can_be_raw(self) -> bool {
1657-
self != kw::Invalid && self != kw::Underscore && !self.is_path_segment_keyword()
1657+
self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword()
16581658
}
16591659
}
16601660

compiler/rustc_typeck/src/check/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
883883
Ok(method)
884884
}
885885
Err(error) => {
886-
if segment.ident.name != kw::Invalid {
886+
if segment.ident.name != kw::Empty {
887887
self.report_extended_method_error(segment, span, args, rcvr_t, error);
888888
}
889889
Err(())
@@ -1547,7 +1547,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15471547
return field_ty;
15481548
}
15491549

1550-
if field.name == kw::Invalid {
1550+
if field.name == kw::Empty {
15511551
} else if self.method_exists(field, expr_t, expr.hir_id, true) {
15521552
self.ban_take_value_of_method(expr, expr_t, field);
15531553
} else if !expr_t.is_primitive_ty() {

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
914914
method::MethodError::PrivateMatch(kind, def_id, _) => Ok((kind, def_id)),
915915
_ => Err(ErrorReported),
916916
};
917-
if item_name.name != kw::Invalid {
917+
if item_name.name != kw::Empty {
918918
if let Some(mut e) = self.report_method_error(
919919
span,
920920
ty,

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], &'a [Ident]) {
941941
.iter()
942942
.enumerate()
943943
.map(|(i, ty)| {
944-
let mut name = self.1.get(i).map(|ident| ident.name).unwrap_or(kw::Invalid);
944+
let mut name = self.1.get(i).map(|ident| ident.name).unwrap_or(kw::Empty);
945945
if name.is_empty() {
946946
name = kw::Underscore;
947947
}
@@ -1000,7 +1000,7 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
10001000
.iter()
10011001
.map(|t| Argument {
10021002
type_: t.clean(cx),
1003-
name: names.next().map(|i| i.name).unwrap_or(kw::Invalid),
1003+
name: names.next().map(|i| i.name).unwrap_or(kw::Empty),
10041004
})
10051005
.collect(),
10061006
},

src/librustdoc/html/render/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2086,8 +2086,8 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
20862086
(true, false) => return Ordering::Greater,
20872087
}
20882088
}
2089-
let lhs = i1.name.unwrap_or(kw::Invalid).as_str();
2090-
let rhs = i2.name.unwrap_or(kw::Invalid).as_str();
2089+
let lhs = i1.name.unwrap_or(kw::Empty).as_str();
2090+
let rhs = i2.name.unwrap_or(kw::Empty).as_str();
20912091
compare_names(&lhs, &rhs)
20922092
}
20932093

@@ -4206,7 +4206,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache:
42064206
ty: \"{ty}\", \
42074207
relpath: \"{path}\"\
42084208
}};</script>",
4209-
name = it.name.unwrap_or(kw::Invalid),
4209+
name = it.name.unwrap_or(kw::Empty),
42104210
ty = it.type_(),
42114211
path = relpath
42124212
);

0 commit comments

Comments
 (0)