Skip to content

Commit d582ea3

Browse files
authored
Unrolled build for rust-lang#123462
Rollup merge of rust-lang#123462 - fmease:rn-mod-sep-to-path-sep, r=nnethercote Cleanup: Rename `ModSep` to `PathSep` `::` is usually referred to as the *path separator* (citation needed). The existing name `ModSep` for *module separator* is a bit misleading since it in fact separates the segments of arbitrary path segments, not only ones resolving to modules. Let me just give a shout-out to associated items (`T::Assoc`, `<Ty as Trait>::function`) and enum variants (`Option::None`). Motivation: Reduce friction for new contributors, prevent potential confusion. cc `@petrochenkov` r? nnethercote or compiler
2 parents ccfcd95 + 3cbc9e9 commit d582ea3

File tree

13 files changed

+44
-42
lines changed

13 files changed

+44
-42
lines changed

compiler/rustc_ast/src/attr/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ impl MetaItem {
308308
// FIXME: Share code with `parse_path`.
309309
let path = match tokens.next().map(|tt| TokenTree::uninterpolate(tt)).as_deref() {
310310
Some(&TokenTree::Token(
311-
Token { kind: ref kind @ (token::Ident(..) | token::ModSep), span },
311+
Token { kind: ref kind @ (token::Ident(..) | token::PathSep), span },
312312
_,
313313
)) => 'arm: {
314314
let mut segments = if let &token::Ident(name, _) = kind {
315-
if let Some(TokenTree::Token(Token { kind: token::ModSep, .. }, _)) =
315+
if let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) =
316316
tokens.peek()
317317
{
318318
tokens.next();
@@ -331,7 +331,7 @@ impl MetaItem {
331331
} else {
332332
return None;
333333
}
334-
if let Some(TokenTree::Token(Token { kind: token::ModSep, .. }, _)) =
334+
if let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) =
335335
tokens.peek()
336336
{
337337
tokens.next();

compiler/rustc_ast/src/token.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub enum TokenKind {
290290
/// `:`
291291
Colon,
292292
/// `::`
293-
ModSep,
293+
PathSep,
294294
/// `->`
295295
RArrow,
296296
/// `<-`
@@ -393,7 +393,7 @@ impl TokenKind {
393393
BinOpEq(Shr) => (Gt, Ge),
394394
DotDot => (Dot, Dot),
395395
DotDotDot => (Dot, DotDot),
396-
ModSep => (Colon, Colon),
396+
PathSep => (Colon, Colon),
397397
RArrow => (BinOp(Minus), Gt),
398398
LArrow => (Lt, BinOp(Minus)),
399399
FatArrow => (Eq, Gt),
@@ -454,7 +454,9 @@ impl Token {
454454
match self.kind {
455455
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
456456
| BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon
457-
| ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true,
457+
| PathSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => {
458+
true
459+
}
458460

459461
OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..)
460462
| Lifetime(..) | Interpolated(..) | Eof => false,
@@ -481,7 +483,7 @@ impl Token {
481483
// DotDotDot is no longer supported, but we need some way to display the error
482484
DotDot | DotDotDot | DotDotEq | // range notation
483485
Lt | BinOp(Shl) | // associated path
484-
ModSep | // global path
486+
PathSep | // global path
485487
Lifetime(..) | // labeled loop
486488
Pound => true, // expression attributes
487489
Interpolated(ref nt) => matches!(&nt.0, NtLiteral(..) |
@@ -507,7 +509,7 @@ impl Token {
507509
// DotDotDot is no longer supported
508510
| DotDot | DotDotDot | DotDotEq // ranges
509511
| Lt | BinOp(Shl) // associated path
510-
| ModSep => true, // global path
512+
| PathSep => true, // global path
511513
Interpolated(ref nt) => matches!(&nt.0, NtLiteral(..) |
512514
NtPat(..) |
513515
NtBlock(..) |
@@ -530,7 +532,7 @@ impl Token {
530532
Question | // maybe bound in trait object
531533
Lifetime(..) | // lifetime bound in trait object
532534
Lt | BinOp(Shl) | // associated path
533-
ModSep => true, // global path
535+
PathSep => true, // global path
534536
Interpolated(ref nt) => matches!(&nt.0, NtTy(..) | NtPath(..)),
535537
// For anonymous structs or unions, which only appear in specific positions
536538
// (type of struct fields or union fields), we don't consider them as regular types
@@ -708,7 +710,7 @@ impl Token {
708710
}
709711

710712
pub fn is_path_start(&self) -> bool {
711-
self == &ModSep
713+
self == &PathSep
712714
|| self.is_qpath_start()
713715
|| self.is_whole_path()
714716
|| self.is_path_segment_keyword()
@@ -821,7 +823,7 @@ impl Token {
821823
_ => return None,
822824
},
823825
Colon => match joint.kind {
824-
Colon => ModSep,
826+
Colon => PathSep,
825827
_ => return None,
826828
},
827829
SingleQuote => match joint.kind {
@@ -830,7 +832,7 @@ impl Token {
830832
},
831833

832834
Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot
833-
| DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar
835+
| DotDotEq | Comma | Semi | PathSep | RArrow | LArrow | FatArrow | Pound | Dollar
834836
| Question | OpenDelim(..) | CloseDelim(..) | Literal(..) | Ident(..)
835837
| Lifetime(..) | Interpolated(..) | DocComment(..) | Eof => return None,
836838
};

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
893893
token::Comma => ",".into(),
894894
token::Semi => ";".into(),
895895
token::Colon => ":".into(),
896-
token::ModSep => "::".into(),
896+
token::PathSep => "::".into(),
897897
token::RArrow => "->".into(),
898898
token::LArrow => "<-".into(),
899899
token::FatArrow => "=>".into(),

compiler/rustc_expand/src/proc_macro_server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
208208
Comma => op(","),
209209
Semi => op(";"),
210210
Colon => op(":"),
211-
ModSep => op("::"),
211+
PathSep => op("::"),
212212
RArrow => op("->"),
213213
LArrow => op("<-"),
214214
FatArrow => op("=>"),

compiler/rustc_parse/src/parser/diagnostics.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'a> Parser<'a> {
279279
TokenKind::Colon,
280280
TokenKind::Comma,
281281
TokenKind::Semi,
282-
TokenKind::ModSep,
282+
TokenKind::PathSep,
283283
TokenKind::OpenDelim(Delimiter::Brace),
284284
TokenKind::OpenDelim(Delimiter::Parenthesis),
285285
TokenKind::CloseDelim(Delimiter::Brace),
@@ -1169,7 +1169,7 @@ impl<'a> Parser<'a> {
11691169
return;
11701170
}
11711171

1172-
if token::ModSep == self.token.kind && segment.args.is_none() {
1172+
if token::PathSep == self.token.kind && segment.args.is_none() {
11731173
let snapshot = self.create_snapshot_for_diagnostic();
11741174
self.bump();
11751175
let lo = self.token.span;
@@ -1420,15 +1420,15 @@ impl<'a> Parser<'a> {
14201420
[(token::Lt, 1), (token::Gt, -1), (token::BinOp(token::Shr), -2)];
14211421
self.consume_tts(1, &modifiers);
14221422

1423-
if !&[token::OpenDelim(Delimiter::Parenthesis), token::ModSep]
1423+
if !&[token::OpenDelim(Delimiter::Parenthesis), token::PathSep]
14241424
.contains(&self.token.kind)
14251425
{
14261426
// We don't have `foo< bar >(` or `foo< bar >::`, so we rewind the
14271427
// parser and bail out.
14281428
self.restore_snapshot(snapshot);
14291429
}
14301430
}
1431-
return if token::ModSep == self.token.kind {
1431+
return if token::PathSep == self.token.kind {
14321432
// We have some certainty that this was a bad turbofish at this point.
14331433
// `foo< bar >::`
14341434
if let ExprKind::Binary(o, ..) = inner_op.kind
@@ -1784,7 +1784,7 @@ impl<'a> Parser<'a> {
17841784
}
17851785

17861786
// Do not add `::` to expected tokens.
1787-
if self.token == token::ModSep {
1787+
if self.token == token::PathSep {
17881788
if let Some(ty) = base.to_ty() {
17891789
return self.maybe_recover_from_bad_qpath_stage_2(ty.span, ty);
17901790
}
@@ -1799,7 +1799,7 @@ impl<'a> Parser<'a> {
17991799
ty_span: Span,
18001800
ty: P<Ty>,
18011801
) -> PResult<'a, P<T>> {
1802-
self.expect(&token::ModSep)?;
1802+
self.expect(&token::PathSep)?;
18031803

18041804
let mut path = ast::Path { segments: ThinVec::new(), span: DUMMY_SP, tokens: None };
18051805
self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None)?;

compiler/rustc_parse/src/parser/item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,12 @@ impl<'a> Parser<'a> {
358358
fn is_reuse_path_item(&mut self) -> bool {
359359
// no: `reuse ::path` for compatibility reasons with macro invocations
360360
self.token.is_keyword(kw::Reuse)
361-
&& self.look_ahead(1, |t| t.is_path_start() && t.kind != token::ModSep)
361+
&& self.look_ahead(1, |t| t.is_path_start() && t.kind != token::PathSep)
362362
}
363363

364364
/// Are we sure this could not possibly be a macro invocation?
365365
fn isnt_macro_invocation(&mut self) -> bool {
366-
self.check_ident() && self.look_ahead(1, |t| *t != token::Not && *t != token::ModSep)
366+
self.check_ident() && self.look_ahead(1, |t| *t != token::Not && *t != token::PathSep)
367367
}
368368

369369
/// Recover on encountering a struct or method definition where the user
@@ -1020,7 +1020,7 @@ impl<'a> Parser<'a> {
10201020
{
10211021
// `use *;` or `use ::*;` or `use {...};` or `use ::{...};`
10221022
let mod_sep_ctxt = self.token.span.ctxt();
1023-
if self.eat(&token::ModSep) {
1023+
if self.eat(&token::PathSep) {
10241024
prefix
10251025
.segments
10261026
.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)));
@@ -1031,7 +1031,7 @@ impl<'a> Parser<'a> {
10311031
// `use path::*;` or `use path::{...};` or `use path;` or `use path as bar;`
10321032
prefix = self.parse_path(PathStyle::Mod)?;
10331033

1034-
if self.eat(&token::ModSep) {
1034+
if self.eat(&token::PathSep) {
10351035
self.parse_use_tree_glob_or_nested()?
10361036
} else {
10371037
// Recover from using a colon as path separator.
@@ -2752,7 +2752,7 @@ impl<'a> Parser<'a> {
27522752
// Is `self` `n` tokens ahead?
27532753
let is_isolated_self = |this: &Self, n| {
27542754
this.is_keyword_ahead(n, &[kw::SelfLower])
2755-
&& this.look_ahead(n + 1, |t| t != &token::ModSep)
2755+
&& this.look_ahead(n + 1, |t| t != &token::PathSep)
27562756
};
27572757
// Is `mut self` `n` tokens ahead?
27582758
let is_isolated_mut_self =

compiler/rustc_parse/src/parser/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
109109
($self: expr, $allow_qpath_recovery: expr) => {
110110
if $allow_qpath_recovery
111111
&& $self.may_recover()
112-
&& $self.look_ahead(1, |t| t == &token::ModSep)
112+
&& $self.look_ahead(1, |t| t == &token::PathSep)
113113
&& let token::Interpolated(nt) = &$self.token.kind
114114
&& let token::NtTy(ty) = &nt.0
115115
{
@@ -1532,7 +1532,7 @@ impl<'a> Parser<'a> {
15321532

15331533
/// `::{` or `::*`
15341534
fn is_import_coupler(&mut self) -> bool {
1535-
self.check(&token::ModSep)
1535+
self.check(&token::PathSep)
15361536
&& self.look_ahead(1, |t| {
15371537
*t == token::OpenDelim(Delimiter::Brace) || *t == token::BinOp(token::Star)
15381538
})

compiler/rustc_parse/src/parser/nonterminal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a> Parser<'a> {
6262
_ => false,
6363
},
6464
NonterminalKind::Path | NonterminalKind::Meta => match &token.kind {
65-
token::ModSep | token::Ident(..) => true,
65+
token::PathSep | token::Ident(..) => true,
6666
token::Interpolated(nt) => may_be_ident(&nt.0),
6767
_ => false,
6868
},
@@ -76,7 +76,7 @@ impl<'a> Parser<'a> {
7676
token::Literal(_) | // literal
7777
token::DotDot | // range pattern (future compat)
7878
token::DotDotDot | // range pattern (future compat)
79-
token::ModSep | // path
79+
token::PathSep | // path
8080
token::Lt | // path (UFCS constant)
8181
token::BinOp(token::Shl) => true, // path (double UFCS)
8282
// leading vert `|` or-pattern

compiler/rustc_parse/src/parser/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ impl<'a> Parser<'a> {
10161016
&& self.look_ahead(1, |t| !matches!(t.kind, token::OpenDelim(Delimiter::Parenthesis) // A tuple struct pattern.
10171017
| token::OpenDelim(Delimiter::Brace) // A struct pattern.
10181018
| token::DotDotDot | token::DotDotEq | token::DotDot // A range pattern.
1019-
| token::ModSep // A tuple / struct variant pattern.
1019+
| token::PathSep // A tuple / struct variant pattern.
10201020
| token::Not)) // A macro expanding to a pattern.
10211021
}
10221022

compiler/rustc_parse/src/parser/path.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'a> Parser<'a> {
9696
}
9797

9898
if !self.recover_colon_before_qpath_proj() {
99-
self.expect(&token::ModSep)?;
99+
self.expect(&token::PathSep)?;
100100
}
101101

102102
let qself = P(QSelf { ty, path_span, position: path.segments.len() });
@@ -200,7 +200,7 @@ impl<'a> Parser<'a> {
200200
let lo = self.token.span;
201201
let mut segments = ThinVec::new();
202202
let mod_sep_ctxt = self.token.span.ctxt();
203-
if self.eat(&token::ModSep) {
203+
if self.eat(&token::PathSep) {
204204
segments.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)));
205205
}
206206
self.parse_path_segments(&mut segments, style, ty_generics)?;
@@ -232,11 +232,11 @@ impl<'a> Parser<'a> {
232232
// `PathStyle::Expr` is only provided at the root invocation and never in
233233
// `parse_path_segment` to recurse and therefore can be checked to maintain
234234
// this invariant.
235-
self.check_trailing_angle_brackets(&segment, &[&token::ModSep]);
235+
self.check_trailing_angle_brackets(&segment, &[&token::PathSep]);
236236
}
237237
segments.push(segment);
238238

239-
if self.is_import_coupler() || !self.eat(&token::ModSep) {
239+
if self.is_import_coupler() || !self.eat(&token::PathSep) {
240240
if style == PathStyle::Expr
241241
&& self.may_recover()
242242
&& self.token == token::Colon
@@ -291,7 +291,7 @@ impl<'a> Parser<'a> {
291291
Ok(
292292
if style == PathStyle::Type && check_args_start(self)
293293
|| style != PathStyle::Mod
294-
&& self.check(&token::ModSep)
294+
&& self.check(&token::PathSep)
295295
&& self.look_ahead(1, |t| is_args_start(t))
296296
{
297297
// We use `style == PathStyle::Expr` to check if this is in a recursion or not. If
@@ -303,7 +303,7 @@ impl<'a> Parser<'a> {
303303
}
304304

305305
// Generic arguments are found - `<`, `(`, `::<` or `::(`.
306-
self.eat(&token::ModSep);
306+
self.eat(&token::PathSep);
307307
let lo = self.token.span;
308308
let args = if self.eat_lt() {
309309
// `<'a, T, A = U>`
@@ -379,7 +379,7 @@ impl<'a> Parser<'a> {
379379
let token_before_parsing = self.token.clone();
380380
let mut snapshot = None;
381381
if self.may_recover()
382-
&& prev_token_before_parsing.kind == token::ModSep
382+
&& prev_token_before_parsing.kind == token::PathSep
383383
&& (style == PathStyle::Expr && self.token.can_begin_expr()
384384
|| style == PathStyle::Pat && self.token.can_begin_pattern())
385385
{
@@ -388,7 +388,7 @@ impl<'a> Parser<'a> {
388388

389389
let (inputs, _) = match self.parse_paren_comma_seq(|p| p.parse_ty()) {
390390
Ok(output) => output,
391-
Err(mut error) if prev_token_before_parsing.kind == token::ModSep => {
391+
Err(mut error) if prev_token_before_parsing.kind == token::PathSep => {
392392
error.span_label(
393393
prev_token_before_parsing.span.to(token_before_parsing.span),
394394
"while parsing this parenthesized list of type arguments starting here",
@@ -470,7 +470,7 @@ impl<'a> Parser<'a> {
470470
}
471471
}
472472

473-
if let token::ModSep | token::RArrow = self.token.kind {
473+
if let token::PathSep | token::RArrow = self.token.kind {
474474
return;
475475
}
476476

compiler/rustc_parse/src/parser/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ enum AllowCVariadic {
8282
/// Types can also be of the form `IDENT(u8, u8) -> u8`, however this assumes
8383
/// that `IDENT` is not the ident of a fn trait.
8484
fn can_continue_type_after_non_fn_ident(t: &Token) -> bool {
85-
t == &token::ModSep || t == &token::Lt || t == &token::BinOp(token::Shl)
85+
t == &token::PathSep || t == &token::Lt || t == &token::BinOp(token::Shl)
8686
}
8787

8888
fn can_begin_dyn_bound_in_edition_2015(t: &Token) -> bool {

src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
8888
if !prev_is_dollar
8989
&& let Some(span) = is_crate_keyword(curr)
9090
&& let Some(next) = cursor.look_ahead(0)
91-
&& is_token(next, &TokenKind::ModSep)
91+
&& is_token(next, &TokenKind::PathSep)
9292
{
9393
return Some(span);
9494
}

src/tools/rustfmt/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ fn next_space(tok: &TokenKind) -> SpaceState {
10911091
| TokenKind::DotDotEq
10921092
| TokenKind::Question => SpaceState::Punctuation,
10931093

1094-
TokenKind::ModSep
1094+
TokenKind::PathSep
10951095
| TokenKind::Pound
10961096
| TokenKind::Dollar
10971097
| TokenKind::OpenDelim(_)

0 commit comments

Comments
 (0)