Skip to content

Commit 366c178

Browse files
authored
Rollup merge of #71555 - cjgillot:nameless, r=matthewjasper
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2 parents 8c0310d + 32507d6 commit 366c178

File tree

147 files changed

+539
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+539
-593
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4226,7 +4226,6 @@ name = "rustc_privacy"
42264226
version = "0.0.0"
42274227
dependencies = [
42284228
"log",
4229-
"rustc_ast",
42304229
"rustc_attr",
42314230
"rustc_data_structures",
42324231
"rustc_errors",

src/librustc_ast/ast.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ pub use crate::util::parser::ExprPrecedence;
2222
pub use GenericArgs::*;
2323
pub use UnsafeSource::*;
2424

25-
pub use rustc_span::symbol::{Ident, Symbol as Name};
26-
2725
use crate::ptr::P;
2826
use crate::token::{self, DelimToken};
2927
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
@@ -34,7 +32,7 @@ use rustc_data_structures::thin_vec::ThinVec;
3432
use rustc_macros::HashStable_Generic;
3533
use rustc_serialize::{self, Decoder, Encoder};
3634
use rustc_span::source_map::{respan, Spanned};
37-
use rustc_span::symbol::{kw, sym, Symbol};
35+
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3836
use rustc_span::{Span, DUMMY_SP};
3937

4038
use std::convert::TryFrom;
@@ -2451,7 +2449,7 @@ pub enum ItemKind {
24512449
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
24522450
///
24532451
/// E.g., `extern crate foo` or `extern crate foo_bar as foo`.
2454-
ExternCrate(Option<Name>),
2452+
ExternCrate(Option<Symbol>),
24552453
/// A use declaration item (`use`).
24562454
///
24572455
/// E.g., `use foo;`, `use foo::bar;` or `use foo::bar as FooBar;`.

src/librustc_ast/attr/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use crate::ast;
44
use crate::ast::{AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute};
55
use crate::ast::{Expr, GenericParam, Item, Lit, LitKind, Local, Stmt, StmtKind};
6-
use crate::ast::{Ident, Name, Path, PathSegment};
76
use crate::ast::{MacArgs, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem};
7+
use crate::ast::{Path, PathSegment};
88
use crate::mut_visit::visit_clobber;
99
use crate::ptr::P;
1010
use crate::token::{self, Token};
@@ -14,7 +14,7 @@ use rustc_data_structures::sync::Lock;
1414
use rustc_index::bit_set::GrowableBitSet;
1515
use rustc_span::edition::{Edition, DEFAULT_EDITION};
1616
use rustc_span::source_map::{BytePos, Spanned};
17-
use rustc_span::symbol::{sym, Symbol};
17+
use rustc_span::symbol::{sym, Ident, Symbol};
1818
use rustc_span::Span;
1919

2020
use log::debug;
@@ -113,7 +113,7 @@ impl NestedMetaItem {
113113
}
114114

115115
/// Returns a name and single literal value tuple of the `MetaItem`.
116-
pub fn name_value_literal(&self) -> Option<(Name, &Lit)> {
116+
pub fn name_value_literal(&self) -> Option<(Symbol, &Lit)> {
117117
self.meta_item().and_then(|meta_item| {
118118
meta_item.meta_item_list().and_then(|meta_item_list| {
119119
if meta_item_list.len() == 1 {

src/librustc_ast/mut_visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::tokenstream::*;
1515
use rustc_data_structures::map_in_place::MapInPlace;
1616
use rustc_data_structures::sync::Lrc;
1717
use rustc_span::source_map::{respan, Spanned};
18+
use rustc_span::symbol::Ident;
1819
use rustc_span::Span;
1920

2021
use smallvec::{smallvec, Array, SmallVec};

src/librustc_ast/token.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_macros::HashStable_Generic;
1414
use rustc_span::symbol::kw;
15-
use rustc_span::symbol::Symbol;
15+
use rustc_span::symbol::{Ident, Symbol};
1616
use rustc_span::{self, Span, DUMMY_SP};
1717
use std::borrow::Cow;
1818
use std::{fmt, mem};
@@ -145,7 +145,7 @@ impl Lit {
145145
}
146146
}
147147

148-
pub fn ident_can_begin_expr(name: ast::Name, span: Span, is_raw: bool) -> bool {
148+
pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
149149
let ident_token = Token::new(Ident(name, is_raw), span);
150150

151151
!ident_token.is_reserved_ident()
@@ -173,7 +173,7 @@ pub fn ident_can_begin_expr(name: ast::Name, span: Span, is_raw: bool) -> bool {
173173
.contains(&name)
174174
}
175175

176-
fn ident_can_begin_type(name: ast::Name, span: Span, is_raw: bool) -> bool {
176+
fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool {
177177
let ident_token = Token::new(Ident(name, is_raw), span);
178178

179179
!ident_token.is_reserved_ident()
@@ -229,18 +229,18 @@ pub enum TokenKind {
229229
/// Do not forget about `NtIdent` when you want to match on identifiers.
230230
/// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to
231231
/// treat regular and interpolated identifiers in the same way.
232-
Ident(ast::Name, /* is_raw */ bool),
232+
Ident(Symbol, /* is_raw */ bool),
233233
/// Lifetime identifier token.
234234
/// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
235235
/// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to
236236
/// treat regular and interpolated lifetime identifiers in the same way.
237-
Lifetime(ast::Name),
237+
Lifetime(Symbol),
238238

239239
Interpolated(Lrc<Nonterminal>),
240240

241241
// Can be expanded into several tokens.
242242
/// A doc comment.
243-
DocComment(ast::Name),
243+
DocComment(Symbol),
244244

245245
// Junk. These carry no data because we don't really care about the data
246246
// they *would* carry, and don't really want to allocate a new ident for
@@ -249,9 +249,9 @@ pub enum TokenKind {
249249
Whitespace,
250250
/// A comment.
251251
Comment,
252-
Shebang(ast::Name),
252+
Shebang(Symbol),
253253
/// A completely invalid token which should be skipped.
254-
Unknown(ast::Name),
254+
Unknown(Symbol),
255255

256256
Eof,
257257
}
@@ -325,8 +325,8 @@ impl Token {
325325
Token::new(TokenKind::Whitespace, DUMMY_SP)
326326
}
327327

328-
/// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary.
329-
pub fn from_ast_ident(ident: ast::Ident) -> Self {
328+
/// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary.
329+
pub fn from_ast_ident(ident: Ident) -> Self {
330330
Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span)
331331
}
332332

@@ -488,19 +488,19 @@ impl Token {
488488
}
489489

490490
/// Returns an identifier if this token is an identifier.
491-
pub fn ident(&self) -> Option<(ast::Ident, /* is_raw */ bool)> {
491+
pub fn ident(&self) -> Option<(Ident, /* is_raw */ bool)> {
492492
let token = self.uninterpolate();
493493
match token.kind {
494-
Ident(name, is_raw) => Some((ast::Ident::new(name, token.span), is_raw)),
494+
Ident(name, is_raw) => Some((Ident::new(name, token.span), is_raw)),
495495
_ => None,
496496
}
497497
}
498498

499499
/// Returns a lifetime identifier if this token is a lifetime.
500-
pub fn lifetime(&self) -> Option<ast::Ident> {
500+
pub fn lifetime(&self) -> Option<Ident> {
501501
let token = self.uninterpolate();
502502
match token.kind {
503-
Lifetime(name) => Some(ast::Ident::new(name, token.span)),
503+
Lifetime(name) => Some(Ident::new(name, token.span)),
504504
_ => None,
505505
}
506506
}
@@ -577,28 +577,28 @@ impl Token {
577577
}
578578

579579
pub fn is_path_segment_keyword(&self) -> bool {
580-
self.is_non_raw_ident_where(ast::Ident::is_path_segment_keyword)
580+
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
581581
}
582582

583583
// Returns true for reserved identifiers used internally for elided lifetimes,
584584
// unnamed method parameters, crate root module, error recovery etc.
585585
pub fn is_special_ident(&self) -> bool {
586-
self.is_non_raw_ident_where(ast::Ident::is_special)
586+
self.is_non_raw_ident_where(Ident::is_special)
587587
}
588588

589589
/// Returns `true` if the token is a keyword used in the language.
590590
pub fn is_used_keyword(&self) -> bool {
591-
self.is_non_raw_ident_where(ast::Ident::is_used_keyword)
591+
self.is_non_raw_ident_where(Ident::is_used_keyword)
592592
}
593593

594594
/// Returns `true` if the token is a keyword reserved for possible future use.
595595
pub fn is_unused_keyword(&self) -> bool {
596-
self.is_non_raw_ident_where(ast::Ident::is_unused_keyword)
596+
self.is_non_raw_ident_where(Ident::is_unused_keyword)
597597
}
598598

599599
/// Returns `true` if the token is either a special identifier or a keyword.
600600
pub fn is_reserved_ident(&self) -> bool {
601-
self.is_non_raw_ident_where(ast::Ident::is_reserved)
601+
self.is_non_raw_ident_where(Ident::is_reserved)
602602
}
603603

604604
/// Returns `true` if the token is the identifier `true` or `false`.
@@ -607,7 +607,7 @@ impl Token {
607607
}
608608

609609
/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
610-
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(ast::Ident) -> bool) -> bool {
610+
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool {
611611
match self.ident() {
612612
Some((id, false)) => pred(id),
613613
_ => false,
@@ -746,8 +746,8 @@ pub enum Nonterminal {
746746
NtPat(P<ast::Pat>),
747747
NtExpr(P<ast::Expr>),
748748
NtTy(P<ast::Ty>),
749-
NtIdent(ast::Ident, /* is_raw */ bool),
750-
NtLifetime(ast::Ident),
749+
NtIdent(Ident, /* is_raw */ bool),
750+
NtLifetime(Ident),
751751
NtLiteral(P<ast::Expr>),
752752
/// Stuff inside brackets for attributes
753753
NtMeta(P<ast::AttrItem>),

src/librustc_ast/visit.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::ast::*;
1717
use crate::token::Token;
1818
use crate::tokenstream::{TokenStream, TokenTree};
1919

20+
use rustc_span::symbol::{Ident, Symbol};
2021
use rustc_span::Span;
2122

2223
#[derive(Copy, Clone, PartialEq)]
@@ -74,7 +75,7 @@ impl<'a> FnKind<'a> {
7475
/// to monitor future changes to `Visitor` in case a new method with a
7576
/// new default implementation gets introduced.)
7677
pub trait Visitor<'ast>: Sized {
77-
fn visit_name(&mut self, _span: Span, _name: Name) {
78+
fn visit_name(&mut self, _span: Span, _name: Symbol) {
7879
// Nothing to do.
7980
}
8081
fn visit_ident(&mut self, ident: Ident) {

src/librustc_ast_lowering/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_errors::struct_span_err;
99
use rustc_hir as hir;
1010
use rustc_hir::def::Res;
1111
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
12-
use rustc_span::symbol::{sym, Symbol};
12+
use rustc_span::symbol::{sym, Ident, Symbol};
1313

1414
impl<'hir> LoweringContext<'_, 'hir> {
1515
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {

src/librustc_ast_lowering/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir as hir;
1212
use rustc_hir::def::{DefKind, Res};
1313
use rustc_hir::def_id::LocalDefId;
1414
use rustc_span::source_map::{respan, DesugaringKind};
15-
use rustc_span::symbol::{kw, sym};
15+
use rustc_span::symbol::{kw, sym, Ident};
1616
use rustc_span::Span;
1717
use rustc_target::spec::abi;
1818

src/librustc_ast_lowering/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use rustc_session::parse::ParseSess;
6363
use rustc_session::Session;
6464
use rustc_span::hygiene::ExpnId;
6565
use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind};
66-
use rustc_span::symbol::{kw, sym, Symbol};
66+
use rustc_span::symbol::{kw, sym, Ident, Symbol};
6767
use rustc_span::Span;
6868

6969
use log::{debug, trace};

src/librustc_ast_lowering/pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_ast::ptr::P;
55
use rustc_data_structures::stack::ensure_sufficient_stack;
66
use rustc_hir as hir;
77
use rustc_hir::def::Res;
8+
use rustc_span::symbol::Ident;
89
use rustc_span::{source_map::Spanned, Span};
910

1011
impl<'a, 'hir> LoweringContext<'a, 'hir> {

src/librustc_ast_lowering/path.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_hir::def_id::DefId;
99
use rustc_hir::GenericArg;
1010
use rustc_session::lint::builtin::ELIDED_LIFETIMES_IN_PATHS;
1111
use rustc_session::lint::BuiltinLintDiagnostics;
12+
use rustc_span::symbol::Ident;
1213
use rustc_span::Span;
1314

1415
use log::debug;

src/librustc_ast_passes/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_parse::validate_attr;
2020
use rustc_session::lint::builtin::PATTERNS_IN_FNS_WITHOUT_BODY;
2121
use rustc_session::lint::LintBuffer;
2222
use rustc_session::Session;
23-
use rustc_span::symbol::{kw, sym};
23+
use rustc_span::symbol::{kw, sym, Ident};
2424
use rustc_span::Span;
2525
use std::mem;
2626
use std::ops::DerefMut;

src/librustc_ast_passes/feature_gate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP};
77
use rustc_feature::{Features, GateIssue, UnstableFeatures};
88
use rustc_session::parse::{feature_err, feature_err_issue, ParseSess};
99
use rustc_span::source_map::Spanned;
10-
use rustc_span::symbol::sym;
10+
use rustc_span::symbol::{sym, Symbol};
1111
use rustc_span::Span;
1212

1313
use log::debug;
@@ -252,7 +252,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
252252
}
253253
}
254254

255-
fn visit_name(&mut self, sp: Span, name: ast::Name) {
255+
fn visit_name(&mut self, sp: Span, name: Symbol) {
256256
if !name.as_str().is_ascii() {
257257
gate_feature_post!(
258258
&self,

src/librustc_ast_passes/node_count.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use rustc_ast::ast::*;
44
use rustc_ast::visit::*;
5+
use rustc_span::symbol::Ident;
56
use rustc_span::Span;
67

78
pub struct NodeCounter {

0 commit comments

Comments
 (0)