Skip to content

Commit 2fd765c

Browse files
authored
Rollup merge of #89990 - petrochenkov:idempty, r=wesleywiser
rustc_span: `Ident::invalid` -> `Ident::empty` The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s as well.
2 parents 874f19f + a680833 commit 2fd765c

File tree

20 files changed

+34
-35
lines changed

20 files changed

+34
-35
lines changed

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl NestedMetaItem {
6262
self.meta_item().and_then(|meta_item| meta_item.ident())
6363
}
6464
pub fn name_or_empty(&self) -> Symbol {
65-
self.ident().unwrap_or_else(Ident::invalid).name
65+
self.ident().unwrap_or_else(Ident::empty).name
6666
}
6767

6868
/// Gets the string value if `self` is a `MetaItem` and the `MetaItem` is a
@@ -131,7 +131,7 @@ impl Attribute {
131131
}
132132
}
133133
pub fn name_or_empty(&self) -> Symbol {
134-
self.ident().unwrap_or_else(Ident::invalid).name
134+
self.ident().unwrap_or_else(Ident::empty).name
135135
}
136136

137137
pub fn value_str(&self) -> Option<Symbol> {
@@ -166,7 +166,7 @@ impl MetaItem {
166166
if self.path.segments.len() == 1 { Some(self.path.segments[0].ident) } else { None }
167167
}
168168
pub fn name_or_empty(&self) -> Symbol {
169-
self.ident().unwrap_or_else(Ident::invalid).name
169+
self.ident().unwrap_or_else(Ident::empty).name
170170
}
171171

172172
// Example:

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
10601060
let item_vis =
10611061
Visibility { kind: VisibilityKind::Public, span: span.shrink_to_lo(), tokens: None };
10621062
let item = P(Item {
1063-
ident: Ident::invalid(),
1063+
ident: Ident::empty(),
10641064
attrs,
10651065
id: DUMMY_NODE_ID,
10661066
vis: item_vis,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14351435
trace!("registering opaque type with id {:#?}", opaque_ty_id);
14361436
let opaque_ty_item = hir::Item {
14371437
def_id: opaque_ty_id,
1438-
ident: Ident::invalid(),
1438+
ident: Ident::empty(),
14391439
kind: opaque_ty_item_kind,
14401440
vis: respan(self.lower_span(span.shrink_to_lo()), hir::VisibilityKind::Inherited),
14411441
span: self.lower_span(opaque_ty_span),

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ pub fn expand_global_asm<'cx>(
812812
Ok(args) => {
813813
if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
814814
MacEager::items(smallvec![P(ast::Item {
815-
ident: Ident::invalid(),
815+
ident: Ident::empty(),
816816
attrs: Vec::new(),
817817
id: ast::DUMMY_NODE_ID,
818818
kind: ast::ItemKind::GlobalAsm(inline_asm),

compiler/rustc_builtin_macros/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl MultiItemModifier for Expander {
8585
fn dummy_annotatable() -> Annotatable {
8686
Annotatable::GenericParam(ast::GenericParam {
8787
id: ast::DUMMY_NODE_ID,
88-
ident: Ident::invalid(),
88+
ident: Ident::empty(),
8989
attrs: Default::default(),
9090
bounds: Default::default(),
9191
is_placeholder: false,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl<'a> TraitDef<'a> {
724724

725725
cx.item(
726726
self.span,
727-
Ident::invalid(),
727+
Ident::empty(),
728728
a,
729729
ast::ItemKind::Impl(Box::new(ast::ImplKind {
730730
unsafety,

compiler/rustc_builtin_macros/src/deriving/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn inject_impl_of_structural_trait(
178178

179179
let newitem = cx.item(
180180
span,
181-
Ident::invalid(),
181+
Ident::empty(),
182182
attrs,
183183
ItemKind::Impl(Box::new(ImplKind {
184184
unsafety: ast::Unsafe::No,

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn inject(
7777

7878
let use_item = cx.item(
7979
span,
80-
Ident::invalid(),
80+
Ident::empty(),
8181
vec![cx.attribute(cx.meta_word(span, sym::prelude_import))],
8282
ast::ItemKind::Use(ast::UseTree {
8383
prefix: cx.path(span, import_path),

compiler/rustc_expand/src/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
383383
Unsafe::No,
384384
ModKind::Loaded(krate.items, Inline::Yes, krate.span)
385385
),
386-
ident: Ident::invalid(),
386+
ident: Ident::empty(),
387387
id: ast::DUMMY_NODE_ID,
388388
vis: ast::Visibility {
389389
span: krate.span.shrink_to_lo(),
@@ -1426,7 +1426,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14261426
_ => unreachable!(),
14271427
})
14281428
}
1429-
ast::ItemKind::Mod(_, ref mut mod_kind) if ident != Ident::invalid() => {
1429+
ast::ItemKind::Mod(_, ref mut mod_kind) if ident != Ident::empty() => {
14301430
let (file_path, dir_path, dir_ownership) = match mod_kind {
14311431
ModKind::Loaded(_, inline, _) => {
14321432
// Inline `mod foo { ... }`, but we still need to push directories.
@@ -1508,7 +1508,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15081508
_ => {
15091509
item.attrs = attrs;
15101510
// The crate root is special - don't assign an ID to it.
1511-
if !(matches!(item.kind, ast::ItemKind::Mod(..)) && ident == Ident::invalid()) {
1511+
if !(matches!(item.kind, ast::ItemKind::Mod(..)) && ident == Ident::empty()) {
15121512
assign_id!(self, &mut item.id, || noop_flat_map_item(item, self))
15131513
} else {
15141514
noop_flat_map_item(item, self)

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn parse_tree(
204204
pprust::token_to_string(&token),
205205
);
206206
sess.span_diagnostic.span_err(token.span, &msg);
207-
TokenTree::MetaVar(token.span, Ident::invalid())
207+
TokenTree::MetaVar(token.span, Ident::empty())
208208
}
209209

210210
// There are no more tokens. Just return the `$` we already have.

0 commit comments

Comments
 (0)