Skip to content

Commit 6cb28b6

Browse files
committed
Ident::with_empty_ctxt -> Ident::with_dummy_span
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
1 parent 67d6ce4 commit 6cb28b6

File tree

30 files changed

+77
-77
lines changed

30 files changed

+77
-77
lines changed

src/librustc/hir/lowering.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ impl<'a> LoweringContext<'a> {
12241224
P(hir::Path {
12251225
res,
12261226
segments: hir_vec![hir::PathSegment::from_ident(
1227-
Ident::with_empty_ctxt(kw::SelfUpper)
1227+
Ident::with_dummy_span(kw::SelfUpper)
12281228
)],
12291229
span: t.span,
12301230
}),
@@ -1558,7 +1558,7 @@ impl<'a> LoweringContext<'a> {
15581558

15591559
let (name, kind) = match name {
15601560
hir::LifetimeName::Underscore => (
1561-
hir::ParamName::Plain(Ident::with_empty_ctxt(kw::UnderscoreLifetime)),
1561+
hir::ParamName::Plain(Ident::with_dummy_span(kw::UnderscoreLifetime)),
15621562
hir::LifetimeParamKind::Elided,
15631563
),
15641564
hir::LifetimeName::Param(param_name) => (
@@ -2002,7 +2002,7 @@ impl<'a> LoweringContext<'a> {
20022002
bindings: hir_vec![
20032003
hir::TypeBinding {
20042004
hir_id: this.next_id(),
2005-
ident: Ident::with_empty_ctxt(FN_OUTPUT_NAME),
2005+
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
20062006
kind: hir::TypeBindingKind::Equality {
20072007
ty: output
20082008
.as_ref()
@@ -2394,7 +2394,7 @@ impl<'a> LoweringContext<'a> {
23942394
let future_params = P(hir::GenericArgs {
23952395
args: hir_vec![],
23962396
bindings: hir_vec![hir::TypeBinding {
2397-
ident: Ident::with_empty_ctxt(FN_OUTPUT_NAME),
2397+
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
23982398
kind: hir::TypeBindingKind::Equality {
23992399
ty: output_ty,
24002400
},

src/librustc/hir/lowering/expr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ impl LoweringContext<'_> {
552552

553553
// let mut pinned = <expr>;
554554
let expr = P(self.lower_expr(expr));
555-
let pinned_ident = Ident::with_empty_ctxt(sym::pinned);
555+
let pinned_ident = Ident::with_dummy_span(sym::pinned);
556556
let (pinned_pat, pinned_pat_hid) = self.pat_ident_binding_mode(
557557
span,
558558
pinned_ident,
@@ -593,7 +593,7 @@ impl LoweringContext<'_> {
593593
let loop_node_id = self.sess.next_node_id();
594594
let loop_hir_id = self.lower_node_id(loop_node_id);
595595
let ready_arm = {
596-
let x_ident = Ident::with_empty_ctxt(sym::result);
596+
let x_ident = Ident::with_dummy_span(sym::result);
597597
let (x_pat, x_pat_hid) = self.pat_ident(span, x_ident);
598598
let x_expr = P(self.expr_ident(span, x_ident, x_pat_hid));
599599
let ready_pat = self.pat_std_enum(
@@ -1070,9 +1070,9 @@ impl LoweringContext<'_> {
10701070
);
10711071
head.span = desugared_span;
10721072

1073-
let iter = Ident::with_empty_ctxt(sym::iter);
1073+
let iter = Ident::with_dummy_span(sym::iter);
10741074

1075-
let next_ident = Ident::with_empty_ctxt(sym::__next);
1075+
let next_ident = Ident::with_dummy_span(sym::__next);
10761076
let (next_pat, next_pat_hid) = self.pat_ident_binding_mode(
10771077
desugared_span,
10781078
next_ident,
@@ -1081,7 +1081,7 @@ impl LoweringContext<'_> {
10811081

10821082
// `::std::option::Option::Some(val) => __next = val`
10831083
let pat_arm = {
1084-
let val_ident = Ident::with_empty_ctxt(sym::val);
1084+
let val_ident = Ident::with_dummy_span(sym::val);
10851085
let (val_pat, val_pat_hid) = self.pat_ident(pat.span, val_ident);
10861086
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat_hid));
10871087
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat_hid));
@@ -1247,7 +1247,7 @@ impl LoweringContext<'_> {
12471247

12481248
// `Ok(val) => #[allow(unreachable_code)] val,`
12491249
let ok_arm = {
1250-
let val_ident = Ident::with_empty_ctxt(sym::val);
1250+
let val_ident = Ident::with_dummy_span(sym::val);
12511251
let (val_pat, val_pat_nid) = self.pat_ident(span, val_ident);
12521252
let val_expr = P(self.expr_ident_with_attrs(
12531253
span,
@@ -1263,7 +1263,7 @@ impl LoweringContext<'_> {
12631263
// `Err(err) => #[allow(unreachable_code)]
12641264
// return Try::from_error(From::from(err)),`
12651265
let err_arm = {
1266-
let err_ident = Ident::with_empty_ctxt(sym::err);
1266+
let err_ident = Ident::with_dummy_span(sym::err);
12671267
let (err_local, err_local_nid) = self.pat_ident(try_span, err_ident);
12681268
let from_expr = {
12691269
let from_path = &[sym::convert, sym::From, sym::from];

src/librustc/hir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl ParamName {
202202
match *self {
203203
ParamName::Plain(ident) => ident,
204204
ParamName::Fresh(_) |
205-
ParamName::Error => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
205+
ParamName::Error => Ident::with_dummy_span(kw::UnderscoreLifetime),
206206
}
207207
}
208208

@@ -237,8 +237,8 @@ impl LifetimeName {
237237
pub fn ident(&self) -> Ident {
238238
match *self {
239239
LifetimeName::Implicit | LifetimeName::Error => Ident::invalid(),
240-
LifetimeName::Underscore => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
241-
LifetimeName::Static => Ident::with_empty_ctxt(kw::StaticLifetime),
240+
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
241+
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
242242
LifetimeName::Param(param_name) => param_name.ident(),
243243
}
244244
}

src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ impl<'a> State<'a> {
14571457
}
14581458

14591459
pub fn print_name(&mut self, name: ast::Name) {
1460-
self.print_ident(ast::Ident::with_empty_ctxt(name))
1460+
self.print_ident(ast::Ident::with_dummy_span(name))
14611461
}
14621462

14631463
pub fn print_for_decl(&mut self, loc: &hir::Local, coll: &hir::Expr) {

src/librustc/traits/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
14171417
projection_ty: ty::ProjectionTy::from_ref_and_name(
14181418
tcx,
14191419
trait_ref,
1420-
Ident::with_empty_ctxt(FN_OUTPUT_NAME),
1420+
Ident::with_dummy_span(FN_OUTPUT_NAME),
14211421
),
14221422
ty: ret_type
14231423
}

src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ impl RustcDefaultCalls {
678678

679679
let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| {
680680
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
681-
path: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)),
681+
path: ast::Path::from_ident(ast::Ident::with_dummy_span(name)),
682682
node: ast::MetaItemKind::Word,
683683
span: DUMMY_SP,
684684
});

src/librustc_metadata/decoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,15 @@ impl<'a, 'tcx> CrateMetadata {
569569

570570
ty::VariantDef::new(
571571
tcx,
572-
Ident::with_empty_ctxt(self.item_name(index)),
572+
Ident::with_dummy_span(self.item_name(index)),
573573
variant_did,
574574
ctor_did,
575575
data.discr,
576576
item.children.decode(self).map(|index| {
577577
let f = self.entry(index);
578578
ty::FieldDef {
579579
did: self.local_def_id(index),
580-
ident: Ident::with_empty_ctxt(self.item_name(index)),
580+
ident: Ident::with_dummy_span(self.item_name(index)),
581581
vis: f.visibility.decode(self)
582582
}
583583
}).collect(),
@@ -741,7 +741,7 @@ impl<'a, 'tcx> CrateMetadata {
741741
DefKind::Macro(ext.macro_kind()),
742742
self.local_def_id(DefIndex::from_proc_macro_index(id)),
743743
);
744-
let ident = Ident::with_empty_ctxt(name);
744+
let ident = Ident::with_dummy_span(name);
745745
callback(def::Export {
746746
ident: ident,
747747
res: res,
@@ -783,7 +783,7 @@ impl<'a, 'tcx> CrateMetadata {
783783
if let Some(kind) = self.def_kind(child_index) {
784784
callback(def::Export {
785785
res: Res::Def(kind, self.local_def_id(child_index)),
786-
ident: Ident::with_empty_ctxt(self.item_name(child_index)),
786+
ident: Ident::with_dummy_span(self.item_name(child_index)),
787787
vis: self.get_visibility(child_index),
788788
span: self.entry(child_index).span.decode((self, sess)),
789789
});

src/librustc_resolve/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl<'a> Resolver<'a> {
595595
where FilterFn: Fn(Res) -> bool
596596
{
597597
let mut suggestions = self.lookup_import_candidates_from_module(
598-
lookup_ident, namespace, self.graph_root, Ident::with_empty_ctxt(kw::Crate), &filter_fn
598+
lookup_ident, namespace, self.graph_root, Ident::with_dummy_span(kw::Crate), &filter_fn
599599
);
600600

601601
if lookup_ident.span.rust_2018() {

src/librustc_resolve/late.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
352352
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
353353
}
354354
TyKind::ImplicitSelf => {
355-
let self_ty = Ident::with_empty_ctxt(kw::SelfUpper);
355+
let self_ty = Ident::with_dummy_span(kw::SelfUpper);
356356
let res = self.resolve_ident_in_lexical_scope(self_ty, TypeNS, Some(ty.id), ty.span)
357357
.map_or(Res::Err, |d| d.res());
358358
self.r.record_partial_res(ty.id, PartialRes::new(res));
@@ -442,7 +442,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
442442
GenericParamKind::Type { ref default, .. } => {
443443
found_default |= default.is_some();
444444
if found_default {
445-
Some((Ident::with_empty_ctxt(param.ident.name), Res::Err))
445+
Some((Ident::with_dummy_span(param.ident.name), Res::Err))
446446
} else {
447447
None
448448
}
@@ -459,7 +459,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
459459
false
460460
}
461461
})
462-
.map(|param| (Ident::with_empty_ctxt(param.ident.name), Res::Err)));
462+
.map(|param| (Ident::with_dummy_span(param.ident.name), Res::Err)));
463463

464464
for param in &generics.params {
465465
match param.kind {
@@ -476,7 +476,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
476476
}
477477

478478
// Allow all following defaults to refer to this type parameter.
479-
default_ban_rib.bindings.remove(&Ident::with_empty_ctxt(param.ident.name));
479+
default_ban_rib.bindings.remove(&Ident::with_dummy_span(param.ident.name));
480480
}
481481
GenericParamKind::Const { ref ty } => {
482482
self.ribs[TypeNS].push(const_ty_param_ban_rib);
@@ -965,7 +965,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
965965
let mut self_type_rib = Rib::new(NormalRibKind);
966966

967967
// Plain insert (no renaming, since types are not currently hygienic)
968-
self_type_rib.bindings.insert(Ident::with_empty_ctxt(kw::SelfUpper), self_res);
968+
self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), self_res);
969969
self.ribs[TypeNS].push(self_type_rib);
970970
f(self);
971971
self.ribs[TypeNS].pop();
@@ -976,7 +976,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
976976
{
977977
let self_res = Res::SelfCtor(impl_id);
978978
let mut self_type_rib = Rib::new(NormalRibKind);
979-
self_type_rib.bindings.insert(Ident::with_empty_ctxt(kw::SelfUpper), self_res);
979+
self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), self_res);
980980
self.ribs[ValueNS].push(self_type_rib);
981981
f(self);
982982
self.ribs[ValueNS].pop();
@@ -1476,7 +1476,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
14761476
self.r.trait_map.insert(id, traits);
14771477
}
14781478

1479-
let mut std_path = vec![Segment::from_ident(Ident::with_empty_ctxt(sym::std))];
1479+
let mut std_path = vec![Segment::from_ident(Ident::with_dummy_span(sym::std))];
14801480
std_path.extend(path);
14811481
if self.r.primitive_type_table.primitive_types.contains_key(&path[0].ident.name) {
14821482
let cl = CrateLint::No;
@@ -1507,7 +1507,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
15071507

15081508
fn self_type_is_available(&mut self, span: Span) -> bool {
15091509
let binding = self.resolve_ident_in_lexical_scope(
1510-
Ident::with_empty_ctxt(kw::SelfUpper),
1510+
Ident::with_dummy_span(kw::SelfUpper),
15111511
TypeNS,
15121512
None,
15131513
span,

src/librustc_resolve/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,11 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
985985
} else {
986986
kw::Crate
987987
};
988-
let segments = iter::once(Ident::with_empty_ctxt(root))
988+
let segments = iter::once(Ident::with_dummy_span(root))
989989
.chain(
990990
crate_root.into_iter()
991991
.chain(components.iter().cloned())
992-
.map(Ident::with_empty_ctxt)
992+
.map(Ident::with_dummy_span)
993993
).map(|i| self.new_ast_path_segment(i)).collect::<Vec<_>>();
994994

995995
let path = ast::Path {
@@ -1060,11 +1060,11 @@ impl<'a> Resolver<'a> {
10601060
.collect();
10611061

10621062
if !attr::contains_name(&krate.attrs, sym::no_core) {
1063-
extern_prelude.insert(Ident::with_empty_ctxt(sym::core), Default::default());
1063+
extern_prelude.insert(Ident::with_dummy_span(sym::core), Default::default());
10641064
if !attr::contains_name(&krate.attrs, sym::no_std) {
1065-
extern_prelude.insert(Ident::with_empty_ctxt(sym::std), Default::default());
1065+
extern_prelude.insert(Ident::with_dummy_span(sym::std), Default::default());
10661066
if session.rust_2018() {
1067-
extern_prelude.insert(Ident::with_empty_ctxt(sym::meta), Default::default());
1067+
extern_prelude.insert(Ident::with_dummy_span(sym::meta), Default::default());
10681068
}
10691069
}
10701070
}
@@ -2624,7 +2624,7 @@ impl<'a> Resolver<'a> {
26242624
let path = if path_str.starts_with("::") {
26252625
ast::Path {
26262626
span,
2627-
segments: iter::once(Ident::with_empty_ctxt(kw::PathRoot))
2627+
segments: iter::once(Ident::with_dummy_span(kw::PathRoot))
26282628
.chain({
26292629
path_str.split("::").skip(1).map(Ident::from_str)
26302630
})
@@ -2713,7 +2713,7 @@ fn module_to_string(module: Module<'_>) -> Option<String> {
27132713
fn collect_mod(names: &mut Vec<Ident>, module: Module<'_>) {
27142714
if let ModuleKind::Def(.., name) = module.kind {
27152715
if let Some(parent) = module.parent {
2716-
names.push(Ident::with_empty_ctxt(name));
2716+
names.push(Ident::with_dummy_span(name));
27172717
collect_mod(names, parent);
27182718
}
27192719
} else {

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29432943
(PlaceOp::Index, false) => (self.tcx.lang_items().index_trait(), sym::index),
29442944
(PlaceOp::Index, true) => (self.tcx.lang_items().index_mut_trait(), sym::index_mut),
29452945
};
2946-
(tr, ast::Ident::with_empty_ctxt(name))
2946+
(tr, ast::Ident::with_dummy_span(name))
29472947
}
29482948

29492949
fn try_overloaded_place_op(&self,

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ impl Attributes {
930930
if attr.check_name(sym::enable) {
931931
if let Some(feat) = attr.value_str() {
932932
let meta = attr::mk_name_value_item_str(
933-
Ident::with_empty_ctxt(sym::target_feature), feat, DUMMY_SP
933+
Ident::with_dummy_span(sym::target_feature), feat, DUMMY_SP
934934
);
935935
if let Ok(feat_cfg) = Cfg::parse(&meta) {
936936
cfg &= feat_cfg;

src/libsyntax/attr/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl Attribute {
327327
if self.is_sugared_doc {
328328
let comment = self.value_str().unwrap();
329329
let meta = mk_name_value_item_str(
330-
Ident::with_empty_ctxt(sym::doc),
330+
Ident::with_dummy_span(sym::doc),
331331
Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())),
332332
DUMMY_SP,
333333
);
@@ -412,7 +412,7 @@ pub fn mk_sugared_doc_attr(text: Symbol, span: Span) -> Attribute {
412412
Attribute {
413413
id: mk_attr_id(),
414414
style,
415-
path: Path::from_ident(Ident::with_empty_ctxt(sym::doc).with_span_pos(span)),
415+
path: Path::from_ident(Ident::with_dummy_span(sym::doc).with_span_pos(span)),
416416
tokens: MetaItemKind::NameValue(lit).tokens(span),
417417
is_sugared_doc: true,
418418
span,

src/libsyntax/diagnostics/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt<'_>,
172172
(descriptions.len(), ecx.expr_vec(span, descriptions))
173173
});
174174

175-
let static_ = ecx.lifetime(span, Ident::with_empty_ctxt(kw::StaticLifetime));
175+
let static_ = ecx.lifetime(span, Ident::with_dummy_span(kw::StaticLifetime));
176176
let ty_str = ecx.ty_rptr(
177177
span,
178178
ecx.ty_ident(span, ecx.ident_of("str")),

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ impl<'a> ExtCtxt<'a> {
872872
pub fn std_path(&self, components: &[Symbol]) -> Vec<ast::Ident> {
873873
let def_site = DUMMY_SP.apply_mark(self.current_expansion.id);
874874
iter::once(Ident::new(kw::DollarCrate, def_site))
875-
.chain(components.iter().map(|&s| Ident::with_empty_ctxt(s)))
875+
.chain(components.iter().map(|&s| Ident::with_dummy_span(s)))
876876
.collect()
877877
}
878878
pub fn name_of(&self, st: &str) -> ast::Name {

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'a> ExtCtxt<'a> {
340340
self.expr_path(self.path_ident(span, id))
341341
}
342342
pub fn expr_self(&self, span: Span) -> P<ast::Expr> {
343-
self.expr_ident(span, Ident::with_empty_ctxt(kw::SelfLower))
343+
self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower))
344344
}
345345

346346
pub fn expr_binary(&self, sp: Span, op: ast::BinOpKind,

0 commit comments

Comments
 (0)