Ident::with_empty_ctxt -> Ident::with_dummy_span

`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
This commit is contained in:
Vadim Petrochenkov 2019-08-11 02:20:18 +03:00
parent 67d6ce4206
commit 6cb28b6617
30 changed files with 77 additions and 77 deletions

View File

@ -1224,7 +1224,7 @@ impl<'a> LoweringContext<'a> {
P(hir::Path {
res,
segments: hir_vec![hir::PathSegment::from_ident(
Ident::with_empty_ctxt(kw::SelfUpper)
Ident::with_dummy_span(kw::SelfUpper)
)],
span: t.span,
}),
@ -1558,7 +1558,7 @@ impl<'a> LoweringContext<'a> {
let (name, kind) = match name {
hir::LifetimeName::Underscore => (
hir::ParamName::Plain(Ident::with_empty_ctxt(kw::UnderscoreLifetime)),
hir::ParamName::Plain(Ident::with_dummy_span(kw::UnderscoreLifetime)),
hir::LifetimeParamKind::Elided,
),
hir::LifetimeName::Param(param_name) => (
@ -2002,7 +2002,7 @@ impl<'a> LoweringContext<'a> {
bindings: hir_vec![
hir::TypeBinding {
hir_id: this.next_id(),
ident: Ident::with_empty_ctxt(FN_OUTPUT_NAME),
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
kind: hir::TypeBindingKind::Equality {
ty: output
.as_ref()
@ -2394,7 +2394,7 @@ impl<'a> LoweringContext<'a> {
let future_params = P(hir::GenericArgs {
args: hir_vec![],
bindings: hir_vec![hir::TypeBinding {
ident: Ident::with_empty_ctxt(FN_OUTPUT_NAME),
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
kind: hir::TypeBindingKind::Equality {
ty: output_ty,
},

View File

@ -552,7 +552,7 @@ impl LoweringContext<'_> {
// let mut pinned = <expr>;
let expr = P(self.lower_expr(expr));
let pinned_ident = Ident::with_empty_ctxt(sym::pinned);
let pinned_ident = Ident::with_dummy_span(sym::pinned);
let (pinned_pat, pinned_pat_hid) = self.pat_ident_binding_mode(
span,
pinned_ident,
@ -593,7 +593,7 @@ impl LoweringContext<'_> {
let loop_node_id = self.sess.next_node_id();
let loop_hir_id = self.lower_node_id(loop_node_id);
let ready_arm = {
let x_ident = Ident::with_empty_ctxt(sym::result);
let x_ident = Ident::with_dummy_span(sym::result);
let (x_pat, x_pat_hid) = self.pat_ident(span, x_ident);
let x_expr = P(self.expr_ident(span, x_ident, x_pat_hid));
let ready_pat = self.pat_std_enum(
@ -1070,9 +1070,9 @@ impl LoweringContext<'_> {
);
head.span = desugared_span;
let iter = Ident::with_empty_ctxt(sym::iter);
let iter = Ident::with_dummy_span(sym::iter);
let next_ident = Ident::with_empty_ctxt(sym::__next);
let next_ident = Ident::with_dummy_span(sym::__next);
let (next_pat, next_pat_hid) = self.pat_ident_binding_mode(
desugared_span,
next_ident,
@ -1081,7 +1081,7 @@ impl LoweringContext<'_> {
// `::std::option::Option::Some(val) => __next = val`
let pat_arm = {
let val_ident = Ident::with_empty_ctxt(sym::val);
let val_ident = Ident::with_dummy_span(sym::val);
let (val_pat, val_pat_hid) = self.pat_ident(pat.span, val_ident);
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat_hid));
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat_hid));
@ -1247,7 +1247,7 @@ impl LoweringContext<'_> {
// `Ok(val) => #[allow(unreachable_code)] val,`
let ok_arm = {
let val_ident = Ident::with_empty_ctxt(sym::val);
let val_ident = Ident::with_dummy_span(sym::val);
let (val_pat, val_pat_nid) = self.pat_ident(span, val_ident);
let val_expr = P(self.expr_ident_with_attrs(
span,
@ -1263,7 +1263,7 @@ impl LoweringContext<'_> {
// `Err(err) => #[allow(unreachable_code)]
// return Try::from_error(From::from(err)),`
let err_arm = {
let err_ident = Ident::with_empty_ctxt(sym::err);
let err_ident = Ident::with_dummy_span(sym::err);
let (err_local, err_local_nid) = self.pat_ident(try_span, err_ident);
let from_expr = {
let from_path = &[sym::convert, sym::From, sym::from];

View File

@ -202,7 +202,7 @@ impl ParamName {
match *self {
ParamName::Plain(ident) => ident,
ParamName::Fresh(_) |
ParamName::Error => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
ParamName::Error => Ident::with_dummy_span(kw::UnderscoreLifetime),
}
}
@ -237,8 +237,8 @@ impl LifetimeName {
pub fn ident(&self) -> Ident {
match *self {
LifetimeName::Implicit | LifetimeName::Error => Ident::invalid(),
LifetimeName::Underscore => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
LifetimeName::Static => Ident::with_empty_ctxt(kw::StaticLifetime),
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
LifetimeName::Param(param_name) => param_name.ident(),
}
}

View File

@ -1457,7 +1457,7 @@ impl<'a> State<'a> {
}
pub fn print_name(&mut self, name: ast::Name) {
self.print_ident(ast::Ident::with_empty_ctxt(name))
self.print_ident(ast::Ident::with_dummy_span(name))
}
pub fn print_for_decl(&mut self, loc: &hir::Local, coll: &hir::Expr) {

View File

@ -1417,7 +1417,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
projection_ty: ty::ProjectionTy::from_ref_and_name(
tcx,
trait_ref,
Ident::with_empty_ctxt(FN_OUTPUT_NAME),
Ident::with_dummy_span(FN_OUTPUT_NAME),
),
ty: ret_type
}

View File

@ -678,7 +678,7 @@ impl RustcDefaultCalls {
let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| {
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
path: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)),
path: ast::Path::from_ident(ast::Ident::with_dummy_span(name)),
node: ast::MetaItemKind::Word,
span: DUMMY_SP,
});

View File

@ -569,7 +569,7 @@ impl<'a, 'tcx> CrateMetadata {
ty::VariantDef::new(
tcx,
Ident::with_empty_ctxt(self.item_name(index)),
Ident::with_dummy_span(self.item_name(index)),
variant_did,
ctor_did,
data.discr,
@ -577,7 +577,7 @@ impl<'a, 'tcx> CrateMetadata {
let f = self.entry(index);
ty::FieldDef {
did: self.local_def_id(index),
ident: Ident::with_empty_ctxt(self.item_name(index)),
ident: Ident::with_dummy_span(self.item_name(index)),
vis: f.visibility.decode(self)
}
}).collect(),
@ -741,7 +741,7 @@ impl<'a, 'tcx> CrateMetadata {
DefKind::Macro(ext.macro_kind()),
self.local_def_id(DefIndex::from_proc_macro_index(id)),
);
let ident = Ident::with_empty_ctxt(name);
let ident = Ident::with_dummy_span(name);
callback(def::Export {
ident: ident,
res: res,
@ -783,7 +783,7 @@ impl<'a, 'tcx> CrateMetadata {
if let Some(kind) = self.def_kind(child_index) {
callback(def::Export {
res: Res::Def(kind, self.local_def_id(child_index)),
ident: Ident::with_empty_ctxt(self.item_name(child_index)),
ident: Ident::with_dummy_span(self.item_name(child_index)),
vis: self.get_visibility(child_index),
span: self.entry(child_index).span.decode((self, sess)),
});

View File

@ -595,7 +595,7 @@ impl<'a> Resolver<'a> {
where FilterFn: Fn(Res) -> bool
{
let mut suggestions = self.lookup_import_candidates_from_module(
lookup_ident, namespace, self.graph_root, Ident::with_empty_ctxt(kw::Crate), &filter_fn
lookup_ident, namespace, self.graph_root, Ident::with_dummy_span(kw::Crate), &filter_fn
);
if lookup_ident.span.rust_2018() {

View File

@ -352,7 +352,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
}
TyKind::ImplicitSelf => {
let self_ty = Ident::with_empty_ctxt(kw::SelfUpper);
let self_ty = Ident::with_dummy_span(kw::SelfUpper);
let res = self.resolve_ident_in_lexical_scope(self_ty, TypeNS, Some(ty.id), ty.span)
.map_or(Res::Err, |d| d.res());
self.r.record_partial_res(ty.id, PartialRes::new(res));
@ -442,7 +442,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
GenericParamKind::Type { ref default, .. } => {
found_default |= default.is_some();
if found_default {
Some((Ident::with_empty_ctxt(param.ident.name), Res::Err))
Some((Ident::with_dummy_span(param.ident.name), Res::Err))
} else {
None
}
@ -459,7 +459,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
false
}
})
.map(|param| (Ident::with_empty_ctxt(param.ident.name), Res::Err)));
.map(|param| (Ident::with_dummy_span(param.ident.name), Res::Err)));
for param in &generics.params {
match param.kind {
@ -476,7 +476,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
}
// Allow all following defaults to refer to this type parameter.
default_ban_rib.bindings.remove(&Ident::with_empty_ctxt(param.ident.name));
default_ban_rib.bindings.remove(&Ident::with_dummy_span(param.ident.name));
}
GenericParamKind::Const { ref ty } => {
self.ribs[TypeNS].push(const_ty_param_ban_rib);
@ -965,7 +965,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
let mut self_type_rib = Rib::new(NormalRibKind);
// Plain insert (no renaming, since types are not currently hygienic)
self_type_rib.bindings.insert(Ident::with_empty_ctxt(kw::SelfUpper), self_res);
self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), self_res);
self.ribs[TypeNS].push(self_type_rib);
f(self);
self.ribs[TypeNS].pop();
@ -976,7 +976,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
{
let self_res = Res::SelfCtor(impl_id);
let mut self_type_rib = Rib::new(NormalRibKind);
self_type_rib.bindings.insert(Ident::with_empty_ctxt(kw::SelfUpper), self_res);
self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), self_res);
self.ribs[ValueNS].push(self_type_rib);
f(self);
self.ribs[ValueNS].pop();
@ -1476,7 +1476,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
self.r.trait_map.insert(id, traits);
}
let mut std_path = vec![Segment::from_ident(Ident::with_empty_ctxt(sym::std))];
let mut std_path = vec![Segment::from_ident(Ident::with_dummy_span(sym::std))];
std_path.extend(path);
if self.r.primitive_type_table.primitive_types.contains_key(&path[0].ident.name) {
let cl = CrateLint::No;
@ -1507,7 +1507,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
fn self_type_is_available(&mut self, span: Span) -> bool {
let binding = self.resolve_ident_in_lexical_scope(
Ident::with_empty_ctxt(kw::SelfUpper),
Ident::with_dummy_span(kw::SelfUpper),
TypeNS,
None,
span,

View File

@ -985,11 +985,11 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
} else {
kw::Crate
};
let segments = iter::once(Ident::with_empty_ctxt(root))
let segments = iter::once(Ident::with_dummy_span(root))
.chain(
crate_root.into_iter()
.chain(components.iter().cloned())
.map(Ident::with_empty_ctxt)
.map(Ident::with_dummy_span)
).map(|i| self.new_ast_path_segment(i)).collect::<Vec<_>>();
let path = ast::Path {
@ -1060,11 +1060,11 @@ impl<'a> Resolver<'a> {
.collect();
if !attr::contains_name(&krate.attrs, sym::no_core) {
extern_prelude.insert(Ident::with_empty_ctxt(sym::core), Default::default());
extern_prelude.insert(Ident::with_dummy_span(sym::core), Default::default());
if !attr::contains_name(&krate.attrs, sym::no_std) {
extern_prelude.insert(Ident::with_empty_ctxt(sym::std), Default::default());
extern_prelude.insert(Ident::with_dummy_span(sym::std), Default::default());
if session.rust_2018() {
extern_prelude.insert(Ident::with_empty_ctxt(sym::meta), Default::default());
extern_prelude.insert(Ident::with_dummy_span(sym::meta), Default::default());
}
}
}
@ -2624,7 +2624,7 @@ impl<'a> Resolver<'a> {
let path = if path_str.starts_with("::") {
ast::Path {
span,
segments: iter::once(Ident::with_empty_ctxt(kw::PathRoot))
segments: iter::once(Ident::with_dummy_span(kw::PathRoot))
.chain({
path_str.split("::").skip(1).map(Ident::from_str)
})
@ -2713,7 +2713,7 @@ fn module_to_string(module: Module<'_>) -> Option<String> {
fn collect_mod(names: &mut Vec<Ident>, module: Module<'_>) {
if let ModuleKind::Def(.., name) = module.kind {
if let Some(parent) = module.parent {
names.push(Ident::with_empty_ctxt(name));
names.push(Ident::with_dummy_span(name));
collect_mod(names, parent);
}
} else {

View File

@ -2943,7 +2943,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(PlaceOp::Index, false) => (self.tcx.lang_items().index_trait(), sym::index),
(PlaceOp::Index, true) => (self.tcx.lang_items().index_mut_trait(), sym::index_mut),
};
(tr, ast::Ident::with_empty_ctxt(name))
(tr, ast::Ident::with_dummy_span(name))
}
fn try_overloaded_place_op(&self,

View File

@ -930,7 +930,7 @@ impl Attributes {
if attr.check_name(sym::enable) {
if let Some(feat) = attr.value_str() {
let meta = attr::mk_name_value_item_str(
Ident::with_empty_ctxt(sym::target_feature), feat, DUMMY_SP
Ident::with_dummy_span(sym::target_feature), feat, DUMMY_SP
);
if let Ok(feat_cfg) = Cfg::parse(&meta) {
cfg &= feat_cfg;

View File

@ -327,7 +327,7 @@ impl Attribute {
if self.is_sugared_doc {
let comment = self.value_str().unwrap();
let meta = mk_name_value_item_str(
Ident::with_empty_ctxt(sym::doc),
Ident::with_dummy_span(sym::doc),
Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())),
DUMMY_SP,
);
@ -412,7 +412,7 @@ pub fn mk_sugared_doc_attr(text: Symbol, span: Span) -> Attribute {
Attribute {
id: mk_attr_id(),
style,
path: Path::from_ident(Ident::with_empty_ctxt(sym::doc).with_span_pos(span)),
path: Path::from_ident(Ident::with_dummy_span(sym::doc).with_span_pos(span)),
tokens: MetaItemKind::NameValue(lit).tokens(span),
is_sugared_doc: true,
span,

View File

@ -172,7 +172,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt<'_>,
(descriptions.len(), ecx.expr_vec(span, descriptions))
});
let static_ = ecx.lifetime(span, Ident::with_empty_ctxt(kw::StaticLifetime));
let static_ = ecx.lifetime(span, Ident::with_dummy_span(kw::StaticLifetime));
let ty_str = ecx.ty_rptr(
span,
ecx.ty_ident(span, ecx.ident_of("str")),

View File

@ -872,7 +872,7 @@ impl<'a> ExtCtxt<'a> {
pub fn std_path(&self, components: &[Symbol]) -> Vec<ast::Ident> {
let def_site = DUMMY_SP.apply_mark(self.current_expansion.id);
iter::once(Ident::new(kw::DollarCrate, def_site))
.chain(components.iter().map(|&s| Ident::with_empty_ctxt(s)))
.chain(components.iter().map(|&s| Ident::with_dummy_span(s)))
.collect()
}
pub fn name_of(&self, st: &str) -> ast::Name {

View File

@ -340,7 +340,7 @@ impl<'a> ExtCtxt<'a> {
self.expr_path(self.path_ident(span, id))
}
pub fn expr_self(&self, span: Span) -> P<ast::Expr> {
self.expr_ident(span, Ident::with_empty_ctxt(kw::SelfLower))
self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower))
}
pub fn expr_binary(&self, sp: Span, op: ast::BinOpKind,

View File

@ -1249,21 +1249,21 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
let include_info = vec![
ast::NestedMetaItem::MetaItem(
attr::mk_name_value_item_str(
Ident::with_empty_ctxt(sym::file),
Ident::with_dummy_span(sym::file),
file,
DUMMY_SP,
),
),
ast::NestedMetaItem::MetaItem(
attr::mk_name_value_item_str(
Ident::with_empty_ctxt(sym::contents),
Ident::with_dummy_span(sym::contents),
src_interned,
DUMMY_SP,
),
),
];
let include_ident = Ident::with_empty_ctxt(sym::include);
let include_ident = Ident::with_dummy_span(sym::include);
let item = attr::mk_list_item(include_ident, include_info);
items.push(ast::NestedMetaItem::MetaItem(item));
}
@ -1325,7 +1325,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}
}
let meta = attr::mk_list_item(Ident::with_empty_ctxt(sym::doc), items);
let meta = attr::mk_list_item(Ident::with_dummy_span(sym::doc), items);
*at = attr::Attribute {
span: at.span,
id: at.id,

View File

@ -60,7 +60,7 @@ impl<'a> Parser<'a> {
// Record that we fetched the mod from an external file
if warn {
let attr = attr::mk_attr_outer(
attr::mk_word_item(Ident::with_empty_ctxt(sym::warn_directory_ownership)));
attr::mk_word_item(Ident::with_dummy_span(sym::warn_directory_ownership)));
attr::mark_known(&attr);
attrs.push(attr);
}

View File

@ -123,13 +123,13 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
// of the feature gate, so we fake them up here.
// #![feature(prelude_import)]
let pi_nested = attr::mk_nested_word_item(ast::Ident::with_empty_ctxt(sym::prelude_import));
let list = attr::mk_list_item(ast::Ident::with_empty_ctxt(sym::feature), vec![pi_nested]);
let pi_nested = attr::mk_nested_word_item(ast::Ident::with_dummy_span(sym::prelude_import));
let list = attr::mk_list_item(ast::Ident::with_dummy_span(sym::feature), vec![pi_nested]);
let fake_attr = attr::mk_attr_inner(list);
s.print_attribute(&fake_attr);
// #![no_std]
let no_std_meta = attr::mk_word_item(ast::Ident::with_empty_ctxt(sym::no_std));
let no_std_meta = attr::mk_word_item(ast::Ident::with_dummy_span(sym::no_std));
let fake_attr = attr::mk_attr_inner(no_std_meta);
s.print_attribute(&fake_attr);
}

View File

@ -129,7 +129,7 @@ fn cs_clone_shallow(name: &str,
if is_union {
// let _: AssertParamIsCopy<Self>;
let self_ty =
cx.ty_path(cx.path_ident(trait_span, ast::Ident::with_empty_ctxt(kw::SelfUpper)));
cx.ty_path(cx.path_ident(trait_span, ast::Ident::with_dummy_span(kw::SelfUpper)));
assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, "AssertParamIsCopy");
} else {
match *substr.fields {

View File

@ -82,7 +82,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
let expr = cx.expr_method_call(span,
builder_expr.clone(),
Ident::with_empty_ctxt(sym::field),
Ident::with_dummy_span(sym::field),
vec![field]);
// Use `let _ = expr;` to avoid triggering the
@ -106,7 +106,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
let field = cx.expr_addr_of(field.span, field);
let expr = cx.expr_method_call(span,
builder_expr.clone(),
Ident::with_empty_ctxt(sym::field),
Ident::with_dummy_span(sym::field),
vec![name, field]);
stmts.push(stmt_let_undescore(cx, span, expr));
}

View File

@ -928,7 +928,7 @@ impl<'a> MethodDef<'a> {
let args = {
let self_args = explicit_self.map(|explicit_self| {
let ident = Ident::with_empty_ctxt(kw::SelfLower).with_span_pos(trait_.span);
let ident = Ident::with_dummy_span(kw::SelfLower).with_span_pos(trait_.span);
ast::Arg::from_self(ThinVec::default(), explicit_self, ident)
});
let nonself_args = arg_types.into_iter()

View File

@ -23,13 +23,13 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>,
let sp = sp.apply_mark(cx.current_expansion.id);
let e = match env::var(&*var.as_str()) {
Err(..) => {
let lt = cx.lifetime(sp, Ident::with_empty_ctxt(kw::StaticLifetime));
let lt = cx.lifetime(sp, Ident::with_dummy_span(kw::StaticLifetime));
cx.expr_path(cx.path_all(sp,
true,
cx.std_path(&[sym::option, sym::Option, sym::None]),
vec![GenericArg::Type(cx.ty_rptr(sp,
cx.ty_ident(sp,
Ident::with_empty_ctxt(sym::str)),
Ident::with_dummy_span(sym::str)),
Some(lt),
ast::Mutability::Immutable))],
vec![]))

View File

@ -44,7 +44,7 @@ pub fn expand(
let const_ty = ecx.ty(span, TyKind::Tup(Vec::new()));
let const_body = ecx.expr_block(ecx.block(span, stmts));
let const_item =
ecx.item_const(span, Ident::with_empty_ctxt(kw::Underscore), const_ty, const_body);
ecx.item_const(span, Ident::with_dummy_span(kw::Underscore), const_ty, const_body);
// Return the original item and the new methods.
vec![Annotatable::Item(item), Annotatable::Item(const_item)]
@ -120,7 +120,7 @@ impl AllocFnFactory<'_, '_> {
) -> P<Expr> {
match *ty {
AllocatorTy::Layout => {
let usize = self.cx.path_ident(self.span, Ident::with_empty_ctxt(sym::usize));
let usize = self.cx.path_ident(self.span, Ident::with_dummy_span(sym::usize));
let ty_usize = self.cx.ty_path(usize);
let size = ident();
let align = ident();
@ -178,12 +178,12 @@ impl AllocFnFactory<'_, '_> {
}
fn usize(&self) -> P<Ty> {
let usize = self.cx.path_ident(self.span, Ident::with_empty_ctxt(sym::usize));
let usize = self.cx.path_ident(self.span, Ident::with_dummy_span(sym::usize));
self.cx.ty_path(usize)
}
fn ptr_u8(&self) -> P<Ty> {
let u8 = self.cx.path_ident(self.span, Ident::with_empty_ctxt(sym::u8));
let u8 = self.cx.path_ident(self.span, Ident::with_dummy_span(sym::u8));
let ty_u8 = self.cx.ty_path(u8);
self.cx.ty_ptr(self.span, ty_u8, Mutability::Mutable)
}

View File

@ -42,7 +42,7 @@ pub mod test_harness;
pub fn register_builtin_macros(resolver: &mut dyn syntax::ext::base::Resolver, edition: Edition) {
let mut register = |name, kind| resolver.register_builtin_macro(
Ident::with_empty_ctxt(name), SyntaxExtension {
Ident::with_dummy_span(name), SyntaxExtension {
is_builtin: true, ..SyntaxExtension::default(kind, edition)
},
);

View File

@ -48,7 +48,7 @@ pub fn inject(
[sym::rustc_attrs][..].into(),
));
for (name, ext) in named_exts {
resolver.register_builtin_macro(Ident::with_empty_ctxt(name), ext);
resolver.register_builtin_macro(Ident::with_dummy_span(name), ext);
extra_items.push(plugin_macro_def(name, span));
}
// The `macro_rules` items must be inserted before any other items.

View File

@ -337,7 +337,7 @@ fn mk_decls(
let doc = cx.meta_list(span, sym::doc, vec![hidden]);
let doc_hidden = cx.attribute(doc);
let proc_macro = Ident::with_empty_ctxt(sym::proc_macro);
let proc_macro = Ident::with_dummy_span(sym::proc_macro);
let krate = cx.item(span,
proc_macro,
Vec::new(),
@ -349,7 +349,7 @@ fn mk_decls(
let custom_derive = Ident::from_str("custom_derive");
let attr = Ident::from_str("attr");
let bang = Ident::from_str("bang");
let crate_kw = Ident::with_empty_ctxt(kw::Crate);
let crate_kw = Ident::with_dummy_span(kw::Crate);
let decls = {
let local_path = |sp: Span, name| {

View File

@ -32,7 +32,7 @@ pub fn inject(
// HACK(eddyb) gensym the injected crates on the Rust 2018 edition,
// so they don't accidentally interfere with the new import paths.
let orig_name_sym = Symbol::intern(orig_name_str);
let orig_name_ident = Ident::with_empty_ctxt(orig_name_sym);
let orig_name_ident = Ident::with_dummy_span(orig_name_sym);
let (rename, orig_name) = if rust_2018 {
(orig_name_ident.gensym(), Some(orig_name_sym))
} else {
@ -40,7 +40,7 @@ pub fn inject(
};
krate.module.items.insert(0, P(ast::Item {
attrs: vec![attr::mk_attr_outer(
attr::mk_word_item(ast::Ident::with_empty_ctxt(sym::macro_use))
attr::mk_word_item(ast::Ident::with_dummy_span(sym::macro_use))
)],
vis: dummy_spanned(ast::VisibilityKind::Inherited),
node: ast::ItemKind::ExternCrate(alt_std_name.or(orig_name)),
@ -66,7 +66,7 @@ pub fn inject(
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
node: ast::ItemKind::Use(P(ast::UseTree {
prefix: ast::Path {
segments: iter::once(ast::Ident::with_empty_ctxt(kw::PathRoot))
segments: iter::once(ast::Ident::with_dummy_span(kw::PathRoot))
.chain(
[name, "prelude", "v1"].iter().cloned()
.map(ast::Ident::from_str)

View File

@ -150,7 +150,7 @@ impl MutVisitor for EntryPointCleaner {
EntryPointType::MainAttr |
EntryPointType::Start =>
item.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| {
let allow_ident = Ident::with_empty_ctxt(sym::allow);
let allow_ident = Ident::with_dummy_span(sym::allow);
let dc_nested = attr::mk_nested_word_item(Ident::from_str("dead_code"));
let allow_dead_code_item = attr::mk_list_item(allow_ident, vec![dc_nested]);
let allow_dead_code = attr::mk_attr_outer(allow_dead_code_item);
@ -191,7 +191,7 @@ fn mk_reexport_mod(cx: &mut TestCtxt<'_>,
tests: Vec<Ident>,
tested_submods: Vec<(Ident, Ident)>)
-> (P<ast::Item>, Ident) {
let super_ = Ident::with_empty_ctxt(kw::Super);
let super_ = Ident::with_dummy_span(kw::Super);
let items = tests.into_iter().map(|r| {
cx.ext_cx.item_use_simple(DUMMY_SP, dummy_spanned(ast::VisibilityKind::Public),
@ -274,7 +274,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
[sym::main, sym::test, sym::rustc_attrs][..].into(),
));
let ecx = &cx.ext_cx;
let test_id = Ident::with_empty_ctxt(sym::test);
let test_id = Ident::with_dummy_span(sym::test);
// test::test_main_static(...)
let mut test_runner = cx.test_runner.clone().unwrap_or(

View File

@ -744,25 +744,25 @@ impl Ident {
Ident { name, span }
}
/// Constructs a new identifier with an empty syntax context.
/// Constructs a new identifier with a dummy span.
#[inline]
pub const fn with_empty_ctxt(name: Symbol) -> Ident {
pub const fn with_dummy_span(name: Symbol) -> Ident {
Ident::new(name, DUMMY_SP)
}
#[inline]
pub fn invalid() -> Ident {
Ident::with_empty_ctxt(kw::Invalid)
Ident::with_dummy_span(kw::Invalid)
}
/// Maps an interned string to an identifier with an empty syntax context.
pub fn from_interned_str(string: InternedString) -> Ident {
Ident::with_empty_ctxt(string.as_symbol())
Ident::with_dummy_span(string.as_symbol())
}
/// Maps a string to an identifier with an empty span.
pub fn from_str(string: &str) -> Ident {
Ident::with_empty_ctxt(Symbol::intern(string))
Ident::with_dummy_span(Symbol::intern(string))
}
/// Maps a string and a span to an identifier.