Skip to content

Commit c389a39

Browse files
committed
Eliminate unnecessary Ident::with_empty_ctxts
1 parent 59a3821 commit c389a39

File tree

18 files changed

+33
-33
lines changed

18 files changed

+33
-33
lines changed

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ impl<'a> LoweringContext<'a> {
16141614
trace!("registering existential type with id {:#?}", exist_ty_id);
16151615
let exist_ty_item = hir::Item {
16161616
hir_id: exist_ty_id,
1617-
ident: Ident::with_empty_ctxt(kw::Invalid),
1617+
ident: Ident::invalid(),
16181618
attrs: Default::default(),
16191619
node: exist_ty_item_kind,
16201620
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),

src/librustc/hir/map/def_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
138138
// information we encapsulate into, the better
139139
let def_data = match i.node {
140140
ItemKind::Impl(..) => DefPathData::Impl,
141-
ItemKind::Mod(..) if i.ident == Ident::with_empty_ctxt(kw::Invalid) => {
141+
ItemKind::Mod(..) if i.ident.name == kw::Invalid => {
142142
return visit::walk_item(self, i);
143143
}
144144
ItemKind::Mod(..) | ItemKind::Trait(..) | ItemKind::TraitAlias(..) |

src/librustc/hir/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ pub enum LifetimeName {
234234
impl LifetimeName {
235235
pub fn ident(&self) -> Ident {
236236
match *self {
237-
LifetimeName::Implicit => Ident::with_empty_ctxt(kw::Invalid),
238-
LifetimeName::Error => Ident::with_empty_ctxt(kw::Invalid),
237+
LifetimeName::Implicit | LifetimeName::Error => Ident::invalid(),
239238
LifetimeName::Underscore => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
240239
LifetimeName::Static => Ident::with_empty_ctxt(kw::StaticLifetime),
241240
LifetimeName::Param(param_name) => param_name.ident(),

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16021602
} {
16031603
debug!("id = {:?} span = {:?} name = {:?}", id, span, name);
16041604

1605-
if name == ast::Ident::with_empty_ctxt(kw::UnderscoreLifetime) {
1605+
if name.name == kw::UnderscoreLifetime {
16061606
continue;
16071607
}
16081608

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl<'a> Resolver<'a> {
420420

421421
ItemKind::GlobalAsm(..) => {}
422422

423-
ItemKind::Mod(..) if ident == Ident::with_empty_ctxt(kw::Invalid) => {} // Crate root
423+
ItemKind::Mod(..) if ident.name == kw::Invalid => {} // Crate root
424424

425425
ItemKind::Mod(..) => {
426426
let def_id = self.definitions.local_def_id(item.id);

src/librustc_resolve/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
460460
(Some(fst), _) if fst.ident.span.rust_2018() &&
461461
!fst.ident.is_path_segment_keyword() => {
462462
// Insert a placeholder that's later replaced by `self`/`super`/etc.
463-
path.insert(0, Segment::from_ident(Ident::with_empty_ctxt(kw::Invalid)));
463+
path.insert(0, Segment::from_ident(Ident::invalid()));
464464
}
465465
_ => return None,
466466
}

src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4669,7 +4669,7 @@ impl<'a> Resolver<'a> {
46694669
{
46704670
let mut candidates = Vec::new();
46714671
let mut seen_modules = FxHashSet::default();
4672-
let not_local_module = crate_name != Ident::with_empty_ctxt(kw::Crate);
4672+
let not_local_module = crate_name.name != kw::Crate;
46734673
let mut worklist = vec![(start_module, Vec::<ast::PathSegment>::new(), not_local_module)];
46744674

46754675
while let Some((in_module,

src/librustc_resolve/resolve_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
992992
// HACK(eddyb) `lint_if_path_starts_with_module` needs at least
993993
// 2 segments, so the `resolve_path` above won't trigger it.
994994
let mut full_path = directive.module_path.clone();
995-
full_path.push(Segment::from_ident(Ident::with_empty_ctxt(kw::Invalid)));
995+
full_path.push(Segment::from_ident(Ident::invalid()));
996996
self.lint_if_path_starts_with_module(
997997
directive.crate_lint(),
998998
&full_path,

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
11751175
vis: ast::Visibility, vp: P<ast::UseTree>) -> P<ast::Item> {
11761176
P(ast::Item {
11771177
id: ast::DUMMY_NODE_ID,
1178-
ident: Ident::with_empty_ctxt(kw::Invalid),
1178+
ident: Ident::invalid(),
11791179
attrs: vec![],
11801180
node: ast::ItemKind::Use(vp),
11811181
vis,

src/libsyntax/ext/expand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
271271
attrs: krate.attrs,
272272
span: krate.span,
273273
node: ast::ItemKind::Mod(krate.module),
274-
ident: Ident::with_empty_ctxt(kw::Invalid),
274+
ident: Ident::invalid(),
275275
id: ast::DUMMY_NODE_ID,
276276
vis: respan(krate.span.shrink_to_lo(), ast::VisibilityKind::Public),
277277
tokens: None,
@@ -708,7 +708,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
708708
};
709709
let path = &mac.node.path;
710710

711-
let ident = ident.unwrap_or_else(|| Ident::with_empty_ctxt(kw::Invalid));
711+
let ident = ident.unwrap_or_else(|| Ident::invalid());
712712
let validate_and_set_expn_info = |this: &mut Self, // arg instead of capture
713713
def_site_span: Option<Span>,
714714
allow_internal_unstable,
@@ -929,7 +929,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
929929
invoc.expansion_data.mark.set_expn_info(expn_info);
930930
let span = span.with_ctxt(self.cx.backtrace());
931931
let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this
932-
path: Path::from_ident(Ident::with_empty_ctxt(kw::Invalid)),
932+
path: Path::from_ident(Ident::invalid()),
933933
span: DUMMY_SP,
934934
node: ast::MetaItemKind::Word,
935935
};
@@ -1338,7 +1338,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13381338
})
13391339
}
13401340
ast::ItemKind::Mod(ast::Mod { inner, .. }) => {
1341-
if item.ident == Ident::with_empty_ctxt(kw::Invalid) {
1341+
if item.ident == Ident::invalid() {
13421342
return noop_flat_map_item(item, self);
13431343
}
13441344

0 commit comments

Comments
 (0)