Skip to content

Commit 062451a

Browse files
committed
XXX: kw::PathRoot
1 parent 25290c0 commit 062451a

File tree

26 files changed

+57
-61
lines changed

26 files changed

+57
-61
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl fmt::Display for Lifetime {
9292
pub struct Path {
9393
pub span: Span,
9494
/// The segments in the path: the things separated by `::`.
95-
/// Global paths begin with `kw::PathRoot`.
95+
/// Global paths begin with `sym::path_root`.
9696
pub segments: ThinVec<PathSegment>,
9797
pub tokens: Option<LazyAttrTokenStream>,
9898
}
@@ -121,7 +121,7 @@ impl Path {
121121
}
122122

123123
pub fn is_global(&self) -> bool {
124-
!self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot
124+
!self.segments.is_empty() && self.segments[0].ident.name == sym::path_root
125125
}
126126

127127
/// If this path is a single identifier with no arguments, does not ensure
@@ -156,7 +156,7 @@ impl PathSegment {
156156
}
157157

158158
pub fn path_root(span: Span) -> Self {
159-
PathSegment::from_ident(Ident::new(kw::PathRoot, span))
159+
PathSegment::from_ident(Ident::new(sym::path_root, span))
160160
}
161161

162162
pub fn span(&self) -> Span {

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ impl Token {
918918
}
919919

920920
/// Returns true for reserved identifiers used internally for elided lifetimes,
921-
/// unnamed method parameters, crate root module, error recovery etc.
921+
/// unnamed method parameters, error recovery etc.
922922
pub fn is_special_ident(&self) -> bool {
923923
self.is_non_raw_ident_where(Ident::is_special)
924924
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
564564
let path = if trees.is_empty()
565565
&& !(prefix.segments.is_empty()
566566
|| prefix.segments.len() == 1
567-
&& prefix.segments[0].ident.name == kw::PathRoot)
567+
&& prefix.segments[0].ident.name == sym::path_root)
568568
{
569569
// For empty lists we need to lower the prefix so it is checked for things
570570
// like stability later.

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
834834
}
835835

836836
fn print_path_segment(&mut self, segment: &ast::PathSegment, colons_before_params: bool) {
837-
if segment.ident.name != kw::PathRoot {
837+
if segment.ident.name != sym::path_root {
838838
self.print_ident(segment.ident);
839839
if let Some(args) = &segment.args {
840840
self.print_generic_args(args, colons_before_params);

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn inject(
7575
// the one with the prelude.
7676
let name = names[0];
7777

78-
let root = (edition == Edition2015).then_some(kw::PathRoot);
78+
let root = (edition == Edition2015).then_some(sym::path_root);
7979

8080
let import_path = root
8181
.iter()

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1717
use rustc_span::def_id::LocalDefId;
1818
use rustc_span::hygiene::MacroKind;
1919
use rustc_span::source_map::Spanned;
20-
use rustc_span::symbol::{Ident, Symbol, kw, sym};
20+
use rustc_span::symbol::{Ident, Symbol, sym};
2121
use rustc_span::{BytePos, DUMMY_SP, ErrorGuaranteed, Span};
2222
use rustc_target::asm::InlineAsmRegOrRegClass;
2323
use smallvec::SmallVec;
@@ -199,7 +199,7 @@ pub type UsePath<'hir> = Path<'hir, SmallVec<[Res; 3]>>;
199199

200200
impl Path<'_> {
201201
pub fn is_global(&self) -> bool {
202-
!self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot
202+
!self.segments.is_empty() && self.segments[0].ident.name == sym::path_root
203203
}
204204
}
205205

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_hir::{
2020
};
2121
use rustc_span::FileName;
2222
use rustc_span::source_map::SourceMap;
23-
use rustc_span::symbol::{Ident, Symbol, kw};
23+
use rustc_span::symbol::{Ident, Symbol, sym};
2424
use {rustc_ast as ast, rustc_hir as hir};
2525

2626
pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: HirId) -> String {
@@ -1563,15 +1563,15 @@ impl<'a> State<'a> {
15631563
if i > 0 {
15641564
self.word("::")
15651565
}
1566-
if segment.ident.name != kw::PathRoot {
1566+
if segment.ident.name != sym::path_root {
15671567
self.print_ident(segment.ident);
15681568
self.print_generic_args(segment.args(), colons_before_params);
15691569
}
15701570
}
15711571
}
15721572

15731573
fn print_path_segment(&mut self, segment: &hir::PathSegment<'_>) {
1574-
if segment.ident.name != kw::PathRoot {
1574+
if segment.ident.name != sym::path_root {
15751575
self.print_ident(segment.ident);
15761576
self.print_generic_args(segment.args(), false);
15771577
}
@@ -1590,7 +1590,7 @@ impl<'a> State<'a> {
15901590
if i > 0 {
15911591
self.word("::")
15921592
}
1593-
if segment.ident.name != kw::PathRoot {
1593+
if segment.ident.name != sym::path_root {
15941594
self.print_ident(segment.ident);
15951595
self.print_generic_args(segment.args(), colons_before_params);
15961596
}

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
332332
None
333333
} else if ident.span.is_rust_2015() {
334334
Some(Segment::from_ident(Ident::new(
335-
kw::PathRoot,
335+
sym::path_root,
336336
path.span.shrink_to_lo().with_ctxt(ident.span.ctxt()),
337337
)))
338338
} else {
@@ -514,7 +514,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
514514
}
515515
.map(|ctxt| {
516516
Segment::from_ident(Ident::new(
517-
kw::PathRoot,
517+
sym::path_root,
518518
use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt),
519519
))
520520
});
@@ -523,7 +523,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
523523
debug!("build_reduced_graph_for_use_tree: prefix={:?}", prefix);
524524

525525
let empty_for_self = |prefix: &[Segment]| {
526-
prefix.is_empty() || prefix.len() == 1 && prefix[0].ident.name == kw::PathRoot
526+
prefix.is_empty() || prefix.len() == 1 && prefix[0].ident.name == sym::path_root
527527
};
528528
match use_tree.kind {
529529
ast::UseTreeKind::Simple(rename) => {
@@ -595,7 +595,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
595595
if crate_name != sym::empty {
596596
// `crate_name` should not be interpreted as relative.
597597
module_path.push(Segment::from_ident_and_id(
598-
Ident { name: kw::PathRoot, span: source.ident.span },
598+
Ident { name: sym::path_root, span: source.ident.span },
599599
self.r.next_node_id(),
600600
));
601601
source.ident.name = crate_name;

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
493493

494494
// We're only interested in `use` paths which should start with
495495
// `{{root}}` currently.
496-
if first_name != kw::PathRoot {
496+
if first_name != sym::path_root {
497497
return;
498498
}
499499

@@ -1077,7 +1077,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10771077
}
10781078
}
10791079
Scope::CrateRoot => {
1080-
let root_ident = Ident::new(kw::PathRoot, ident.span);
1080+
let root_ident = Ident::new(sym::path_root, ident.span);
10811081
let root_module = this.resolve_crate_root(root_ident);
10821082
this.add_module_candidates(root_module, &mut suggestions, filter_fn, None);
10831083
}
@@ -2059,10 +2059,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20592059
let parent = match parent {
20602060
// ::foo is mounted at the crate root for 2015, and is the extern
20612061
// prelude for 2018+
2062-
kw::PathRoot if self.tcx.sess.edition() > Edition::Edition2015 => {
2062+
sym::path_root if self.tcx.sess.edition() > Edition::Edition2015 => {
20632063
"the list of imported crates".to_owned()
20642064
}
2065-
kw::PathRoot | kw::Crate => "the crate root".to_owned(),
2065+
sym::path_root | kw::Crate => "the crate root".to_owned(),
20662066
_ => format!("`{parent}`"),
20672067
};
20682068

@@ -2244,7 +2244,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22442244
// `{{root}}::ident::...` on both editions.
22452245
// On 2015 `{{root}}` is usually added implicitly.
22462246
(Some(fst), Some(snd))
2247-
if fst.ident.name == kw::PathRoot && !snd.ident.is_path_segment_keyword() => {}
2247+
if fst.ident.name == sym::path_root && !snd.ident.is_path_segment_keyword() => {}
22482248
// `ident::...` on 2018.
22492249
(Some(fst), _)
22502250
if fst.ident.span.at_least_rust_2018() && !fst.ident.is_path_segment_keyword() =>

compiler/rustc_resolve/src/ident.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
498498
_ => Err(Determinacy::Determined),
499499
},
500500
Scope::CrateRoot => {
501-
let root_ident = Ident::new(kw::PathRoot, ident.span);
501+
let root_ident = Ident::new(sym::path_root, ident.span);
502502
let root_module = this.resolve_crate_root(root_ident);
503503
let binding = this.resolve_ident_in_module(
504504
ModuleOrUniformRoot::Module(root_module),
@@ -1485,19 +1485,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14851485
module = Some(ModuleOrUniformRoot::Module(self_mod));
14861486
continue;
14871487
}
1488-
if name == kw::PathRoot && ident.span.at_least_rust_2018() {
1488+
if name == sym::path_root && ident.span.at_least_rust_2018() {
14891489
module = Some(ModuleOrUniformRoot::ExternPrelude);
14901490
continue;
14911491
}
1492-
if name == kw::PathRoot
1492+
if name == sym::path_root
14931493
&& ident.span.is_rust_2015()
14941494
&& self.tcx.sess.at_least_rust_2018()
14951495
{
14961496
// `::a::b` from 2015 macro on 2018 global edition
14971497
module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude);
14981498
continue;
14991499
}
1500-
if name == kw::PathRoot || name == kw::Crate || name == kw::DollarCrate {
1500+
if name == sym::path_root || name == kw::Crate || name == kw::DollarCrate {
15011501
// `::a::b`, `crate::a::b` or `$crate::a::b`
15021502
let crate_root = self.resolve_crate_root(ident);
15031503
if let Some(res) = crate_root.res() {
@@ -1512,12 +1512,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15121512
// Report special messages for path segment keywords in wrong positions.
15131513
if ident.is_path_segment_keyword() && segment_idx != 0 {
15141514
return PathResult::failed(ident, false, finalize.is_some(), module, || {
1515-
let name_str = if name == kw::PathRoot {
1515+
let name_str = if name == sym::path_root {
15161516
"crate root".to_string()
15171517
} else {
15181518
format!("`{name}`")
15191519
};
1520-
let label = if segment_idx == 1 && path[0].ident.name == kw::PathRoot {
1520+
let label = if segment_idx == 1 && path[0].ident.name == sym::path_root {
15211521
format!("global paths cannot start with {name_str}")
15221522
} else {
15231523
format!("{name_str} in paths can only be used in start position")

0 commit comments

Comments
 (0)