1
Fork 0

syntax: Rename some keywords

`CrateRoot` -> `PathRoot`, `::` doesn't necessarily mean crate root now
`SelfValue` -> `SelfLower`, `SelfType` -> `SelfUpper`, both `self` and `Self` can be used in type and value namespaces now
This commit is contained in:
Vadim Petrochenkov 2018-12-02 03:35:55 +03:00
parent 101467c152
commit 08f8faedd0
26 changed files with 83 additions and 83 deletions

View file

@ -741,14 +741,14 @@ fn_anon_params
; ;
fn_params_with_self fn_params_with_self
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); } : '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); } | '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); } | '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
| '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); } | '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
; ;
fn_anon_params_with_self fn_anon_params_with_self
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); } : '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); } | '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); } | '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
| '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); } | '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); }

View file

@ -1201,7 +1201,7 @@ impl<'a> LoweringContext<'a> {
None, None,
P(hir::Path { P(hir::Path {
def: self.expect_full_def(t.id), def: self.expect_full_def(t.id),
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfType.ident())], segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfUpper.ident())],
span: t.span, span: t.span,
}), }),
)), )),
@ -2425,7 +2425,7 @@ impl<'a> LoweringContext<'a> {
// Don't expose `Self` (recovered "keyword used as ident" parse error). // Don't expose `Self` (recovered "keyword used as ident" parse error).
// `rustc::ty` expects `Self` to be only used for a trait's `Self`. // `rustc::ty` expects `Self` to be only used for a trait's `Self`.
// Instead, use gensym("Self") to create a distinct name that looks the same. // Instead, use gensym("Self") to create a distinct name that looks the same.
let ident = if param.ident.name == keywords::SelfType.name() { let ident = if param.ident.name == keywords::SelfUpper.name() {
param.ident.gensym() param.ident.gensym()
} else { } else {
param.ident param.ident
@ -2981,7 +2981,7 @@ impl<'a> LoweringContext<'a> {
// Correctly resolve `self` imports // Correctly resolve `self` imports
if path.segments.len() > 1 if path.segments.len() > 1
&& path.segments.last().unwrap().ident.name == keywords::SelfValue.name() && path.segments.last().unwrap().ident.name == keywords::SelfLower.name()
{ {
let _ = path.segments.pop(); let _ = path.segments.pop();
if rename.is_none() { if rename.is_none() {

View file

@ -475,7 +475,7 @@ impl<'hir> Map<'hir> {
pub fn ty_param_name(&self, id: NodeId) -> Name { pub fn ty_param_name(&self, id: NodeId) -> Name {
match self.get(id) { match self.get(id) {
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfType.name(), Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfUpper.name(),
Node::GenericParam(param) => param.name.ident().name, Node::GenericParam(param) => param.name.ident().name,
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)), _ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
} }

View file

@ -311,7 +311,7 @@ pub struct Path {
impl Path { impl Path {
pub fn is_global(&self) -> bool { pub fn is_global(&self) -> bool {
!self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name() !self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
} }
} }

View file

@ -1622,7 +1622,7 @@ impl<'a> State<'a> {
if i > 0 { if i > 0 {
self.s.word("::")? self.s.word("::")?
} }
if segment.ident.name != keywords::CrateRoot.name() && if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() { segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?; self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| { segment.with_generic_args(|generic_args| {
@ -1636,7 +1636,7 @@ impl<'a> State<'a> {
} }
pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> { pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> {
if segment.ident.name != keywords::CrateRoot.name() && if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() { segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?; self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| { segment.with_generic_args(|generic_args| {
@ -1664,7 +1664,7 @@ impl<'a> State<'a> {
if i > 0 { if i > 0 {
self.s.word("::")? self.s.word("::")?
} }
if segment.ident.name != keywords::CrateRoot.name() && if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() { segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?; self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| { segment.with_generic_args(|generic_args| {

View file

@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let sp = ident.span; let sp = ident.span;
let var = self.variable(hir_id, sp); let var = self.variable(hir_id, sp);
// Ignore unused self. // Ignore unused self.
if ident.name != keywords::SelfValue.name() { if ident.name != keywords::SelfLower.name() {
if !self.warn_about_unused(sp, hir_id, entry_ln, var) { if !self.warn_about_unused(sp, hir_id, entry_ln, var) {
if self.live_on_entry(entry_ln, var).is_none() { if self.live_on_entry(entry_ln, var).is_none() {
self.report_dead_assign(hir_id, sp, var, true); self.report_dead_assign(hir_id, sp, var, true);

View file

@ -2710,7 +2710,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
#[inline] #[inline]
pub fn mk_self_type(self) -> Ty<'tcx> { pub fn mk_self_type(self) -> Ty<'tcx> {
self.mk_ty_param(0, keywords::SelfType.name().as_interned_str()) self.mk_ty_param(0, keywords::SelfUpper.name().as_interned_str())
} }
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> { pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> {

View file

@ -1020,7 +1020,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
} }
pub fn for_self() -> ParamTy { pub fn for_self() -> ParamTy {
ParamTy::new(0, keywords::SelfType.name().as_interned_str()) ParamTy::new(0, keywords::SelfUpper.name().as_interned_str())
} }
pub fn for_def(def: &ty::GenericParamDef) -> ParamTy { pub fn for_def(def: &ty::GenericParamDef) -> ParamTy {
@ -1035,7 +1035,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
// FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere, // FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere,
// but this should only be possible when using `-Z continue-parse-after-error` like // but this should only be possible when using `-Z continue-parse-after-error` like
// `compile-fail/issue-36638.rs`. // `compile-fail/issue-36638.rs`.
self.name == keywords::SelfType.name().as_str() && self.idx == 0 self.name == keywords::SelfUpper.name().as_str() && self.idx == 0
} }
} }

View file

@ -473,7 +473,7 @@ impl UnusedImportBraces {
match items[0].0.kind { match items[0].0.kind {
ast::UseTreeKind::Simple(rename, ..) => { ast::UseTreeKind::Simple(rename, ..) => {
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident; let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
if orig_ident.name == keywords::SelfValue.name() { if orig_ident.name == keywords::SelfLower.name() {
return; return;
} }
node_ident = rename.unwrap_or(orig_ident); node_ident = rename.unwrap_or(orig_ident);

View file

@ -263,7 +263,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
// Deliberately fall into this case for all implicit self types, // Deliberately fall into this case for all implicit self types,
// so that we don't fall in to the next case with them. // so that we don't fall in to the next case with them.
*kind == mir::ImplicitSelfKind::MutRef *kind == mir::ImplicitSelfKind::MutRef
} else if Some(keywords::SelfValue.name()) == local_decl.name { } else if Some(keywords::SelfLower.name()) == local_decl.name {
// Otherwise, check if the name is the self kewyord - in which case // Otherwise, check if the name is the self kewyord - in which case
// we have an explicit self. Do the same thing in this case and check // we have an explicit self. Do the same thing in this case and check
// for a `self: &mut Self` to suggest removing the `&mut`. // for a `self: &mut Self` to suggest removing the `&mut`.

View file

@ -145,7 +145,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
} }
_ => None, _ => None,
}.map(|ctxt| Segment::from_ident(Ident::new( }.map(|ctxt| Segment::from_ident(Ident::new(
keywords::CrateRoot.name(), use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt) keywords::PathRoot.name(), use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt)
))); )));
let prefix = crate_root.into_iter().chain(prefix_iter).collect::<Vec<_>>(); let prefix = crate_root.into_iter().chain(prefix_iter).collect::<Vec<_>>();
@ -153,7 +153,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
let empty_for_self = |prefix: &[Segment]| { let empty_for_self = |prefix: &[Segment]| {
prefix.is_empty() || prefix.is_empty() ||
prefix.len() == 1 && prefix[0].ident.name == keywords::CrateRoot.name() prefix.len() == 1 && prefix[0].ident.name == keywords::PathRoot.name()
}; };
match use_tree.kind { match use_tree.kind {
ast::UseTreeKind::Simple(rename, ..) => { ast::UseTreeKind::Simple(rename, ..) => {
@ -164,7 +164,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
if nested { if nested {
// Correctly handle `self` // Correctly handle `self`
if source.ident.name == keywords::SelfValue.name() { if source.ident.name == keywords::SelfLower.name() {
type_ns_only = true; type_ns_only = true;
if empty_for_self(&module_path) { if empty_for_self(&module_path) {
@ -185,7 +185,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
} }
} else { } else {
// Disallow `self` // Disallow `self`
if source.ident.name == keywords::SelfValue.name() { if source.ident.name == keywords::SelfLower.name() {
resolve_error(self, resolve_error(self,
use_tree.span, use_tree.span,
ResolutionError::SelfImportsOnlyAllowedWithin); ResolutionError::SelfImportsOnlyAllowedWithin);
@ -205,7 +205,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// `crate_name` should not be interpreted as relative. // `crate_name` should not be interpreted as relative.
module_path.push(Segment { module_path.push(Segment {
ident: Ident { ident: Ident {
name: keywords::CrateRoot.name(), name: keywords::PathRoot.name(),
span: source.ident.span, span: source.ident.span,
}, },
id: Some(self.session.next_node_id()), id: Some(self.session.next_node_id()),
@ -270,7 +270,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// Ensure there is at most one `self` in the list // Ensure there is at most one `self` in the list
let self_spans = items.iter().filter_map(|&(ref use_tree, _)| { let self_spans = items.iter().filter_map(|&(ref use_tree, _)| {
if let ast::UseTreeKind::Simple(..) = use_tree.kind { if let ast::UseTreeKind::Simple(..) = use_tree.kind {
if use_tree.ident().name == keywords::SelfValue.name() { if use_tree.ident().name == keywords::SelfLower.name() {
return Some(use_tree.span); return Some(use_tree.span);
} }
} }
@ -305,7 +305,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
let new_span = prefix[prefix.len() - 1].ident.span; let new_span = prefix[prefix.len() - 1].ident.span;
let tree = ast::UseTree { let tree = ast::UseTree {
prefix: ast::Path::from_ident( prefix: ast::Path::from_ident(
Ident::new(keywords::SelfValue.name(), new_span) Ident::new(keywords::SelfLower.name(), new_span)
), ),
kind: ast::UseTreeKind::Simple( kind: ast::UseTreeKind::Simple(
Some(Ident::new(keywords::Underscore.name().gensymed(), new_span)), Some(Ident::new(keywords::Underscore.name().gensymed(), new_span)),
@ -344,13 +344,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
} }
ItemKind::ExternCrate(orig_name) => { ItemKind::ExternCrate(orig_name) => {
let module = if orig_name.is_none() && ident.name == keywords::SelfValue.name() { let module = if orig_name.is_none() && ident.name == keywords::SelfLower.name() {
self.session self.session
.struct_span_err(item.span, "`extern crate self;` requires renaming") .struct_span_err(item.span, "`extern crate self;` requires renaming")
.span_suggestion(item.span, "try", "extern crate self as name;".into()) .span_suggestion(item.span, "try", "extern crate self as name;".into())
.emit(); .emit();
return; return;
} else if orig_name == Some(keywords::SelfValue.name()) { } else if orig_name == Some(keywords::SelfLower.name()) {
if !self.session.features_untracked().extern_crate_self { if !self.session.features_untracked().extern_crate_self {
emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span, emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span,
GateIssue::Language, "`extern crate self` is unstable"); GateIssue::Language, "`extern crate self` is unstable");
@ -783,7 +783,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
"an `extern crate` loading macros must be at the crate root"); "an `extern crate` loading macros must be at the crate root");
} }
if let ItemKind::ExternCrate(Some(orig_name)) = item.node { if let ItemKind::ExternCrate(Some(orig_name)) = item.node {
if orig_name == keywords::SelfValue.name() { if orig_name == keywords::SelfLower.name() {
self.session.span_err(attr.span, self.session.span_err(attr.span,
"`macro_use` is not supported on `extern crate self`"); "`macro_use` is not supported on `extern crate self`");
} }

View file

@ -30,7 +30,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
match (path.get(0), path.get(1)) { match (path.get(0), path.get(1)) {
// `{{root}}::ident::...` on both editions. // `{{root}}::ident::...` on both editions.
// On 2015 `{{root}}` is usually added implicitly. // On 2015 `{{root}}` is usually added implicitly.
(Some(fst), Some(snd)) if fst.ident.name == keywords::CrateRoot.name() && (Some(fst), Some(snd)) if fst.ident.name == keywords::PathRoot.name() &&
!snd.ident.is_path_segment_keyword() => {} !snd.ident.is_path_segment_keyword() => {}
// `ident::...` on 2018 // `ident::...` on 2018
(Some(fst), _) if fst.ident.span.rust_2018() && (Some(fst), _) if fst.ident.span.rust_2018() &&
@ -61,7 +61,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
parent_scope: &ParentScope<'b>, parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Option<String>)> { ) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `self` and check if that is valid. // Replace first ident with `self` and check if that is valid.
path[0].ident.name = keywords::SelfValue.name(); path[0].ident.name = keywords::SelfLower.name();
let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result); debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result { if let PathResult::Module(..) = result {

View file

@ -769,7 +769,7 @@ impl<'a, 'tcx, 'cl> Visitor<'tcx> for Resolver<'a, 'cl> {
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type); self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
} }
TyKind::ImplicitSelf => { TyKind::ImplicitSelf => {
let self_ty = keywords::SelfType.ident(); let self_ty = keywords::SelfUpper.ident();
let def = self.resolve_ident_in_lexical_scope(self_ty, TypeNS, Some(ty.id), ty.span) let def = self.resolve_ident_in_lexical_scope(self_ty, TypeNS, Some(ty.id), ty.span)
.map_or(Def::Err, |d| d.def()); .map_or(Def::Err, |d| d.def());
self.record_def(ty.id, PathResolution::new(def)); self.record_def(ty.id, PathResolution::new(def));
@ -1679,7 +1679,7 @@ impl<'a, 'cl> hir::lowering::Resolver for Resolver<'a, 'cl> {
components: &[&str], components: &[&str],
is_value: bool is_value: bool
) -> hir::Path { ) -> hir::Path {
let segments = iter::once(keywords::CrateRoot.ident()) let segments = iter::once(keywords::PathRoot.ident())
.chain( .chain(
crate_root.into_iter() crate_root.into_iter()
.chain(components.iter().cloned()) .chain(components.iter().cloned())
@ -1721,7 +1721,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
let path = if path_str.starts_with("::") { let path = if path_str.starts_with("::") {
ast::Path { ast::Path {
span, span,
segments: iter::once(keywords::CrateRoot.ident()) segments: iter::once(keywords::PathRoot.ident())
.chain({ .chain({
path_str.split("::").skip(1).map(Ident::from_str) path_str.split("::").skip(1).map(Ident::from_str)
}) })
@ -2036,7 +2036,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
let record_used = record_used_id.is_some(); let record_used = record_used_id.is_some();
assert!(ns == TypeNS || ns == ValueNS); assert!(ns == TypeNS || ns == ValueNS);
if ns == TypeNS { if ns == TypeNS {
ident.span = if ident.name == keywords::SelfType.name() { ident.span = if ident.name == keywords::SelfUpper.name() {
// FIXME(jseyfried) improve `Self` hygiene // FIXME(jseyfried) improve `Self` hygiene
ident.span.with_ctxt(SyntaxContext::empty()) ident.span.with_ctxt(SyntaxContext::empty())
} else { } else {
@ -2649,7 +2649,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
let mut self_type_rib = Rib::new(NormalRibKind); let mut self_type_rib = Rib::new(NormalRibKind);
// plain insert (no renaming, types are not currently hygienic....) // plain insert (no renaming, types are not currently hygienic....)
self_type_rib.bindings.insert(keywords::SelfType.ident(), self_def); self_type_rib.bindings.insert(keywords::SelfUpper.ident(), self_def);
self.ribs[TypeNS].push(self_type_rib); self.ribs[TypeNS].push(self_type_rib);
f(self); f(self);
self.ribs[TypeNS].pop(); self.ribs[TypeNS].pop();
@ -2660,7 +2660,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
{ {
let self_def = Def::SelfCtor(impl_id); let self_def = Def::SelfCtor(impl_id);
let mut self_type_rib = Rib::new(NormalRibKind); let mut self_type_rib = Rib::new(NormalRibKind);
self_type_rib.bindings.insert(keywords::SelfType.ident(), self_def); self_type_rib.bindings.insert(keywords::SelfUpper.ident(), self_def);
self.ribs[ValueNS].push(self_type_rib); self.ribs[ValueNS].push(self_type_rib);
f(self); f(self);
self.ribs[ValueNS].pop(); self.ribs[ValueNS].pop();
@ -3146,7 +3146,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
let item_span = path.last().unwrap().ident.span; let item_span = path.last().unwrap().ident.span;
let (mod_prefix, mod_str) = if path.len() == 1 { let (mod_prefix, mod_str) = if path.len() == 1 {
(String::new(), "this scope".to_string()) (String::new(), "this scope".to_string())
} else if path.len() == 2 && path[0].ident.name == keywords::CrateRoot.name() { } else if path.len() == 2 && path[0].ident.name == keywords::PathRoot.name() {
(String::new(), "the crate root".to_string()) (String::new(), "the crate root".to_string())
} else { } else {
let mod_path = &path[..path.len() - 1]; let mod_path = &path[..path.len() - 1];
@ -3515,13 +3515,13 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
} }
fn self_type_is_available(&mut self, span: Span) -> bool { fn self_type_is_available(&mut self, span: Span) -> bool {
let binding = self.resolve_ident_in_lexical_scope(keywords::SelfType.ident(), let binding = self.resolve_ident_in_lexical_scope(keywords::SelfUpper.ident(),
TypeNS, None, span); TypeNS, None, span);
if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false } if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false }
} }
fn self_value_is_available(&mut self, self_span: Span, path_span: Span) -> bool { fn self_value_is_available(&mut self, self_span: Span, path_span: Span) -> bool {
let ident = Ident::new(keywords::SelfValue.name(), self_span); let ident = Ident::new(keywords::SelfLower.name(), self_span);
let binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, path_span); let binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, path_span);
if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false } if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false }
} }
@ -3673,7 +3673,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
}; };
if path.len() > 1 && !global_by_default && result.base_def() != Def::Err && if path.len() > 1 && !global_by_default && result.base_def() != Def::Err &&
path[0].ident.name != keywords::CrateRoot.name() && path[0].ident.name != keywords::PathRoot.name() &&
path[0].ident.name != keywords::DollarCrate.name() { path[0].ident.name != keywords::DollarCrate.name() {
let unqualified_result = { let unqualified_result = {
match self.resolve_path_without_parent_scope( match self.resolve_path_without_parent_scope(
@ -3755,7 +3755,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
let name = ident.name; let name = ident.name;
allow_super &= ns == TypeNS && allow_super &= ns == TypeNS &&
(name == keywords::SelfValue.name() || (name == keywords::SelfLower.name() ||
name == keywords::Super.name()); name == keywords::Super.name());
if ns == TypeNS { if ns == TypeNS {
@ -3779,24 +3779,24 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
return PathResult::Failed(ident.span, msg, false); return PathResult::Failed(ident.span, msg, false);
} }
if i == 0 { if i == 0 {
if name == keywords::SelfValue.name() { if name == keywords::SelfLower.name() {
let mut ctxt = ident.span.ctxt().modern(); let mut ctxt = ident.span.ctxt().modern();
module = Some(ModuleOrUniformRoot::Module( module = Some(ModuleOrUniformRoot::Module(
self.resolve_self(&mut ctxt, self.current_module))); self.resolve_self(&mut ctxt, self.current_module)));
continue; continue;
} }
if name == keywords::Extern.name() || if name == keywords::Extern.name() ||
name == keywords::CrateRoot.name() && ident.span.rust_2018() { name == keywords::PathRoot.name() && ident.span.rust_2018() {
module = Some(ModuleOrUniformRoot::ExternPrelude); module = Some(ModuleOrUniformRoot::ExternPrelude);
continue; continue;
} }
if name == keywords::CrateRoot.name() && if name == keywords::PathRoot.name() &&
ident.span.rust_2015() && self.session.rust_2018() { ident.span.rust_2015() && self.session.rust_2018() {
// `::a::b` from 2015 macro on 2018 global edition // `::a::b` from 2015 macro on 2018 global edition
module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude); module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude);
continue; continue;
} }
if name == keywords::CrateRoot.name() || if name == keywords::PathRoot.name() ||
name == keywords::Crate.name() || name == keywords::Crate.name() ||
name == keywords::DollarCrate.name() { name == keywords::DollarCrate.name() {
// `::a::b`, `crate::a::b` or `$crate::a::b` // `::a::b`, `crate::a::b` or `$crate::a::b`
@ -3809,12 +3809,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
// Report special messages for path segment keywords in wrong positions. // Report special messages for path segment keywords in wrong positions.
if ident.is_path_segment_keyword() && i != 0 { if ident.is_path_segment_keyword() && i != 0 {
let name_str = if name == keywords::CrateRoot.name() { let name_str = if name == keywords::PathRoot.name() {
"crate root".to_string() "crate root".to_string()
} else { } else {
format!("`{}`", name) format!("`{}`", name)
}; };
let msg = if i == 1 && path[0].ident.name == keywords::CrateRoot.name() { let msg = if i == 1 && path[0].ident.name == keywords::PathRoot.name() {
format!("global paths cannot start with {}", name_str) format!("global paths cannot start with {}", name_str)
} else { } else {
format!("{} in paths can only be used in start position", name_str) format!("{} in paths can only be used in start position", name_str)
@ -3944,7 +3944,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
// We're only interested in `use` paths which should start with // We're only interested in `use` paths which should start with
// `{{root}}` or `extern` currently. // `{{root}}` or `extern` currently.
if first_name != keywords::Extern.name() && first_name != keywords::CrateRoot.name() { if first_name != keywords::Extern.name() && first_name != keywords::PathRoot.name() {
return return
} }
@ -3953,7 +3953,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
Some(Segment { ident, .. }) if ident.name == keywords::Crate.name() => return, Some(Segment { ident, .. }) if ident.name == keywords::Crate.name() => return,
// Otherwise go below to see if it's an extern crate // Otherwise go below to see if it's an extern crate
Some(_) => {} Some(_) => {}
// If the path has length one (and it's `CrateRoot` most likely) // If the path has length one (and it's `PathRoot` most likely)
// then we don't know whether we're gonna be importing a crate or an // then we don't know whether we're gonna be importing a crate or an
// item in our crate. Defer this lint to elsewhere // item in our crate. Defer this lint to elsewhere
None => return, None => return,
@ -4740,7 +4740,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
} else { } else {
let ctxt = ident.span.ctxt(); let ctxt = ident.span.ctxt();
Some(Segment::from_ident(Ident::new( Some(Segment::from_ident(Ident::new(
keywords::CrateRoot.name(), path.span.shrink_to_lo().with_ctxt(ctxt) keywords::PathRoot.name(), path.span.shrink_to_lo().with_ctxt(ctxt)
))) )))
}; };
@ -5090,17 +5090,17 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
} }
fn is_self_type(path: &[Segment], namespace: Namespace) -> bool { fn is_self_type(path: &[Segment], namespace: Namespace) -> bool {
namespace == TypeNS && path.len() == 1 && path[0].ident.name == keywords::SelfType.name() namespace == TypeNS && path.len() == 1 && path[0].ident.name == keywords::SelfUpper.name()
} }
fn is_self_value(path: &[Segment], namespace: Namespace) -> bool { fn is_self_value(path: &[Segment], namespace: Namespace) -> bool {
namespace == ValueNS && path.len() == 1 && path[0].ident.name == keywords::SelfValue.name() namespace == ValueNS && path.len() == 1 && path[0].ident.name == keywords::SelfLower.name()
} }
fn names_to_string(idents: &[Ident]) -> String { fn names_to_string(idents: &[Ident]) -> String {
let mut result = String::new(); let mut result = String::new();
for (i, ident) in idents.iter() for (i, ident) in idents.iter()
.filter(|ident| ident.name != keywords::CrateRoot.name()) .filter(|ident| ident.name != keywords::PathRoot.name())
.enumerate() { .enumerate() {
if i > 0 { if i > 0 {
result.push_str("::"); result.push_str("::");

View file

@ -167,7 +167,7 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
if path.segments[0].ident.name == keywords::DollarCrate.name() { if path.segments[0].ident.name == keywords::DollarCrate.name() {
let module = self.0.resolve_crate_root(path.segments[0].ident); let module = self.0.resolve_crate_root(path.segments[0].ident);
path.segments[0].ident.name = keywords::CrateRoot.name(); path.segments[0].ident.name = keywords::PathRoot.name();
if !module.is_local() { if !module.is_local() {
let span = path.segments[0].ident.span; let span = path.segments[0].ident.span;
path.segments.insert(1, match module.kind { path.segments.insert(1, match module.kind {
@ -674,7 +674,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
_ => Err(Determinacy::Determined), _ => Err(Determinacy::Determined),
} }
WhereToResolve::CrateRoot => { WhereToResolve::CrateRoot => {
let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span); let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
let root_module = self.resolve_crate_root(root_ident); let root_module = self.resolve_crate_root(root_ident);
let binding = self.resolve_ident_in_module_ext( let binding = self.resolve_ident_in_module_ext(
ModuleOrUniformRoot::Module(root_module), ModuleOrUniformRoot::Module(root_module),
@ -960,7 +960,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
break 'ok; break 'ok;
} }
if rust_2015 { if rust_2015 {
let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span); let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
let root_module = self.resolve_crate_root(root_ident); let root_module = self.resolve_crate_root(root_ident);
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module), if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
orig_ident, ns, None, false, path_span) orig_ident, ns, None, false, path_span)

View file

@ -198,7 +198,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
.to_name_binding(self.arenas); .to_name_binding(self.arenas);
return Ok(binding); return Ok(binding);
} else if ident.name == keywords::Super.name() || } else if ident.name == keywords::Super.name() ||
ident.name == keywords::SelfValue.name() { ident.name == keywords::SelfLower.name() {
// FIXME: Implement these with renaming requirements so that e.g. // FIXME: Implement these with renaming requirements so that e.g.
// `use super;` doesn't work, but `use super as name;` does. // `use super;` doesn't work, but `use super as name;` does.
// Fall through here to get an error from `early_resolve_...`. // Fall through here to get an error from `early_resolve_...`.
@ -1263,8 +1263,8 @@ fn import_path_to_string(names: &[Ident],
subclass: &ImportDirectiveSubclass, subclass: &ImportDirectiveSubclass,
span: Span) -> String { span: Span) -> String {
let pos = names.iter() let pos = names.iter()
.position(|p| span == p.span && p.name != keywords::CrateRoot.name()); .position(|p| span == p.span && p.name != keywords::PathRoot.name());
let global = !names.is_empty() && names[0].name == keywords::CrateRoot.name(); let global = !names.is_empty() && names[0].name == keywords::PathRoot.name();
if let Some(pos) = pos { if let Some(pos) = pos {
let names = if global { &names[1..pos + 1] } else { &names[..pos + 1] }; let names = if global { &names[1..pos + 1] } else { &names[..pos + 1] };
names_to_string(names) names_to_string(names)

View file

@ -938,7 +938,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
opt_self = Some(ty::GenericParamDef { opt_self = Some(ty::GenericParamDef {
index: 0, index: 0,
name: keywords::SelfType.name().as_interned_str(), name: keywords::SelfUpper.name().as_interned_str(),
def_id: tcx.hir.local_def_id(param_id), def_id: tcx.hir.local_def_id(param_id),
pure_wrt_drop: false, pure_wrt_drop: false,
kind: ty::GenericParamDefKind::Type { kind: ty::GenericParamDefKind::Type {
@ -1007,7 +1007,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
synthetic, synthetic,
.. ..
} => { } => {
if param.name.ident().name == keywords::SelfType.name() { if param.name.ident().name == keywords::SelfUpper.name() {
span_bug!( span_bug!(
param.span, param.span,
"`Self` should not be the name of a regular parameter" "`Self` should not be the name of a regular parameter"

View file

@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
let stripped_typarams = gens.params.iter().filter_map(|param| match param.kind { let stripped_typarams = gens.params.iter().filter_map(|param| match param.kind {
ty::GenericParamDefKind::Lifetime => None, ty::GenericParamDefKind::Lifetime => None,
ty::GenericParamDefKind::Type { .. } => { ty::GenericParamDefKind::Type { .. } => {
if param.name == keywords::SelfType.name().as_str() { if param.name == keywords::SelfUpper.name().as_str() {
assert_eq!(param.index, 0); assert_eq!(param.index, 0);
return None; return None;
} }
@ -3174,7 +3174,7 @@ fn qpath_to_string(p: &hir::QPath) -> String {
if i > 0 { if i > 0 {
s.push_str("::"); s.push_str("::");
} }
if seg.ident.name != keywords::CrateRoot.name() { if seg.ident.name != keywords::PathRoot.name() {
s.push_str(&*seg.ident.as_str()); s.push_str(&*seg.ident.as_str());
} }
} }
@ -3726,7 +3726,7 @@ fn resolve_type(cx: &DocContext,
hir::Float(float_ty) => return Primitive(float_ty.into()), hir::Float(float_ty) => return Primitive(float_ty.into()),
}, },
Def::SelfTy(..) if path.segments.len() == 1 => { Def::SelfTy(..) if path.segments.len() == 1 => {
return Generic(keywords::SelfType.name().to_string()); return Generic(keywords::SelfUpper.name().to_string());
} }
Def::TyParam(..) if path.segments.len() == 1 => { Def::TyParam(..) if path.segments.len() == 1 => {
return Generic(format!("{:#}", path)); return Generic(format!("{:#}", path));

View file

@ -73,7 +73,7 @@ impl fmt::Debug for Lifetime {
pub struct Path { pub struct Path {
pub span: Span, pub span: Span,
/// The segments in the path: the things separated by `::`. /// The segments in the path: the things separated by `::`.
/// Global paths begin with `keywords::CrateRoot`. /// Global paths begin with `keywords::PathRoot`.
pub segments: Vec<PathSegment>, pub segments: Vec<PathSegment>,
} }
@ -117,7 +117,7 @@ impl Path {
} }
pub fn is_global(&self) -> bool { pub fn is_global(&self) -> bool {
!self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name() !self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
} }
} }
@ -145,7 +145,7 @@ impl PathSegment {
PathSegment { ident, id: DUMMY_NODE_ID, args: None } PathSegment { ident, id: DUMMY_NODE_ID, args: None }
} }
pub fn crate_root(span: Span) -> Self { pub fn crate_root(span: Span) -> Self {
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span)) PathSegment::from_ident(Ident::new(keywords::PathRoot.name(), span))
} }
} }
@ -1688,7 +1688,7 @@ pub type ExplicitSelf = Spanned<SelfKind>;
impl Arg { impl Arg {
pub fn to_self(&self) -> Option<ExplicitSelf> { pub fn to_self(&self) -> Option<ExplicitSelf> {
if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node { if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node {
if ident.name == keywords::SelfValue.name() { if ident.name == keywords::SelfLower.name() {
return match self.ty.node { return match self.ty.node {
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))), TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => { TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => {
@ -1706,7 +1706,7 @@ impl Arg {
pub fn is_self(&self) -> bool { pub fn is_self(&self) -> bool {
if let PatKind::Ident(_, ident, _) = self.pat.node { if let PatKind::Ident(_, ident, _) = self.pat.node {
ident.name == keywords::SelfValue.name() ident.name == keywords::SelfLower.name()
} else { } else {
false false
} }

View file

@ -625,7 +625,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.expr_path(self.path_ident(span, id)) self.expr_path(self.path_ident(span, id))
} }
fn expr_self(&self, span: Span) -> P<ast::Expr> { fn expr_self(&self, span: Span) -> P<ast::Expr> {
self.expr_ident(span, keywords::SelfValue.ident()) self.expr_ident(span, keywords::SelfLower.ident())
} }
fn expr_binary(&self, sp: Span, op: ast::BinOpKind, fn expr_binary(&self, sp: Span, op: ast::BinOpKind,

View file

@ -204,7 +204,7 @@ fn macro_bang_format(path: &ast::Path) -> ExpnFormat {
path_str.push_str("::"); path_str.push_str("::");
} }
if segment.ident.name != keywords::CrateRoot.name() && if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() segment.ident.name != keywords::DollarCrate.name()
{ {
path_str.push_str(&segment.ident.as_str()) path_str.push_str(&segment.ident.as_str())

View file

@ -5508,7 +5508,7 @@ impl<'a> Parser<'a> {
_ => unreachable!() _ => unreachable!()
}; };
let isolated_self = |this: &mut Self, n| { let isolated_self = |this: &mut Self, n| {
this.look_ahead(n, |t| t.is_keyword(keywords::SelfValue)) && this.look_ahead(n, |t| t.is_keyword(keywords::SelfLower)) &&
this.look_ahead(n + 1, |t| t != &token::ModSep) this.look_ahead(n + 1, |t| t != &token::ModSep)
}; };
@ -6330,7 +6330,7 @@ impl<'a> Parser<'a> {
return Ok(vis) return Ok(vis)
} else if self.look_ahead(2, |t| t == &token::CloseDelim(token::Paren)) && } else if self.look_ahead(2, |t| t == &token::CloseDelim(token::Paren)) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Super) || self.look_ahead(1, |t| t.is_keyword(keywords::Super) ||
t.is_keyword(keywords::SelfValue)) t.is_keyword(keywords::SelfLower))
{ {
// `pub(self)` or `pub(super)` // `pub(self)` or `pub(super)`
self.bump(); // `(` self.bump(); // `(`
@ -6782,7 +6782,7 @@ impl<'a> Parser<'a> {
let error_msg = "crate name using dashes are not valid in `extern crate` statements"; let error_msg = "crate name using dashes are not valid in `extern crate` statements";
let suggestion_msg = "if the original crate name uses dashes you need to use underscores \ let suggestion_msg = "if the original crate name uses dashes you need to use underscores \
in the code"; in the code";
let mut ident = if self.token.is_keyword(keywords::SelfValue) { let mut ident = if self.token.is_keyword(keywords::SelfLower) {
self.parse_path_segment_ident() self.parse_path_segment_ident()
} else { } else {
self.parse_ident() self.parse_ident()

View file

@ -724,7 +724,7 @@ pub trait PrintState<'a> {
if i > 0 { if i > 0 {
self.writer().word("::")? self.writer().word("::")?
} }
if segment.ident.name != keywords::CrateRoot.name() && if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() segment.ident.name != keywords::DollarCrate.name()
{ {
self.writer().word(segment.ident.as_str().get())?; self.writer().word(segment.ident.as_str().get())?;
@ -2463,7 +2463,7 @@ impl<'a> State<'a> {
colons_before_params: bool) colons_before_params: bool)
-> io::Result<()> -> io::Result<()>
{ {
if segment.ident.name != keywords::CrateRoot.name() && if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() { segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?; self.print_ident(segment.ident)?;
if let Some(ref args) = segment.args { if let Some(ref args) = segment.args {

View file

@ -112,7 +112,7 @@ pub fn maybe_inject_crates_ref(
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited), vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
node: ast::ItemKind::Use(P(ast::UseTree { node: ast::ItemKind::Use(P(ast::UseTree {
prefix: ast::Path { prefix: ast::Path {
segments: iter::once(keywords::CrateRoot.ident()) segments: iter::once(keywords::PathRoot.ident())
.chain( .chain(
[name, "prelude", "v1"].iter().cloned() [name, "prelude", "v1"].iter().cloned()
.map(ast::Ident::from_str) .map(ast::Ident::from_str)

View file

@ -140,7 +140,7 @@ fn cs_clone_shallow(name: &str,
let mut stmts = Vec::new(); let mut stmts = Vec::new();
if is_union { if is_union {
// let _: AssertParamIsCopy<Self>; // let _: AssertParamIsCopy<Self>;
let self_ty = cx.ty_path(cx.path_ident(trait_span, keywords::SelfType.ident())); let self_ty = cx.ty_path(cx.path_ident(trait_span, keywords::SelfUpper.ident()));
assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, "AssertParamIsCopy"); assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, "AssertParamIsCopy");
} else { } else {
match *substr.fields { match *substr.fields {

View file

@ -938,7 +938,7 @@ impl<'a> MethodDef<'a> {
let args = { let args = {
let self_args = explicit_self.map(|explicit_self| { let self_args = explicit_self.map(|explicit_self| {
ast::Arg::from_self(explicit_self, ast::Arg::from_self(explicit_self,
keywords::SelfValue.ident().with_span_pos(trait_.span)) keywords::SelfLower.ident().with_span_pos(trait_.span))
}); });
let nonself_args = arg_types.into_iter() let nonself_args = arg_types.into_iter()
.map(|(name, ty)| cx.arg(trait_.span, name, ty)); .map(|(name, ty)| cx.arg(trait_.span, name, ty));

View file

@ -349,7 +349,7 @@ declare_keywords! {
// Special reserved identifiers used internally for elided lifetimes, // Special reserved identifiers used internally for elided lifetimes,
// unnamed method parameters, crate root module, error recovery etc. // unnamed method parameters, crate root module, error recovery etc.
(0, Invalid, "") (0, Invalid, "")
(1, CrateRoot, "{{root}}") (1, PathRoot, "{{root}}")
(2, DollarCrate, "$crate") (2, DollarCrate, "$crate")
(3, Underscore, "_") (3, Underscore, "_")
@ -378,8 +378,8 @@ declare_keywords! {
(25, Pub, "pub") (25, Pub, "pub")
(26, Ref, "ref") (26, Ref, "ref")
(27, Return, "return") (27, Return, "return")
(28, SelfValue, "self") (28, SelfLower, "self")
(29, SelfType, "Self") (29, SelfUpper, "Self")
(30, Static, "static") (30, Static, "static")
(31, Struct, "struct") (31, Struct, "struct")
(32, Super, "super") (32, Super, "super")
@ -462,11 +462,11 @@ impl Ident {
/// A keyword or reserved identifier that can be used as a path segment. /// A keyword or reserved identifier that can be used as a path segment.
pub fn is_path_segment_keyword(self) -> bool { pub fn is_path_segment_keyword(self) -> bool {
self.name == keywords::Super.name() || self.name == keywords::Super.name() ||
self.name == keywords::SelfValue.name() || self.name == keywords::SelfLower.name() ||
self.name == keywords::SelfType.name() || self.name == keywords::SelfUpper.name() ||
self.name == keywords::Extern.name() || self.name == keywords::Extern.name() ||
self.name == keywords::Crate.name() || self.name == keywords::Crate.name() ||
self.name == keywords::CrateRoot.name() || self.name == keywords::PathRoot.name() ||
self.name == keywords::DollarCrate.name() self.name == keywords::DollarCrate.name()
} }