From d4e143ed2f248a808fb5f1cf959f630d419cc01b Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 19 Apr 2020 13:00:18 +0200 Subject: [PATCH 1/3] Remove ast::{Ident, Name} reexports. --- Cargo.lock | 1 - src/librustc_ast/ast.rs | 6 +- src/librustc_ast/attr/mod.rs | 6 +- src/librustc_ast/mut_visit.rs | 1 + src/librustc_ast/token.rs | 44 ++++++------- src/librustc_ast/visit.rs | 3 +- src/librustc_ast_lowering/expr.rs | 2 +- src/librustc_ast_lowering/item.rs | 2 +- src/librustc_ast_lowering/lib.rs | 2 +- src/librustc_ast_lowering/pat.rs | 1 + src/librustc_ast_lowering/path.rs | 1 + src/librustc_ast_passes/ast_validation.rs | 2 +- src/librustc_ast_passes/feature_gate.rs | 4 +- src/librustc_ast_passes/node_count.rs | 1 + src/librustc_ast_pretty/pprust.rs | 34 +++++----- src/librustc_builtin_macros/assert.rs | 2 +- src/librustc_builtin_macros/concat_idents.rs | 6 +- src/librustc_builtin_macros/deriving/clone.rs | 5 +- .../deriving/cmp/eq.rs | 4 +- .../deriving/cmp/ord.rs | 8 +-- .../deriving/cmp/partial_ord.rs | 6 +- src/librustc_builtin_macros/deriving/debug.rs | 4 +- .../deriving/generic/mod.rs | 20 +++--- .../deriving/generic/ty.rs | 4 +- src/librustc_builtin_macros/deriving/mod.rs | 4 +- src/librustc_builtin_macros/env.rs | 4 +- src/librustc_builtin_macros/format.rs | 6 +- .../global_allocator.rs | 4 +- src/librustc_builtin_macros/global_asm.rs | 3 +- src/librustc_builtin_macros/lib.rs | 3 +- .../proc_macro_harness.rs | 10 +-- .../standard_library_imports.rs | 6 +- src/librustc_builtin_macros/test.rs | 12 ++-- src/librustc_builtin_macros/test_harness.rs | 4 +- .../debuginfo/metadata.rs | 7 +- src/librustc_codegen_llvm/debuginfo/mod.rs | 3 +- src/librustc_codegen_ssa/traits/debuginfo.rs | 5 +- src/librustc_driver/pretty.rs | 3 +- src/librustc_expand/base.rs | 16 ++--- src/librustc_expand/build.rs | 64 +++++++------------ src/librustc_expand/expand.rs | 4 +- src/librustc_expand/mbe.rs | 10 +-- src/librustc_expand/mbe/macro_parser.rs | 3 +- src/librustc_expand/mbe/macro_rules.rs | 16 ++--- src/librustc_expand/mbe/quoted.rs | 7 +- src/librustc_expand/module.rs | 14 ++-- src/librustc_expand/placeholders.rs | 3 +- src/librustc_expand/proc_macro_server.rs | 4 +- src/librustc_hir/hir.rs | 8 +-- src/librustc_hir/intravisit.rs | 7 +- src/librustc_hir/pat_util.rs | 8 +-- src/librustc_hir_pretty/lib.rs | 32 +++++----- src/librustc_incremental/assert_dep_graph.rs | 6 +- .../assert_module_sources.rs | 2 +- .../persist/dirty_clean.rs | 2 +- src/librustc_infer/infer/mod.rs | 5 +- .../traits/error_reporting/mod.rs | 4 +- src/librustc_lint/builtin.rs | 6 +- src/librustc_lint/early.rs | 3 +- src/librustc_lint/internal.rs | 4 +- src/librustc_lint/late.rs | 5 +- src/librustc_lint/lib.rs | 1 + src/librustc_lint/non_ascii_idents.rs | 4 +- src/librustc_lint/passes.rs | 5 +- src/librustc_metadata/rmeta/decoder.rs | 10 +-- .../rmeta/decoder/cstore_impl.rs | 4 +- src/librustc_metadata/rmeta/encoder.rs | 10 +-- src/librustc_metadata/rmeta/mod.rs | 4 +- src/librustc_middle/arena.rs | 2 +- src/librustc_middle/hir/exports.rs | 4 +- src/librustc_middle/hir/map/blocks.rs | 3 +- src/librustc_middle/hir/map/mod.rs | 26 ++++---- src/librustc_middle/mir/mod.rs | 3 +- src/librustc_middle/query/mod.rs | 4 +- src/librustc_middle/traits/mod.rs | 10 +-- .../traits/specialization_graph.rs | 2 +- src/librustc_middle/ty/context.rs | 10 +-- src/librustc_middle/ty/layout.rs | 7 +- src/librustc_middle/ty/mod.rs | 6 +- src/librustc_middle/ty/print/pretty.rs | 4 +- src/librustc_middle/ty/query/on_disk_cache.rs | 2 +- src/librustc_middle/ty/sty.rs | 4 +- src/librustc_mir/borrow_check/mod.rs | 7 +- src/librustc_mir/transform/mod.rs | 5 +- src/librustc_mir_build/build/matches/mod.rs | 8 +-- src/librustc_mir_build/hair/pattern/mod.rs | 6 +- src/librustc_parse/parser/diagnostics.rs | 6 +- src/librustc_parse/parser/expr.rs | 4 +- src/librustc_parse/parser/item.rs | 8 +-- src/librustc_parse/parser/mod.rs | 8 +-- src/librustc_parse/parser/pat.rs | 4 +- src/librustc_parse/parser/path.rs | 4 +- src/librustc_passes/dead.rs | 6 +- src/librustc_passes/liveness.rs | 7 +- src/librustc_plugin_impl/load.rs | 4 +- src/librustc_privacy/Cargo.toml | 1 - src/librustc_privacy/lib.rs | 3 +- src/librustc_resolve/build_reduced_graph.rs | 7 +- src/librustc_resolve/diagnostics.rs | 4 +- src/librustc_resolve/imports.rs | 6 +- src/librustc_resolve/late.rs | 4 +- src/librustc_resolve/late/diagnostics.rs | 6 +- src/librustc_resolve/late/lifetimes.rs | 25 +++----- src/librustc_resolve/lib.rs | 52 +++++++-------- src/librustc_resolve/macros.rs | 6 +- src/librustc_save_analysis/dump_visitor.rs | 5 +- src/librustc_save_analysis/lib.rs | 5 +- src/librustc_save_analysis/sig.rs | 15 +++-- .../traits/project.rs | 3 +- src/librustc_typeck/astconv.rs | 19 ++---- src/librustc_typeck/check/autoderef.rs | 2 +- src/librustc_typeck/check/callee.rs | 2 +- src/librustc_typeck/check/expr.rs | 20 +++--- src/librustc_typeck/check/method/mod.rs | 14 ++-- src/librustc_typeck/check/method/probe.rs | 12 ++-- src/librustc_typeck/check/method/suggest.rs | 9 ++- src/librustc_typeck/check/mod.rs | 14 ++-- src/librustc_typeck/check/op.rs | 2 +- src/librustc_typeck/check/pat.rs | 9 +-- src/librustc_typeck/check/upvar.rs | 9 ++- src/librustc_typeck/check/wfcheck.rs | 6 +- src/librustc_typeck/check_unused.rs | 5 +- src/librustc_typeck/collect.rs | 6 +- src/librustdoc/clean/inline.rs | 5 +- src/librustdoc/clean/mod.rs | 8 +-- src/librustdoc/clean/types.rs | 4 +- src/librustdoc/doctree.rs | 43 ++++++------- .../passes/collect_intra_doc_links.rs | 4 +- src/librustdoc/visit_ast.rs | 29 +++------ 129 files changed, 493 insertions(+), 549 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 375e567222965..f039deac8333f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4132,7 +4132,6 @@ name = "rustc_privacy" version = "0.0.0" dependencies = [ "log", - "rustc_ast", "rustc_attr", "rustc_data_structures", "rustc_errors", diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs index c63bbd53a3148..15bf4b70e2fdc 100644 --- a/src/librustc_ast/ast.rs +++ b/src/librustc_ast/ast.rs @@ -22,8 +22,6 @@ pub use crate::util::parser::ExprPrecedence; pub use GenericArgs::*; pub use UnsafeSource::*; -pub use rustc_span::symbol::{Ident, Symbol as Name}; - use crate::ptr::P; use crate::token::{self, DelimToken}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree}; @@ -34,7 +32,7 @@ use rustc_data_structures::thin_vec::ThinVec; use rustc_macros::HashStable_Generic; use rustc_serialize::{self, Decoder, Encoder}; use rustc_span::source_map::{respan, Spanned}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use std::convert::TryFrom; @@ -2451,7 +2449,7 @@ pub enum ItemKind { /// An `extern crate` item, with the optional *original* crate name if the crate was renamed. /// /// E.g., `extern crate foo` or `extern crate foo_bar as foo`. - ExternCrate(Option), + ExternCrate(Option), /// A use declaration item (`use`). /// /// E.g., `use foo;`, `use foo::bar;` or `use foo::bar as FooBar;`. diff --git a/src/librustc_ast/attr/mod.rs b/src/librustc_ast/attr/mod.rs index 588d250c1bcfa..b812f2dadf6d4 100644 --- a/src/librustc_ast/attr/mod.rs +++ b/src/librustc_ast/attr/mod.rs @@ -3,8 +3,8 @@ use crate::ast; use crate::ast::{AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute}; use crate::ast::{Expr, GenericParam, Item, Lit, LitKind, Local, Stmt, StmtKind}; -use crate::ast::{Ident, Name, Path, PathSegment}; use crate::ast::{MacArgs, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem}; +use crate::ast::{Path, PathSegment}; use crate::mut_visit::visit_clobber; use crate::ptr::P; use crate::token::{self, Token}; @@ -14,7 +14,7 @@ use rustc_data_structures::sync::Lock; use rustc_index::bit_set::GrowableBitSet; use rustc_span::edition::{Edition, DEFAULT_EDITION}; use rustc_span::source_map::{BytePos, Spanned}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; use log::debug; @@ -113,7 +113,7 @@ impl NestedMetaItem { } /// Returns a name and single literal value tuple of the `MetaItem`. - pub fn name_value_literal(&self) -> Option<(Name, &Lit)> { + pub fn name_value_literal(&self) -> Option<(Symbol, &Lit)> { self.meta_item().and_then(|meta_item| { meta_item.meta_item_list().and_then(|meta_item_list| { if meta_item_list.len() == 1 { diff --git a/src/librustc_ast/mut_visit.rs b/src/librustc_ast/mut_visit.rs index e66b358c4ac7f..d533aecf2df6b 100644 --- a/src/librustc_ast/mut_visit.rs +++ b/src/librustc_ast/mut_visit.rs @@ -15,6 +15,7 @@ use crate::tokenstream::*; use rustc_data_structures::map_in_place::MapInPlace; use rustc_data_structures::sync::Lrc; use rustc_span::source_map::{respan, Spanned}; +use rustc_span::symbol::Ident; use rustc_span::Span; use smallvec::{smallvec, Array, SmallVec}; diff --git a/src/librustc_ast/token.rs b/src/librustc_ast/token.rs index be5d322ba1677..a5b9c2a95bbea 100644 --- a/src/librustc_ast/token.rs +++ b/src/librustc_ast/token.rs @@ -12,7 +12,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::Lrc; use rustc_macros::HashStable_Generic; use rustc_span::symbol::kw; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{self, Span, DUMMY_SP}; use std::borrow::Cow; use std::{fmt, mem}; @@ -145,7 +145,7 @@ impl Lit { } } -pub fn ident_can_begin_expr(name: ast::Name, span: Span, is_raw: bool) -> bool { +pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool { let ident_token = Token::new(Ident(name, is_raw), span); !ident_token.is_reserved_ident() @@ -173,7 +173,7 @@ pub fn ident_can_begin_expr(name: ast::Name, span: Span, is_raw: bool) -> bool { .contains(&name) } -fn ident_can_begin_type(name: ast::Name, span: Span, is_raw: bool) -> bool { +fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool { let ident_token = Token::new(Ident(name, is_raw), span); !ident_token.is_reserved_ident() @@ -229,18 +229,18 @@ pub enum TokenKind { /// Do not forget about `NtIdent` when you want to match on identifiers. /// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to /// treat regular and interpolated identifiers in the same way. - Ident(ast::Name, /* is_raw */ bool), + Ident(Symbol, /* is_raw */ bool), /// Lifetime identifier token. /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers. /// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to /// treat regular and interpolated lifetime identifiers in the same way. - Lifetime(ast::Name), + Lifetime(Symbol), Interpolated(Lrc), // Can be expanded into several tokens. /// A doc comment. - DocComment(ast::Name), + DocComment(Symbol), // Junk. These carry no data because we don't really care about the data // they *would* carry, and don't really want to allocate a new ident for @@ -249,9 +249,9 @@ pub enum TokenKind { Whitespace, /// A comment. Comment, - Shebang(ast::Name), + Shebang(Symbol), /// A completely invalid token which should be skipped. - Unknown(ast::Name), + Unknown(Symbol), Eof, } @@ -325,8 +325,8 @@ impl Token { Token::new(TokenKind::Whitespace, DUMMY_SP) } - /// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary. - pub fn from_ast_ident(ident: ast::Ident) -> Self { + /// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary. + pub fn from_ast_ident(ident: Ident) -> Self { Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span) } @@ -488,19 +488,19 @@ impl Token { } /// Returns an identifier if this token is an identifier. - pub fn ident(&self) -> Option<(ast::Ident, /* is_raw */ bool)> { + pub fn ident(&self) -> Option<(Ident, /* is_raw */ bool)> { let token = self.uninterpolate(); match token.kind { - Ident(name, is_raw) => Some((ast::Ident::new(name, token.span), is_raw)), + Ident(name, is_raw) => Some((Ident::new(name, token.span), is_raw)), _ => None, } } /// Returns a lifetime identifier if this token is a lifetime. - pub fn lifetime(&self) -> Option { + pub fn lifetime(&self) -> Option { let token = self.uninterpolate(); match token.kind { - Lifetime(name) => Some(ast::Ident::new(name, token.span)), + Lifetime(name) => Some(Ident::new(name, token.span)), _ => None, } } @@ -577,28 +577,28 @@ impl Token { } pub fn is_path_segment_keyword(&self) -> bool { - self.is_non_raw_ident_where(ast::Ident::is_path_segment_keyword) + self.is_non_raw_ident_where(Ident::is_path_segment_keyword) } // Returns true for reserved identifiers used internally for elided lifetimes, // unnamed method parameters, crate root module, error recovery etc. pub fn is_special_ident(&self) -> bool { - self.is_non_raw_ident_where(ast::Ident::is_special) + self.is_non_raw_ident_where(Ident::is_special) } /// Returns `true` if the token is a keyword used in the language. pub fn is_used_keyword(&self) -> bool { - self.is_non_raw_ident_where(ast::Ident::is_used_keyword) + self.is_non_raw_ident_where(Ident::is_used_keyword) } /// Returns `true` if the token is a keyword reserved for possible future use. pub fn is_unused_keyword(&self) -> bool { - self.is_non_raw_ident_where(ast::Ident::is_unused_keyword) + self.is_non_raw_ident_where(Ident::is_unused_keyword) } /// Returns `true` if the token is either a special identifier or a keyword. pub fn is_reserved_ident(&self) -> bool { - self.is_non_raw_ident_where(ast::Ident::is_reserved) + self.is_non_raw_ident_where(Ident::is_reserved) } /// Returns `true` if the token is the identifier `true` or `false`. @@ -607,7 +607,7 @@ impl Token { } /// Returns `true` if the token is a non-raw identifier for which `pred` holds. - pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(ast::Ident) -> bool) -> bool { + pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool { match self.ident() { Some((id, false)) => pred(id), _ => false, @@ -746,8 +746,8 @@ pub enum Nonterminal { NtPat(P), NtExpr(P), NtTy(P), - NtIdent(ast::Ident, /* is_raw */ bool), - NtLifetime(ast::Ident), + NtIdent(Ident, /* is_raw */ bool), + NtLifetime(Ident), NtLiteral(P), /// Stuff inside brackets for attributes NtMeta(P), diff --git a/src/librustc_ast/visit.rs b/src/librustc_ast/visit.rs index 51863350a8cf3..63f483663bfa6 100644 --- a/src/librustc_ast/visit.rs +++ b/src/librustc_ast/visit.rs @@ -17,6 +17,7 @@ use crate::ast::*; use crate::token::Token; use crate::tokenstream::{TokenStream, TokenTree}; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; #[derive(Copy, Clone, PartialEq)] @@ -74,7 +75,7 @@ impl<'a> FnKind<'a> { /// to monitor future changes to `Visitor` in case a new method with a /// new default implementation gets introduced.) pub trait Visitor<'ast>: Sized { - fn visit_name(&mut self, _span: Span, _name: Name) { + fn visit_name(&mut self, _span: Span, _name: Symbol) { // Nothing to do. } fn visit_ident(&mut self, ident: Ident) { diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index 251faf6af006d..8da3aa633b85f 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -9,7 +9,7 @@ use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; impl<'hir> LoweringContext<'_, 'hir> { fn lower_exprs(&mut self, exprs: &[AstP]) -> &'hir [hir::Expr<'hir>] { diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index c535885e70cb3..eced17c9245f2 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -12,7 +12,7 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::LocalDefId; use rustc_span::source_map::{respan, DesugaringKind}; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Span; use rustc_target::spec::abi; diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 47dd757823be2..7e6dfbf00f591 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -63,7 +63,7 @@ use rustc_session::parse::ParseSess; use rustc_session::Session; use rustc_span::hygiene::ExpnId; use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use log::{debug, trace}; diff --git a/src/librustc_ast_lowering/pat.rs b/src/librustc_ast_lowering/pat.rs index d54ad2036d5c6..496e401d06124 100644 --- a/src/librustc_ast_lowering/pat.rs +++ b/src/librustc_ast_lowering/pat.rs @@ -5,6 +5,7 @@ use rustc_ast::ptr::P; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir as hir; use rustc_hir::def::Res; +use rustc_span::symbol::Ident; use rustc_span::{source_map::Spanned, Span}; impl<'a, 'hir> LoweringContext<'a, 'hir> { diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs index cf6dde813096b..e5ce51f8d2d1f 100644 --- a/src/librustc_ast_lowering/path.rs +++ b/src/librustc_ast_lowering/path.rs @@ -9,6 +9,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::GenericArg; use rustc_session::lint::builtin::ELIDED_LIFETIMES_IN_PATHS; use rustc_session::lint::BuiltinLintDiagnostics; +use rustc_span::symbol::Ident; use rustc_span::Span; use log::debug; diff --git a/src/librustc_ast_passes/ast_validation.rs b/src/librustc_ast_passes/ast_validation.rs index cc88fbb295c68..46c415413e92b 100644 --- a/src/librustc_ast_passes/ast_validation.rs +++ b/src/librustc_ast_passes/ast_validation.rs @@ -20,7 +20,7 @@ use rustc_parse::validate_attr; use rustc_session::lint::builtin::PATTERNS_IN_FNS_WITHOUT_BODY; use rustc_session::lint::LintBuffer; use rustc_session::Session; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Span; use std::mem; use std::ops::DerefMut; diff --git a/src/librustc_ast_passes/feature_gate.rs b/src/librustc_ast_passes/feature_gate.rs index 76c790f80b86b..ffd741a7b37b0 100644 --- a/src/librustc_ast_passes/feature_gate.rs +++ b/src/librustc_ast_passes/feature_gate.rs @@ -7,7 +7,7 @@ use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP}; use rustc_feature::{Features, GateIssue, UnstableFeatures}; use rustc_session::parse::{feature_err, feature_err_issue, ParseSess}; use rustc_span::source_map::Spanned; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use log::debug; @@ -252,7 +252,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } - fn visit_name(&mut self, sp: Span, name: ast::Name) { + fn visit_name(&mut self, sp: Span, name: Symbol) { if !name.as_str().is_ascii() { gate_feature_post!( &self, diff --git a/src/librustc_ast_passes/node_count.rs b/src/librustc_ast_passes/node_count.rs index 534d6c7b1ea70..3cf562b927e2e 100644 --- a/src/librustc_ast_passes/node_count.rs +++ b/src/librustc_ast_passes/node_count.rs @@ -2,6 +2,7 @@ use rustc_ast::ast::*; use rustc_ast::visit::*; +use rustc_span::symbol::Ident; use rustc_span::Span; pub struct NodeCounter { diff --git a/src/librustc_ast_pretty/pprust.rs b/src/librustc_ast_pretty/pprust.rs index d3d7f486b47b4..e6803fdd7f157 100644 --- a/src/librustc_ast_pretty/pprust.rs +++ b/src/librustc_ast_pretty/pprust.rs @@ -12,7 +12,7 @@ use rustc_ast::util::parser::{self, AssocOp, Fixity}; use rustc_ast::util::{classify, comments}; use rustc_span::edition::Edition; use rustc_span::source_map::{SourceMap, Spanned}; -use rustc_span::symbol::{kw, sym, IdentPrinter}; +use rustc_span::symbol::{kw, sym, Ident, IdentPrinter, Symbol}; use rustc_span::{BytePos, FileName, Span}; use std::borrow::Cow; @@ -26,8 +26,8 @@ pub enum MacHeader<'a> { } pub enum AnnNode<'a> { - Ident(&'a ast::Ident), - Name(&'a ast::Name), + Ident(&'a Ident), + Name(&'a Symbol), Block(&'a ast::Block), Item(&'a ast::Item), SubItem(ast::NodeId), @@ -118,8 +118,8 @@ pub fn print_crate<'a>( // of the feature gate, so we fake them up here. // `#![feature(prelude_import)]` - 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 pi_nested = attr::mk_nested_word_item(Ident::with_dummy_span(sym::prelude_import)); + let list = attr::mk_list_item(Ident::with_dummy_span(sym::feature), vec![pi_nested]); let fake_attr = attr::mk_attr_inner(list); s.print_attribute(&fake_attr); @@ -127,7 +127,7 @@ pub fn print_crate<'a>( // root, so this is not needed, and actually breaks things. if edition == Edition::Edition2015 { // `#![no_std]` - let no_std_meta = attr::mk_word_item(ast::Ident::with_dummy_span(sym::no_std)); + let no_std_meta = attr::mk_word_item(Ident::with_dummy_span(sym::no_std)); let fake_attr = attr::mk_attr_inner(no_std_meta); s.print_attribute(&fake_attr); } @@ -389,7 +389,7 @@ impl std::ops::DerefMut for State<'_> { pub trait PrintState<'a>: std::ops::Deref + std::ops::DerefMut { fn comments(&mut self) -> &mut Option>; - fn print_ident(&mut self, ident: ast::Ident); + fn print_ident(&mut self, ident: Ident); fn print_generic_args(&mut self, args: &ast::GenericArgs, colons_before_params: bool); fn strsep( @@ -671,7 +671,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere &mut self, header: Option>, has_bang: bool, - ident: Option, + ident: Option, delim: DelimToken, tts: TokenStream, convert_dollar_crate: bool, @@ -782,7 +782,7 @@ impl<'a> PrintState<'a> for State<'a> { &mut self.comments } - fn print_ident(&mut self, ident: ast::Ident) { + fn print_ident(&mut self, ident: Ident) { self.s.word(IdentPrinter::for_ast_ident(ident, ident.is_raw_guess()).to_string()); self.ann.post(self, AnnNode::Ident(&ident)) } @@ -1001,7 +1001,7 @@ impl<'a> State<'a> { fn print_item_const( &mut self, - ident: ast::Ident, + ident: Ident, mutbl: Option, ty: &ast::Ty, body: Option<&ast::Expr>, @@ -1032,7 +1032,7 @@ impl<'a> State<'a> { fn print_associated_type( &mut self, - ident: ast::Ident, + ident: Ident, generics: &ast::Generics, bounds: &ast::GenericBounds, ty: Option<&ast::Ty>, @@ -1281,7 +1281,7 @@ impl<'a> State<'a> { &mut self, enum_definition: &ast::EnumDef, generics: &ast::Generics, - ident: ast::Ident, + ident: Ident, span: rustc_span::Span, visibility: &ast::Visibility, ) { @@ -1337,7 +1337,7 @@ impl<'a> State<'a> { &mut self, struct_def: &ast::VariantData, generics: &ast::Generics, - ident: ast::Ident, + ident: Ident, span: rustc_span::Span, print_finalizer: bool, ) { @@ -2116,7 +2116,7 @@ impl<'a> State<'a> { self.s.word(i.to_string()) } - crate fn print_name(&mut self, name: ast::Name) { + crate fn print_name(&mut self, name: Symbol) { self.s.word(name.to_string()); self.ann.post(self, AnnNode::Name(&name)) } @@ -2322,7 +2322,7 @@ impl<'a> State<'a> { fn print_fn_full( &mut self, sig: &ast::FnSig, - name: ast::Ident, + name: Ident, generics: &ast::Generics, vis: &ast::Visibility, defaultness: ast::Defaultness, @@ -2347,7 +2347,7 @@ impl<'a> State<'a> { &mut self, decl: &ast::FnDecl, header: ast::FnHeader, - name: Option, + name: Option, generics: &ast::Generics, ) { self.print_fn_header_info(header); @@ -2614,7 +2614,7 @@ impl<'a> State<'a> { ext: ast::Extern, unsafety: ast::Unsafe, decl: &ast::FnDecl, - name: Option, + name: Option, generic_params: &[ast::GenericParam], ) { self.ibox(INDENT_UNIT); diff --git a/src/librustc_builtin_macros/assert.rs b/src/librustc_builtin_macros/assert.rs index 3a3595b04d287..166cd62835030 100644 --- a/src/librustc_builtin_macros/assert.rs +++ b/src/librustc_builtin_macros/assert.rs @@ -7,7 +7,7 @@ use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast_pretty::pprust; use rustc_expand::base::*; use rustc_parse::parser::Parser; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; pub fn expand_assert<'cx>( diff --git a/src/librustc_builtin_macros/concat_idents.rs b/src/librustc_builtin_macros/concat_idents.rs index b55e71b2518f4..8a1741c065466 100644 --- a/src/librustc_builtin_macros/concat_idents.rs +++ b/src/librustc_builtin_macros/concat_idents.rs @@ -3,7 +3,7 @@ use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_expand::base::{self, *}; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; pub fn expand_concat_idents<'cx>( @@ -39,10 +39,10 @@ pub fn expand_concat_idents<'cx>( } } - let ident = ast::Ident::new(Symbol::intern(&res_str), cx.with_call_site_ctxt(sp)); + let ident = Ident::new(Symbol::intern(&res_str), cx.with_call_site_ctxt(sp)); struct ConcatIdentsResult { - ident: ast::Ident, + ident: Ident, } impl base::MacResult for ConcatIdentsResult { diff --git a/src/librustc_builtin_macros/deriving/clone.rs b/src/librustc_builtin_macros/deriving/clone.rs index 97569ef813886..5dbf3825ce693 100644 --- a/src/librustc_builtin_macros/deriving/clone.rs +++ b/src/librustc_builtin_macros/deriving/clone.rs @@ -5,7 +5,7 @@ use crate::deriving::path_std; use rustc_ast::ast::{self, Expr, GenericArg, Generics, ItemKind, MetaItem, VariantData}; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; pub fn expand_deriving_clone( @@ -135,8 +135,7 @@ fn cs_clone_shallow( let mut stmts = Vec::new(); if is_union { // let _: AssertParamIsCopy; - let self_ty = - cx.ty_path(cx.path_ident(trait_span, ast::Ident::with_dummy_span(kw::SelfUpper))); + let self_ty = cx.ty_path(cx.path_ident(trait_span, Ident::with_dummy_span(kw::SelfUpper))); assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, "AssertParamIsCopy"); } else { match *substr.fields { diff --git a/src/librustc_builtin_macros/deriving/cmp/eq.rs b/src/librustc_builtin_macros/deriving/cmp/eq.rs index b39f41513ee35..b3b15b897828a 100644 --- a/src/librustc_builtin_macros/deriving/cmp/eq.rs +++ b/src/librustc_builtin_macros/deriving/cmp/eq.rs @@ -2,10 +2,10 @@ use crate::deriving::generic::ty::*; use crate::deriving::generic::*; use crate::deriving::path_std; -use rustc_ast::ast::{self, Expr, GenericArg, Ident, MetaItem}; +use rustc_ast::ast::{self, Expr, GenericArg, MetaItem}; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; pub fn expand_deriving_eq( diff --git a/src/librustc_builtin_macros/deriving/cmp/ord.rs b/src/librustc_builtin_macros/deriving/cmp/ord.rs index b23fbc6f62bdb..030d2c837428b 100644 --- a/src/librustc_builtin_macros/deriving/cmp/ord.rs +++ b/src/librustc_builtin_macros/deriving/cmp/ord.rs @@ -5,7 +5,7 @@ use crate::deriving::path_std; use rustc_ast::ast::{self, Expr, MetaItem}; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; pub fn expand_deriving_ord( @@ -45,15 +45,15 @@ pub fn expand_deriving_ord( pub fn ordering_collapsed( cx: &mut ExtCtxt<'_>, span: Span, - self_arg_tags: &[ast::Ident], + self_arg_tags: &[Ident], ) -> P { let lft = cx.expr_ident(span, self_arg_tags[0]); let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1])); - cx.expr_method_call(span, lft, ast::Ident::new(sym::cmp, span), vec![rgt]) + cx.expr_method_call(span, lft, Ident::new(sym::cmp, span), vec![rgt]) } pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P { - let test_id = ast::Ident::new(sym::cmp, span); + let test_id = Ident::new(sym::cmp, span); let equals_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal])); let cmp_path = cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]); diff --git a/src/librustc_builtin_macros/deriving/cmp/partial_ord.rs b/src/librustc_builtin_macros/deriving/cmp/partial_ord.rs index 835ccd1b022e1..f29f91e82312b 100644 --- a/src/librustc_builtin_macros/deriving/cmp/partial_ord.rs +++ b/src/librustc_builtin_macros/deriving/cmp/partial_ord.rs @@ -7,7 +7,7 @@ use crate::deriving::{path_local, path_std, pathvec_std}; use rustc_ast::ast::{self, BinOpKind, Expr, MetaItem}; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; pub fn expand_deriving_partial_ord( @@ -104,7 +104,7 @@ pub fn some_ordering_collapsed( cx: &mut ExtCtxt<'_>, span: Span, op: OrderingOp, - self_arg_tags: &[ast::Ident], + self_arg_tags: &[Ident], ) -> P { let lft = cx.expr_ident(span, self_arg_tags[0]); let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1])); @@ -119,7 +119,7 @@ pub fn some_ordering_collapsed( } pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P { - let test_id = ast::Ident::new(sym::cmp, span); + let test_id = Ident::new(sym::cmp, span); let ordering = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal])); let ordering_expr = cx.expr_path(ordering.clone()); let equals_expr = cx.expr_some(span, ordering_expr); diff --git a/src/librustc_builtin_macros/deriving/debug.rs b/src/librustc_builtin_macros/deriving/debug.rs index cea7e8176b67f..99c2b6f8a4eac 100644 --- a/src/librustc_builtin_macros/deriving/debug.rs +++ b/src/librustc_builtin_macros/deriving/debug.rs @@ -2,11 +2,11 @@ use crate::deriving::generic::ty::*; use crate::deriving::generic::*; use crate::deriving::path_std; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_ast::ast::{Expr, MetaItem}; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident}; use rustc_span::{Span, DUMMY_SP}; pub fn expand_deriving_debug( diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs index 3a96c5aa8ed4f..0ba9df08383a4 100644 --- a/src/librustc_builtin_macros/deriving/generic/mod.rs +++ b/src/librustc_builtin_macros/deriving/generic/mod.rs @@ -181,7 +181,7 @@ use std::cell::RefCell; use std::iter; use std::vec; -use rustc_ast::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; +use rustc_ast::ast::{self, BinOpKind, EnumDef, Expr, Generics, PatKind}; use rustc_ast::ast::{GenericArg, GenericParamKind, VariantData}; use rustc_ast::ptr::P; use rustc_attr as attr; @@ -189,7 +189,7 @@ use rustc_data_structures::map_in_place::MapInPlace; use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_session::parse::ParseSess; use rustc_span::source_map::respan; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty}; @@ -222,7 +222,7 @@ pub struct TraitDef<'a> { pub methods: Vec>, - pub associated_types: Vec<(ast::Ident, Ty<'a>)>, + pub associated_types: Vec<(Ident, Ty<'a>)>, } pub struct MethodDef<'a> { @@ -336,14 +336,14 @@ pub fn combine_substructure( /// is not global and starts with `T`, or a `TyQPath`. fn find_type_parameters( ty: &ast::Ty, - ty_param_names: &[ast::Name], + ty_param_names: &[Symbol], cx: &ExtCtxt<'_>, ) -> Vec> { use rustc_ast::visit; struct Visitor<'a, 'b> { cx: &'a ExtCtxt<'b>, - ty_param_names: &'a [ast::Name], + ty_param_names: &'a [Symbol], types: Vec>, } @@ -620,7 +620,7 @@ impl<'a> TraitDef<'a> { .peekable(); if ty_params.peek().is_some() { - let ty_param_names: Vec = + let ty_param_names: Vec = ty_params.map(|ty_param| ty_param.ident.name).collect(); for field_ty in field_tys { @@ -1223,7 +1223,7 @@ impl<'a> MethodDef<'a> { .collect::>(); let self_arg_idents = - self_arg_names.iter().map(|name| cx.ident_of(name, sp)).collect::>(); + self_arg_names.iter().map(|name| cx.ident_of(name, sp)).collect::>(); // The `vi_idents` will be bound, solely in the catch-all, to // a series of let statements mapping each self_arg to an int @@ -1234,7 +1234,7 @@ impl<'a> MethodDef<'a> { let vi_suffix = format!("{}_vi", &name[..]); cx.ident_of(&vi_suffix[..], trait_.span) }) - .collect::>(); + .collect::>(); // Builds, via callback to call_substructure_method, the // delegated expression that handles the catch-all case, @@ -1598,7 +1598,7 @@ impl<'a> TraitDef<'a> { fn create_subpatterns( &self, cx: &mut ExtCtxt<'_>, - field_paths: Vec, + field_paths: Vec, mutbl: ast::Mutability, use_temporaries: bool, ) -> Vec> { @@ -1670,7 +1670,7 @@ impl<'a> TraitDef<'a> { fn create_enum_variant_pattern( &self, cx: &mut ExtCtxt<'_>, - enum_ident: ast::Ident, + enum_ident: Ident, variant: &'a ast::Variant, prefix: &str, mutbl: ast::Mutability, diff --git a/src/librustc_builtin_macros/deriving/generic/ty.rs b/src/librustc_builtin_macros/deriving/generic/ty.rs index 23980a2db8d42..62cbdb19a8894 100644 --- a/src/librustc_builtin_macros/deriving/generic/ty.rs +++ b/src/librustc_builtin_macros/deriving/generic/ty.rs @@ -4,11 +4,11 @@ pub use PtrTy::*; pub use Ty::*; -use rustc_ast::ast::{self, Expr, GenericArg, GenericParamKind, Generics, Ident, SelfKind}; +use rustc_ast::ast::{self, Expr, GenericArg, GenericParamKind, Generics, SelfKind}; use rustc_ast::ptr::P; use rustc_expand::base::ExtCtxt; use rustc_span::source_map::{respan, DUMMY_SP}; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, Ident}; use rustc_span::Span; /// The types of pointers diff --git a/src/librustc_builtin_macros/deriving/mod.rs b/src/librustc_builtin_macros/deriving/mod.rs index b5ad67abf6201..9660cade38241 100644 --- a/src/librustc_builtin_macros/deriving/mod.rs +++ b/src/librustc_builtin_macros/deriving/mod.rs @@ -3,7 +3,7 @@ use rustc_ast::ast::{self, ItemKind, MetaItem}; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; macro path_local($x:ident) { @@ -154,7 +154,7 @@ fn inject_impl_of_structural_trait( let newitem = cx.item( span, - ast::Ident::invalid(), + Ident::invalid(), attrs, ItemKind::Impl { unsafety: ast::Unsafe::No, diff --git a/src/librustc_builtin_macros/env.rs b/src/librustc_builtin_macros/env.rs index fba76f8b4962f..21e1889513b01 100644 --- a/src/librustc_builtin_macros/env.rs +++ b/src/librustc_builtin_macros/env.rs @@ -3,10 +3,10 @@ // interface. // -use rustc_ast::ast::{self, GenericArg, Ident}; +use rustc_ast::ast::{self, GenericArg}; use rustc_ast::tokenstream::TokenStream; use rustc_expand::base::{self, *}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use std::env; diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index 595254700e324..efce62881985e 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -10,7 +10,7 @@ use rustc_ast::tokenstream::TokenStream; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{pluralize, Applicability, DiagnosticBuilder}; use rustc_expand::base::{self, *}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{MultiSpan, Span}; use std::borrow::Cow; @@ -535,7 +535,7 @@ impl<'a, 'b> Context<'a, 'b> { self.count_args_index_offset = sofar; } - fn rtpath(ecx: &ExtCtxt<'_>, s: &str) -> Vec { + fn rtpath(ecx: &ExtCtxt<'_>, s: &str) -> Vec { ecx.std_path(&[sym::fmt, sym::rt, sym::v1, Symbol::intern(s)]) } @@ -794,7 +794,7 @@ impl<'a, 'b> Context<'a, 'b> { macsp: Span, mut sp: Span, ty: &ArgumentType, - arg: ast::Ident, + arg: Ident, ) -> P { sp = ecx.with_def_site_ctxt(sp); let arg = ecx.expr_ident(sp, arg); diff --git a/src/librustc_builtin_macros/global_allocator.rs b/src/librustc_builtin_macros/global_allocator.rs index 5d16be3206aaa..feda17c1812cb 100644 --- a/src/librustc_builtin_macros/global_allocator.rs +++ b/src/librustc_builtin_macros/global_allocator.rs @@ -1,13 +1,13 @@ use crate::util::check_builtin_macro_attribute; -use rustc_ast::ast::{self, Attribute, Expr, FnHeader, FnSig, Generics, Ident, Param}; +use rustc_ast::ast::{self, Attribute, Expr, FnHeader, FnSig, Generics, Param}; use rustc_ast::ast::{ItemKind, Mutability, Stmt, Ty, TyKind, Unsafe}; use rustc_ast::expand::allocator::{ AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS, }; use rustc_ast::ptr::P; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; pub fn expand( diff --git a/src/librustc_builtin_macros/global_asm.rs b/src/librustc_builtin_macros/global_asm.rs index 307e7fe71212b..2729239f62b90 100644 --- a/src/librustc_builtin_macros/global_asm.rs +++ b/src/librustc_builtin_macros/global_asm.rs @@ -15,6 +15,7 @@ use rustc_ast::tokenstream::TokenStream; use rustc_errors::DiagnosticBuilder; use rustc_expand::base::{self, *}; use rustc_span::source_map::respan; +use rustc_span::symbol::Ident; use rustc_span::Span; use smallvec::smallvec; @@ -25,7 +26,7 @@ pub fn expand_global_asm<'cx>( ) -> Box { match parse_global_asm(cx, sp, tts) { Ok(Some(global_asm)) => MacEager::items(smallvec![P(ast::Item { - ident: ast::Ident::invalid(), + ident: Ident::invalid(), attrs: Vec::new(), id: ast::DUMMY_NODE_ID, kind: ast::ItemKind::GlobalAsm(P(global_asm)), diff --git a/src/librustc_builtin_macros/lib.rs b/src/librustc_builtin_macros/lib.rs index bc1767a1238f8..cc77bb73c5ae1 100644 --- a/src/librustc_builtin_macros/lib.rs +++ b/src/librustc_builtin_macros/lib.rs @@ -14,11 +14,10 @@ extern crate proc_macro; use crate::deriving::*; -use rustc_ast::ast::Ident; use rustc_expand::base::{MacroExpanderFn, Resolver, SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::proc_macro::BangProcMacro; use rustc_span::edition::Edition; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident}; mod assert; mod cfg; diff --git a/src/librustc_builtin_macros/proc_macro_harness.rs b/src/librustc_builtin_macros/proc_macro_harness.rs index 735de4f0a5b24..adaf5f03079eb 100644 --- a/src/librustc_builtin_macros/proc_macro_harness.rs +++ b/src/librustc_builtin_macros/proc_macro_harness.rs @@ -1,6 +1,6 @@ use std::mem; -use rustc_ast::ast::{self, Ident, NodeId}; +use rustc_ast::ast::{self, NodeId}; use rustc_ast::attr; use rustc_ast::expand::is_proc_macro_attr; use rustc_ast::ptr::P; @@ -11,17 +11,17 @@ use rustc_expand::expand::{AstFragment, ExpansionConfig}; use rustc_session::parse::ParseSess; use rustc_span::hygiene::AstPass; use rustc_span::source_map::SourceMap; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use smallvec::smallvec; use std::cell::RefCell; struct ProcMacroDerive { id: NodeId, - trait_name: ast::Name, + trait_name: Symbol, function_name: Ident, span: Span, - attrs: Vec, + attrs: Vec, } enum ProcMacroDefType { @@ -480,7 +480,7 @@ fn mk_decls( let anon_constant = cx.item_const( span, - ast::Ident::new(kw::Underscore, span), + Ident::new(kw::Underscore, span), cx.ty(span, ast::TyKind::Tup(Vec::new())), block, ); diff --git a/src/librustc_builtin_macros/standard_library_imports.rs b/src/librustc_builtin_macros/standard_library_imports.rs index f48fd6df9c98b..cd3773c76c483 100644 --- a/src/librustc_builtin_macros/standard_library_imports.rs +++ b/src/librustc_builtin_macros/standard_library_imports.rs @@ -60,17 +60,17 @@ pub fn inject( let name = names[0]; let import_path = if rust_2018 { - [name, sym::prelude, sym::v1].iter().map(|symbol| ast::Ident::new(*symbol, span)).collect() + [name, sym::prelude, sym::v1].iter().map(|symbol| Ident::new(*symbol, span)).collect() } else { [kw::PathRoot, name, sym::prelude, sym::v1] .iter() - .map(|symbol| ast::Ident::new(*symbol, span)) + .map(|symbol| Ident::new(*symbol, span)) .collect() }; let use_item = cx.item( span, - ast::Ident::invalid(), + Ident::invalid(), vec![cx.attribute(cx.meta_word(span, sym::prelude_import))], ast::ItemKind::Use(P(ast::UseTree { prefix: cx.path(span, import_path), diff --git a/src/librustc_builtin_macros/test.rs b/src/librustc_builtin_macros/test.rs index bdc4ae2fe274b..d62f34bab1a31 100644 --- a/src/librustc_builtin_macros/test.rs +++ b/src/librustc_builtin_macros/test.rs @@ -7,7 +7,7 @@ use rustc_ast::attr; use rustc_ast_pretty::pprust; use rustc_expand::base::*; use rustc_span::source_map::respan; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; use std::iter; @@ -105,7 +105,7 @@ pub fn expand_test_or_bench( let (sp, attr_sp) = (cx.with_def_site_ctxt(item.span), cx.with_def_site_ctxt(attr_sp)); - let test_id = ast::Ident::new(sym::test, attr_sp); + let test_id = Ident::new(sym::test, attr_sp); // creates test::$name let test_path = |name| cx.path(sp, vec![test_id, cx.ident_of(name, sp)]); @@ -172,12 +172,12 @@ pub fn expand_test_or_bench( let mut test_const = cx.item( sp, - ast::Ident::new(item.ident.name, sp), + Ident::new(item.ident.name, sp), vec![ // #[cfg(test)] cx.attribute(attr::mk_list_item( - ast::Ident::new(sym::cfg, attr_sp), - vec![attr::mk_nested_word_item(ast::Ident::new(sym::test, attr_sp))], + Ident::new(sym::cfg, attr_sp), + vec![attr::mk_nested_word_item(Ident::new(sym::test, attr_sp))], )), // #[rustc_test_marker] cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)), @@ -288,7 +288,7 @@ pub fn expand_test_or_bench( ] } -fn item_path(mod_path: &[ast::Ident], item_ident: &ast::Ident) -> String { +fn item_path(mod_path: &[Ident], item_ident: &Ident) -> String { mod_path .iter() .chain(iter::once(item_ident)) diff --git a/src/librustc_builtin_macros/test_harness.rs b/src/librustc_builtin_macros/test_harness.rs index aca1c69dfd591..34ed4c800e04f 100644 --- a/src/librustc_builtin_macros/test_harness.rs +++ b/src/librustc_builtin_macros/test_harness.rs @@ -1,7 +1,7 @@ // Code that generates a test runner to run all the tests in a crate use log::debug; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_ast::attr; use rustc_ast::entry::{self, EntryPointType}; use rustc_ast::mut_visit::{ExpectOne, *}; @@ -12,7 +12,7 @@ use rustc_feature::Features; use rustc_session::parse::ParseSess; use rustc_span::hygiene::{AstPass, SyntaxContext, Transparency}; use rustc_span::source_map::respan; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::PanicStrategy; use smallvec::{smallvec, SmallVec}; diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 03bba7657bb6d..fb9a27ed001f4 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -19,7 +19,6 @@ use crate::llvm::debuginfo::{ use crate::value::Value; use log::debug; -use rustc_ast::ast; use rustc_codegen_ssa::traits::*; use rustc_data_structures::const_cstr; use rustc_data_structures::fingerprint::Fingerprint; @@ -93,7 +92,7 @@ pub const UNKNOWN_COLUMN_NUMBER: c_uint = 0; pub const NO_SCOPE_METADATA: Option<&DIScope> = None; #[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)] -pub struct UniqueTypeId(ast::Name); +pub struct UniqueTypeId(Symbol); /// The `TypeMap` is where the `CrateDebugContext` holds the type metadata nodes /// created so far. The metadata nodes are indexed by `UniqueTypeId`, and, for @@ -1300,7 +1299,7 @@ fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool { fn generator_layout_and_saved_local_names( tcx: TyCtxt<'tcx>, def_id: DefId, -) -> (&'tcx GeneratorLayout<'tcx>, IndexVec>) { +) -> (&'tcx GeneratorLayout<'tcx>, IndexVec>) { let body = tcx.optimized_mir(def_id); let generator_layout = body.generator_layout.as_ref().unwrap(); let mut generator_saved_local_names = IndexVec::from_elem(None, &generator_layout.field_tys); @@ -1656,7 +1655,7 @@ enum VariantInfo<'a, 'tcx> { Generator { substs: SubstsRef<'tcx>, generator_layout: &'tcx GeneratorLayout<'tcx>, - generator_saved_local_names: &'a IndexVec>, + generator_saved_local_names: &'a IndexVec>, variant_index: VariantIdx, }, } diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 92e210cdd8cb7..8c9a2c09c272c 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -17,7 +17,6 @@ use crate::llvm::debuginfo::{ }; use crate::value::Value; -use rustc_ast::ast; use rustc_codegen_ssa::debuginfo::type_names; use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; use rustc_codegen_ssa::traits::*; @@ -529,7 +528,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn create_dbg_var( &self, dbg_context: &FunctionDebugContext<&'ll DIScope>, - variable_name: ast::Name, + variable_name: Symbol, variable_type: Ty<'tcx>, scope_metadata: &'ll DIScope, variable_kind: VariableKind, diff --git a/src/librustc_codegen_ssa/traits/debuginfo.rs b/src/librustc_codegen_ssa/traits/debuginfo.rs index 34be1cfdd8844..1ee0f489ffc10 100644 --- a/src/librustc_codegen_ssa/traits/debuginfo.rs +++ b/src/librustc_codegen_ssa/traits/debuginfo.rs @@ -1,10 +1,9 @@ use super::BackendTypes; use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; -use rustc_ast::ast::Name; use rustc_hir::def_id::CrateNum; use rustc_middle::mir; use rustc_middle::ty::{Instance, Ty}; -use rustc_span::{SourceFile, Span}; +use rustc_span::{SourceFile, Span, Symbol}; use rustc_target::abi::call::FnAbi; use rustc_target::abi::Size; @@ -36,7 +35,7 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes { fn create_dbg_var( &self, dbg_context: &FunctionDebugContext, - variable_name: Name, + variable_name: Symbol, variable_type: Ty<'tcx>, scope_metadata: Self::DIScope, variable_kind: VariableKind, diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 610e9b9051040..a443b8f464f1c 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -11,6 +11,7 @@ use rustc_middle::ty::{self, TyCtxt}; use rustc_mir::util::{write_mir_graphviz, write_mir_pretty}; use rustc_session::config::{Input, PpMode, PpSourceMode}; use rustc_session::Session; +use rustc_span::symbol::Ident; use rustc_span::FileName; use std::cell::Cell; @@ -284,7 +285,7 @@ impl<'a> PrinterSupport for HygieneAnnotation<'a> { impl<'a> pprust::PpAnn for HygieneAnnotation<'a> { fn post(&self, s: &mut pprust::State<'_>, node: pprust::AnnNode<'_>) { match node { - pprust::AnnNode::Ident(&ast::Ident { name, span }) => { + pprust::AnnNode::Ident(&Ident { name, span }) => { s.s.space(); s.synth_comment(format!("{}{:?}", name.as_u32(), span.ctxt())) } diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index 59c1a5468f100..fe5bf6f82c6d3 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -1,7 +1,7 @@ use crate::expand::{self, AstFragment, Invocation}; use crate::module::DirectoryOwnership; -use rustc_ast::ast::{self, Attribute, Name, NodeId, PatKind}; +use rustc_ast::ast::{self, Attribute, NodeId, PatKind}; use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::token; @@ -796,7 +796,7 @@ impl SyntaxExtension { span: Span, helper_attrs: Vec, edition: Edition, - name: Name, + name: Symbol, attrs: &[ast::Attribute], ) -> SyntaxExtension { let allow_internal_unstable = attr::allow_internal_unstable(&attrs, &sess.span_diagnostic) @@ -885,7 +885,7 @@ pub trait Resolver { fn resolve_dollar_crates(&mut self); fn visit_ast_fragment_with_placeholders(&mut self, expn_id: ExpnId, fragment: &AstFragment); - fn register_builtin_macro(&mut self, ident: ast::Ident, ext: SyntaxExtension); + fn register_builtin_macro(&mut self, ident: Ident, ext: SyntaxExtension); fn expansion_for_ast_pass( &mut self, @@ -913,7 +913,7 @@ pub trait Resolver { #[derive(Clone)] pub struct ModuleData { - pub mod_path: Vec, + pub mod_path: Vec, pub directory: PathBuf, } @@ -1052,16 +1052,16 @@ impl<'a> ExtCtxt<'a> { pub fn set_trace_macros(&mut self, x: bool) { self.ecfg.trace_mac = x } - pub fn ident_of(&self, st: &str, sp: Span) -> ast::Ident { - ast::Ident::from_str_and_span(st, sp) + pub fn ident_of(&self, st: &str, sp: Span) -> Ident { + Ident::from_str_and_span(st, sp) } - pub fn std_path(&self, components: &[Symbol]) -> Vec { + pub fn std_path(&self, components: &[Symbol]) -> Vec { let def_site = self.with_def_site_ctxt(DUMMY_SP); iter::once(Ident::new(kw::DollarCrate, def_site)) .chain(components.iter().map(|&s| Ident::with_dummy_span(s))) .collect() } - pub fn name_of(&self, st: &str) -> ast::Name { + pub fn name_of(&self, st: &str) -> Symbol { Symbol::intern(st) } diff --git a/src/librustc_expand/build.rs b/src/librustc_expand/build.rs index 4d89bf79e7c67..be2c52a85eb2a 100644 --- a/src/librustc_expand/build.rs +++ b/src/librustc_expand/build.rs @@ -1,28 +1,28 @@ use crate::base::ExtCtxt; -use rustc_ast::ast::{self, AttrVec, BlockCheckMode, Expr, Ident, PatKind, UnOp}; +use rustc_ast::ast::{self, AttrVec, BlockCheckMode, Expr, PatKind, UnOp}; use rustc_ast::attr; use rustc_ast::ptr::P; use rustc_span::source_map::{respan, Spanned}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; impl<'a> ExtCtxt<'a> { - pub fn path(&self, span: Span, strs: Vec) -> ast::Path { + pub fn path(&self, span: Span, strs: Vec) -> ast::Path { self.path_all(span, false, strs, vec![]) } - pub fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path { + pub fn path_ident(&self, span: Span, id: Ident) -> ast::Path { self.path(span, vec![id]) } - pub fn path_global(&self, span: Span, strs: Vec) -> ast::Path { + pub fn path_global(&self, span: Span, strs: Vec) -> ast::Path { self.path_all(span, true, strs, vec![]) } pub fn path_all( &self, span: Span, global: bool, - mut idents: Vec, + mut idents: Vec, args: Vec, ) -> ast::Path { assert!(!idents.is_empty()); @@ -63,7 +63,7 @@ impl<'a> ExtCtxt<'a> { // Might need to take bounds as an argument in the future, if you ever want // to generate a bounded existential trait type. - pub fn ty_ident(&self, span: Span, ident: ast::Ident) -> P { + pub fn ty_ident(&self, span: Span, ident: Ident) -> P { self.ty_path(self.path_ident(span, ident)) } @@ -74,7 +74,7 @@ impl<'a> ExtCtxt<'a> { } } - pub fn const_ident(&self, span: Span, ident: ast::Ident) -> ast::AnonConst { + pub fn const_ident(&self, span: Span, ident: Ident) -> ast::AnonConst { self.anon_const(span, ast::ExprKind::Path(None, self.path_ident(span, ident))) } @@ -95,7 +95,7 @@ impl<'a> ExtCtxt<'a> { pub fn typaram( &self, span: Span, - ident: ast::Ident, + ident: Ident, attrs: Vec, bounds: ast::GenericBounds, default: Option>, @@ -129,14 +129,14 @@ impl<'a> ExtCtxt<'a> { ) } - pub fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime { + pub fn lifetime(&self, span: Span, ident: Ident) -> ast::Lifetime { ast::Lifetime { id: ast::DUMMY_NODE_ID, ident: ident.with_span_pos(span) } } pub fn lifetime_def( &self, span: Span, - ident: ast::Ident, + ident: Ident, attrs: Vec, bounds: ast::GenericBounds, ) -> ast::GenericParam { @@ -155,13 +155,7 @@ impl<'a> ExtCtxt<'a> { ast::Stmt { id: ast::DUMMY_NODE_ID, span: expr.span, kind: ast::StmtKind::Expr(expr) } } - pub fn stmt_let( - &self, - sp: Span, - mutbl: bool, - ident: ast::Ident, - ex: P, - ) -> ast::Stmt { + pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P) -> ast::Stmt { let pat = if mutbl { let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mut); self.pat_ident_binding_mode(sp, ident, binding_mode) @@ -218,7 +212,7 @@ impl<'a> ExtCtxt<'a> { self.expr(path.span, ast::ExprKind::Path(None, path)) } - pub fn expr_ident(&self, span: Span, id: ast::Ident) -> P { + pub fn expr_ident(&self, span: Span, id: Ident) -> P { self.expr_path(self.path_ident(span, id)) } pub fn expr_self(&self, span: Span) -> P { @@ -251,18 +245,13 @@ impl<'a> ExtCtxt<'a> { ) -> P { self.expr(span, ast::ExprKind::Call(expr, args)) } - pub fn expr_call_ident( - &self, - span: Span, - id: ast::Ident, - args: Vec>, - ) -> P { + pub fn expr_call_ident(&self, span: Span, id: Ident, args: Vec>) -> P { self.expr(span, ast::ExprKind::Call(self.expr_ident(span, id), args)) } pub fn expr_call_global( &self, sp: Span, - fn_path: Vec, + fn_path: Vec, args: Vec>, ) -> P { let pathexpr = self.expr_path(self.path_global(sp, fn_path)); @@ -272,7 +261,7 @@ impl<'a> ExtCtxt<'a> { &self, span: Span, expr: P, - ident: ast::Ident, + ident: Ident, mut args: Vec>, ) -> P { args.insert(0, expr); @@ -304,7 +293,7 @@ impl<'a> ExtCtxt<'a> { pub fn expr_struct_ident( &self, span: Span, - id: ast::Ident, + id: Ident, fields: Vec, ) -> P { self.expr_struct(span, self.path_ident(span, id), fields) @@ -405,7 +394,7 @@ impl<'a> ExtCtxt<'a> { pub fn pat_lit(&self, span: Span, expr: P) -> P { self.pat(span, PatKind::Lit(expr)) } - pub fn pat_ident(&self, span: Span, ident: ast::Ident) -> P { + pub fn pat_ident(&self, span: Span, ident: Ident) -> P { let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Not); self.pat_ident_binding_mode(span, ident, binding_mode) } @@ -413,7 +402,7 @@ impl<'a> ExtCtxt<'a> { pub fn pat_ident_binding_mode( &self, span: Span, - ident: ast::Ident, + ident: Ident, bm: ast::BindingMode, ) -> P { let pat = PatKind::Ident(bm, ident.with_span_pos(span), None); @@ -517,7 +506,7 @@ impl<'a> ExtCtxt<'a> { ) } - pub fn lambda(&self, span: Span, ids: Vec, body: P) -> P { + pub fn lambda(&self, span: Span, ids: Vec, body: P) -> P { let fn_decl = self.fn_decl( ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(), ast::FnRetTy::Default(span), @@ -544,20 +533,15 @@ impl<'a> ExtCtxt<'a> { self.lambda(span, Vec::new(), body) } - pub fn lambda1(&self, span: Span, body: P, ident: ast::Ident) -> P { + pub fn lambda1(&self, span: Span, body: P, ident: Ident) -> P { self.lambda(span, vec![ident], body) } - pub fn lambda_stmts_1( - &self, - span: Span, - stmts: Vec, - ident: ast::Ident, - ) -> P { + pub fn lambda_stmts_1(&self, span: Span, stmts: Vec, ident: Ident) -> P { self.lambda1(span, self.expr_block(self.block(span, stmts)), ident) } - pub fn param(&self, span: Span, ident: ast::Ident, ty: P) -> ast::Param { + pub fn param(&self, span: Span, ident: Ident, ty: P) -> ast::Param { let arg_pat = self.pat_ident(span, ident); ast::Param { attrs: AttrVec::default(), @@ -653,7 +637,7 @@ impl<'a> ExtCtxt<'a> { attr::mk_attr_outer(mi) } - pub fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem { + pub fn meta_word(&self, sp: Span, w: Symbol) -> ast::MetaItem { attr::mk_word_item(Ident::new(w, sp)) } } diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index 972e75d201b90..427d04d3a9753 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -7,7 +7,7 @@ use crate::module::{parse_external_mod, push_directory, Directory, DirectoryOwne use crate::placeholders::{placeholder, PlaceholderExpander}; use crate::proc_macro::collect_derives; -use rustc_ast::ast::{self, AttrItem, Block, Ident, LitKind, NodeId, PatKind, Path}; +use rustc_ast::ast::{self, AttrItem, Block, LitKind, NodeId, PatKind, Path}; use rustc_ast::ast::{ItemKind, MacArgs, MacStmtStyle, StmtKind}; use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; @@ -25,7 +25,7 @@ use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::parse::{feature_err, ParseSess}; use rustc_span::source_map::respan; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{FileName, Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; diff --git a/src/librustc_expand/mbe.rs b/src/librustc_expand/mbe.rs index 57957a1fa8bf9..a728261d711a7 100644 --- a/src/librustc_expand/mbe.rs +++ b/src/librustc_expand/mbe.rs @@ -9,10 +9,10 @@ crate mod macro_rules; crate mod quoted; crate mod transcribe; -use rustc_ast::ast; use rustc_ast::token::{self, Token, TokenKind}; use rustc_ast::tokenstream::DelimSpan; +use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_data_structures::sync::Lrc; @@ -82,13 +82,9 @@ enum TokenTree { /// A kleene-style repetition sequence Sequence(DelimSpan, Lrc), /// e.g., `$var` - MetaVar(Span, ast::Ident), + MetaVar(Span, Ident), /// e.g., `$var:expr`. This is only used in the left hand side of MBE macros. - MetaVarDecl( - Span, - ast::Ident, /* name to bind */ - ast::Ident, /* kind of nonterminal */ - ), + MetaVarDecl(Span, Ident /* name to bind */, Ident /* kind of nonterminal */), } impl TokenTree { diff --git a/src/librustc_expand/mbe/macro_parser.rs b/src/librustc_expand/mbe/macro_parser.rs index 350473ab9ae56..0cf092d912bcf 100644 --- a/src/librustc_expand/mbe/macro_parser.rs +++ b/src/librustc_expand/mbe/macro_parser.rs @@ -76,7 +76,6 @@ use TokenTreeOrTokenTreeSlice::*; use crate::mbe::{self, TokenTree}; -use rustc_ast::ast::Name; use rustc_ast::ptr::P; use rustc_ast::token::{self, DocComment, Nonterminal, Token}; use rustc_ast_pretty::pprust; @@ -766,7 +765,7 @@ fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { /// /// Returning `false` is a *stability guarantee* that such a matcher will *never* begin with that /// token. Be conservative (return true) if not sure. -fn may_begin_with(token: &Token, name: Name) -> bool { +fn may_begin_with(token: &Token, name: Symbol) -> bool { /// Checks whether the non-terminal may contain a single (non-keyword) identifier. fn may_be_ident(nt: &token::Nonterminal) -> bool { match *nt { diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs index 7d2c4fbf7af32..ecadf320f87c4 100644 --- a/src/librustc_expand/mbe/macro_rules.rs +++ b/src/librustc_expand/mbe/macro_rules.rs @@ -21,7 +21,7 @@ use rustc_parse::parser::Parser; use rustc_session::parse::ParseSess; use rustc_span::edition::Edition; use rustc_span::hygiene::Transparency; -use rustc_span::symbol::{kw, sym, MacroRulesNormalizedIdent, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, MacroRulesNormalizedIdent, Symbol}; use rustc_span::Span; use log::debug; @@ -39,7 +39,7 @@ crate struct ParserAnyMacro<'a> { /// Span of the expansion site of the macro this parser is for site_span: Span, /// The ident of the macro we're parsing - macro_ident: ast::Ident, + macro_ident: Ident, arm_span: Span, } @@ -88,7 +88,7 @@ fn emit_frag_parse_err( parser: &Parser<'_>, orig_parser: &mut Parser<'_>, site_span: Span, - macro_ident: ast::Ident, + macro_ident: Ident, arm_span: Span, kind: AstFragmentKind, ) { @@ -166,7 +166,7 @@ impl<'a> ParserAnyMacro<'a> { } struct MacroRulesMacroExpander { - name: ast::Ident, + name: Ident, span: Span, transparency: Transparency, lhses: Vec, @@ -215,7 +215,7 @@ fn generic_extension<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, def_span: Span, - name: ast::Ident, + name: Ident, transparency: Transparency, arg: TokenStream, lhses: &[mbe::TokenTree], @@ -400,9 +400,9 @@ pub fn compile_declarative_macro( }; let diag = &sess.span_diagnostic; - let lhs_nm = ast::Ident::new(sym::lhs, def.span); - let rhs_nm = ast::Ident::new(sym::rhs, def.span); - let tt_spec = ast::Ident::new(sym::tt, def.span); + let lhs_nm = Ident::new(sym::lhs, def.span); + let rhs_nm = Ident::new(sym::rhs, def.span); + let tt_spec = Ident::new(sym::tt, def.span); // Parse the macro_rules! invocation let (macro_rules, body) = match &def.kind { diff --git a/src/librustc_expand/mbe/quoted.rs b/src/librustc_expand/mbe/quoted.rs index b19fae6559704..3295f5b392d6d 100644 --- a/src/librustc_expand/mbe/quoted.rs +++ b/src/librustc_expand/mbe/quoted.rs @@ -1,12 +1,11 @@ use crate::mbe::macro_parser; use crate::mbe::{Delimited, KleeneOp, KleeneToken, SequenceRepetition, TokenTree}; -use rustc_ast::ast; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream; use rustc_ast_pretty::pprust; use rustc_session::parse::ParseSess; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, Ident}; use rustc_span::Span; @@ -67,7 +66,7 @@ pub(super) fn parse( tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp), }; sess.missing_fragment_specifiers.borrow_mut().insert(span); - result.push(TokenTree::MetaVarDecl(span, ident, ast::Ident::invalid())); + result.push(TokenTree::MetaVarDecl(span, ident, Ident::invalid())); } // Not a metavar or no matchers allowed, so just return the tree @@ -145,7 +144,7 @@ fn parse_tree( let msg = format!("expected identifier, found `{}`", pprust::token_to_string(&token),); sess.span_diagnostic.span_err(token.span, &msg); - TokenTree::MetaVar(token.span, ast::Ident::invalid()) + TokenTree::MetaVar(token.span, Ident::invalid()) } // There are no more tokens. Just return the `$` we already have. diff --git a/src/librustc_expand/module.rs b/src/librustc_expand/module.rs index aad92a09743b3..9bb2b57b7f591 100644 --- a/src/librustc_expand/module.rs +++ b/src/librustc_expand/module.rs @@ -1,10 +1,10 @@ -use rustc_ast::ast::{self, Attribute, Ident, Mod}; +use rustc_ast::ast::{Attribute, Mod}; use rustc_ast::{attr, token}; use rustc_errors::{struct_span_err, PResult}; use rustc_parse::new_parser_from_file; use rustc_session::parse::ParseSess; use rustc_span::source_map::{FileName, Span}; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident}; use std::path::{self, Path, PathBuf}; @@ -18,7 +18,7 @@ pub struct Directory { pub enum DirectoryOwnership { Owned { // None if `mod.rs`, `Some("foo")` if we're in `foo.rs`. - relative: Option, + relative: Option, }, UnownedViaBlock, UnownedViaMod, @@ -40,7 +40,7 @@ pub struct ModulePathSuccess { crate fn parse_external_mod( sess: &ParseSess, - id: ast::Ident, + id: Ident, span: Span, // The span to blame on errors. Directory { mut ownership, path }: Directory, attrs: &mut Vec, @@ -125,7 +125,7 @@ crate fn push_directory( fn submod_path<'a>( sess: &'a ParseSess, - id: ast::Ident, + id: Ident, span: Span, attrs: &[Attribute], ownership: DirectoryOwnership, @@ -236,9 +236,9 @@ pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option( sess: &'a ParseSess, - id: ast::Ident, + id: Ident, span: Span, - relative: Option, + relative: Option, dir_path: &Path, ) -> ModulePath<'a> { // If we're in a foo.rs file instead of a mod.rs file, diff --git a/src/librustc_expand/placeholders.rs b/src/librustc_expand/placeholders.rs index e1781f8636e58..23f7a5b28fe80 100644 --- a/src/librustc_expand/placeholders.rs +++ b/src/librustc_expand/placeholders.rs @@ -5,6 +5,7 @@ use rustc_ast::ast; use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; use rustc_span::source_map::{dummy_spanned, DUMMY_SP}; +use rustc_span::symbol::Ident; use smallvec::{smallvec, SmallVec}; @@ -23,7 +24,7 @@ pub fn placeholder( } } - let ident = ast::Ident::invalid(); + let ident = Ident::invalid(); let attrs = Vec::new(); let vis = vis.unwrap_or_else(|| dummy_spanned(ast::VisibilityKind::Inherited)); let span = DUMMY_SP; diff --git a/src/librustc_expand/proc_macro_server.rs b/src/librustc_expand/proc_macro_server.rs index 10baffb28ac2d..afc6dc36eb430 100644 --- a/src/librustc_expand/proc_macro_server.rs +++ b/src/librustc_expand/proc_macro_server.rs @@ -10,7 +10,7 @@ use rustc_errors::Diagnostic; use rustc_parse::lexer::nfc_normalize; use rustc_parse::{nt_to_tokenstream, parse_stream_from_source_str}; use rustc_session::parse::ParseSess; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{self, kw, sym, Symbol}; use rustc_span::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span}; use pm::bridge::{server, TokenTree}; @@ -143,7 +143,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec)> Ident(name, false) if name == kw::DollarCrate => tt!(Ident::dollar_crate()), Ident(name, is_raw) => tt!(Ident::new(sess, name, is_raw)), Lifetime(name) => { - let ident = ast::Ident::new(name, span).without_first_quote(); + let ident = symbol::Ident::new(name, span).without_first_quote(); stack.push(tt!(Ident::new(sess, ident.name, false))); tt!(Punct::new('\'', true)) } diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index e6d673b30f7bc..be794b0ee7504 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -3,7 +3,7 @@ use crate::def_id::DefId; crate use crate::hir_id::HirId; use crate::itemlikevisit; -use rustc_ast::ast::{self, CrateSugar, Ident, LlvmAsmDialect, Name}; +use rustc_ast::ast::{self, CrateSugar, LlvmAsmDialect}; use rustc_ast::ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy}; pub use rustc_ast::ast::{BorrowKind, ImplPolarity, IsAuto}; pub use rustc_ast::ast::{CaptureBy, Movability, Mutability}; @@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_macros::HashStable_Generic; use rustc_span::source_map::{SourceMap, Spanned}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use rustc_target::spec::abi::Abi; @@ -2396,7 +2396,7 @@ pub enum ItemKind<'hir> { /// An `extern crate` item, with optional *original* crate name if the crate was renamed. /// /// E.g., `extern crate foo` or `extern crate foo_bar as foo`. - ExternCrate(Option), + ExternCrate(Option), /// `use foo::bar::*;` or `use foo::bar::baz as quux;` /// @@ -2564,7 +2564,7 @@ pub type TraitMap = NodeMap>>; // Map from the NodeId of a glob import to a list of items which are actually // imported. -pub type GlobMap = NodeMap>; +pub type GlobMap = NodeMap>; #[derive(Copy, Clone, Debug, HashStable_Generic)] pub enum Node<'hir> { diff --git a/src/librustc_hir/intravisit.rs b/src/librustc_hir/intravisit.rs index c8f3edcbda0d9..0270d0de5c7d7 100644 --- a/src/librustc_hir/intravisit.rs +++ b/src/librustc_hir/intravisit.rs @@ -34,8 +34,9 @@ use crate::hir::*; use crate::hir_id::CRATE_HIR_ID; use crate::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor}; -use rustc_ast::ast::{Attribute, Ident, Label, Name}; +use rustc_ast::ast::{Attribute, Label}; use rustc_ast::walk_list; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; pub struct DeepVisitor<'v, V> { @@ -317,7 +318,7 @@ pub trait Visitor<'v>: Sized { fn visit_id(&mut self, _hir_id: HirId) { // Nothing to do. } - fn visit_name(&mut self, _span: Span, _name: Name) { + fn visit_name(&mut self, _span: Span, _name: Symbol) { // Nothing to do. } fn visit_ident(&mut self, ident: Ident) { @@ -395,7 +396,7 @@ pub trait Visitor<'v>: Sized { fn visit_variant_data( &mut self, s: &'v VariantData<'v>, - _: Name, + _: Symbol, _: &'v Generics<'v>, _parent_id: HirId, _: Span, diff --git a/src/librustc_hir/pat_util.rs b/src/librustc_hir/pat_util.rs index f19b7fb69c766..2f1b5da8e13a0 100644 --- a/src/librustc_hir/pat_util.rs +++ b/src/librustc_hir/pat_util.rs @@ -1,7 +1,7 @@ use crate::def::{CtorOf, DefKind, Res}; use crate::def_id::DefId; use crate::hir::{self, HirId, PatKind}; -use rustc_ast::ast; +use rustc_span::symbol::Ident; use rustc_span::Span; use std::iter::{Enumerate, ExactSizeIterator}; @@ -79,7 +79,7 @@ impl hir::Pat<'_> { /// Call `f` on every "binding" in a pattern, e.g., on `a` in /// `match foo() { Some(a) => (), None => () }` - pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident)) { + pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, Ident)) { self.walk_always(|p| { if let PatKind::Binding(binding_mode, _, ident, _) = p.kind { f(binding_mode, p.hir_id, p.span, ident); @@ -93,7 +93,7 @@ impl hir::Pat<'_> { /// When encountering an or-pattern `p_0 | ... | p_n` only `p_0` will be visited. pub fn each_binding_or_first( &self, - f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident), + f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, Ident), ) { self.walk(|p| match &p.kind { PatKind::Or(ps) => { @@ -140,7 +140,7 @@ impl hir::Pat<'_> { satisfies } - pub fn simple_ident(&self) -> Option { + pub fn simple_ident(&self) -> Option { match self.kind { PatKind::Binding( hir::BindingAnnotation::Unannotated | hir::BindingAnnotation::Mutable, diff --git a/src/librustc_hir_pretty/lib.rs b/src/librustc_hir_pretty/lib.rs index dee51355b74e8..f8a42376d146a 100644 --- a/src/librustc_hir_pretty/lib.rs +++ b/src/librustc_hir_pretty/lib.rs @@ -10,7 +10,7 @@ use rustc_hir as hir; use rustc_hir::{GenericArg, GenericParam, GenericParamKind, Node}; use rustc_hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier}; use rustc_span::source_map::{SourceMap, Spanned}; -use rustc_span::symbol::{kw, IdentPrinter}; +use rustc_span::symbol::{kw, Ident, IdentPrinter, Symbol}; use rustc_span::{self, BytePos, FileName}; use rustc_target::spec::abi::Abi; @@ -23,7 +23,7 @@ pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: hir::HirId } pub enum AnnNode<'a> { - Name(&'a ast::Name), + Name(&'a Symbol), Block(&'a hir::Block<'a>), Item(&'a hir::Item<'a>), SubItem(hir::HirId), @@ -145,7 +145,7 @@ impl<'a> PrintState<'a> for State<'a> { &mut self.comments } - fn print_ident(&mut self, ident: ast::Ident) { + fn print_ident(&mut self, ident: Ident) { self.s.word(IdentPrinter::for_ast_ident(ident, ident.is_raw_guess()).to_string()); self.ann.post(self, AnnNode::Name(&ident.name)) } @@ -453,7 +453,7 @@ impl<'a> State<'a> { fn print_associated_const( &mut self, - ident: ast::Ident, + ident: Ident, ty: &hir::Ty<'_>, default: Option, vis: &hir::Visibility<'_>, @@ -473,7 +473,7 @@ impl<'a> State<'a> { fn print_associated_type( &mut self, - ident: ast::Ident, + ident: Ident, generics: &hir::Generics<'_>, bounds: Option>, ty: Option<&hir::Ty<'_>>, @@ -768,7 +768,7 @@ impl<'a> State<'a> { &mut self, enum_definition: &hir::EnumDef<'_>, generics: &hir::Generics<'_>, - name: ast::Name, + name: Symbol, span: rustc_span::Span, visibility: &hir::Visibility<'_>, ) { @@ -827,7 +827,7 @@ impl<'a> State<'a> { &mut self, struct_def: &hir::VariantData<'_>, generics: &hir::Generics<'_>, - name: ast::Name, + name: Symbol, span: rustc_span::Span, print_finalizer: bool, ) { @@ -886,11 +886,11 @@ impl<'a> State<'a> { } pub fn print_method_sig( &mut self, - ident: ast::Ident, + ident: Ident, m: &hir::FnSig<'_>, generics: &hir::Generics<'_>, vis: &hir::Visibility<'_>, - arg_names: &[ast::Ident], + arg_names: &[Ident], body_id: Option, ) { self.print_fn(&m.decl, m.header, Some(ident.name), generics, vis, arg_names, body_id) @@ -1297,7 +1297,7 @@ impl<'a> State<'a> { self.bopen(); // Print `let _t = $init;`: - let temp = ast::Ident::from_str("_t"); + let temp = Ident::from_str("_t"); self.print_local(Some(init), |this| this.print_ident(temp)); self.s.word(";"); @@ -1496,8 +1496,8 @@ impl<'a> State<'a> { self.s.word(i.to_string()) } - pub fn print_name(&mut self, name: ast::Name) { - self.print_ident(ast::Ident::with_dummy_span(name)) + pub fn print_name(&mut self, name: Symbol) { + self.print_ident(Ident::with_dummy_span(name)) } pub fn print_for_decl(&mut self, loc: &hir::Local<'_>, coll: &hir::Expr<'_>) { @@ -1888,10 +1888,10 @@ impl<'a> State<'a> { &mut self, decl: &hir::FnDecl<'_>, header: hir::FnHeader, - name: Option, + name: Option, generics: &hir::Generics<'_>, vis: &hir::Visibility<'_>, - arg_names: &[ast::Ident], + arg_names: &[Ident], body_id: Option, ) { self.print_fn_header_info(header, vis); @@ -2154,9 +2154,9 @@ impl<'a> State<'a> { abi: Abi, unsafety: hir::Unsafety, decl: &hir::FnDecl<'_>, - name: Option, + name: Option, generic_params: &[hir::GenericParam<'_>], - arg_names: &[ast::Ident], + arg_names: &[Ident], ) { self.ibox(INDENT_UNIT); if !generic_params.is_empty() { diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 673d6e92b7ee3..807ae586348e9 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -44,7 +44,7 @@ use rustc_middle::dep_graph::debug::{DepNodeFilter, EdgeFilter}; use rustc_middle::dep_graph::{DepGraphQuery, DepKind, DepNode, DepNodeExt}; use rustc_middle::hir::map::Map; use rustc_middle::ty::TyCtxt; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use std::env; @@ -89,7 +89,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) { } type Sources = Vec<(Span, DefId, DepNode)>; -type Targets = Vec<(Span, ast::Name, hir::HirId, DepNode)>; +type Targets = Vec<(Span, Symbol, hir::HirId, DepNode)>; struct IfThisChanged<'tcx> { tcx: TyCtxt<'tcx>, @@ -98,7 +98,7 @@ struct IfThisChanged<'tcx> { } impl IfThisChanged<'tcx> { - fn argument(&self, attr: &ast::Attribute) -> Option { + fn argument(&self, attr: &ast::Attribute) -> Option { let mut value = None; for list_item in attr.meta_item_list().unwrap_or_default() { match list_item.ident() { diff --git a/src/librustc_incremental/assert_module_sources.rs b/src/librustc_incremental/assert_module_sources.rs index 856edb3725a93..eee6e73ed1073 100644 --- a/src/librustc_incremental/assert_module_sources.rs +++ b/src/librustc_incremental/assert_module_sources.rs @@ -147,7 +147,7 @@ impl AssertModuleSource<'tcx> { ); } - fn field(&self, attr: &ast::Attribute, name: Symbol) -> ast::Name { + fn field(&self, attr: &ast::Attribute, name: Symbol) -> Symbol { for item in attr.meta_item_list().unwrap_or_else(Vec::new) { if item.check_name(name) { if let Some(value) = item.value_str() { diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 27aebf7b1b98d..9bf992537dfaf 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -499,7 +499,7 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool { } } -fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> ast::Name { +fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol { if let Some(value) = item.value_str() { value } else { diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs index 2cf9dd882e4bb..67632a97df792 100644 --- a/src/librustc_infer/infer/mod.rs +++ b/src/librustc_infer/infer/mod.rs @@ -10,7 +10,6 @@ pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog}; use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine}; -use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::undo_log::Rollback; @@ -457,7 +456,7 @@ pub enum SubregionOrigin<'tcx> { /// the containing trait. CompareImplMethodObligation { span: Span, - item_name: ast::Name, + item_name: Symbol, impl_item_def_id: DefId, trait_item_def_id: DefId, }, @@ -519,7 +518,7 @@ pub enum RegionVariableOrigin { UpvarRegion(ty::UpvarId, Span), - BoundRegionInCoherence(ast::Name), + BoundRegionInCoherence(Symbol), /// This origin is used for the inference variables that we create /// during NLL region processing. diff --git a/src/librustc_infer/traits/error_reporting/mod.rs b/src/librustc_infer/traits/error_reporting/mod.rs index 2ae7b2ff92565..f873358ff9fdd 100644 --- a/src/librustc_infer/traits/error_reporting/mod.rs +++ b/src/librustc_infer/traits/error_reporting/mod.rs @@ -1,12 +1,12 @@ use super::ObjectSafetyViolation; use crate::infer::InferCtxt; -use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_middle::ty::TyCtxt; +use rustc_span::symbol::Symbol; use rustc_span::Span; use std::fmt; @@ -14,7 +14,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn report_extra_impl_obligation( &self, error_span: Span, - item_name: ast::Name, + item_name: Symbol, _impl_item_def_id: DefId, trait_item_def_id: DefId, requirement: &dyn fmt::Display, diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index cad6a312521e4..7d5289cd46f5b 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -41,7 +41,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::lint::FutureIncompatibleInfo; use rustc_span::edition::Edition; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, Span}; use rustc_target::abi::VariantIdx; use rustc_trait_selection::traits::misc::can_type_implement_copy; @@ -1428,7 +1428,7 @@ impl KeywordIdents { &mut self, cx: &EarlyContext<'_>, UnderMacro(under_macro): UnderMacro, - ident: ast::Ident, + ident: Ident, ) { let next_edition = match cx.sess.edition() { Edition::Edition2015 => { @@ -1482,7 +1482,7 @@ impl EarlyLintPass for KeywordIdents { fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::MacCall) { self.check_tokens(cx, mac.args.inner_tokens()); } - fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) { + fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) { self.check_ident_token(cx, UnderMacro(false), ident); } } diff --git a/src/librustc_lint/early.rs b/src/librustc_lint/early.rs index 018e9da243c70..06987ffa3d569 100644 --- a/src/librustc_lint/early.rs +++ b/src/librustc_lint/early.rs @@ -20,6 +20,7 @@ use rustc_ast::ast; use rustc_ast::visit as ast_visit; use rustc_session::lint::{BufferedEarlyLint, LintBuffer, LintPass}; use rustc_session::Session; +use rustc_span::symbol::Ident; use rustc_span::Span; use log::debug; @@ -159,7 +160,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> ast_visit::walk_ty(self, t); } - fn visit_ident(&mut self, ident: ast::Ident) { + fn visit_ident(&mut self, ident: Ident) { run_early_pass!(self, check_ident, ident); } diff --git a/src/librustc_lint/internal.rs b/src/librustc_lint/internal.rs index 6de8fb45d223d..12b7459e88dc3 100644 --- a/src/librustc_lint/internal.rs +++ b/src/librustc_lint/internal.rs @@ -2,13 +2,13 @@ //! Clippy. use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; -use rustc_ast::ast::{Ident, Item, ItemKind}; +use rustc_ast::ast::{Item, ItemKind}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_hir::{GenericArg, HirId, MutTy, Mutability, Path, PathSegment, QPath, Ty, TyKind}; use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass}; use rustc_span::hygiene::{ExpnKind, MacroKind}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; declare_tool_lint! { pub rustc::DEFAULT_HASH_TYPES, diff --git a/src/librustc_lint/late.rs b/src/librustc_lint/late.rs index c4ac875fec537..c8f827b1f5ced 100644 --- a/src/librustc_lint/late.rs +++ b/src/librustc_lint/late.rs @@ -25,6 +25,7 @@ use rustc_hir::intravisit::Visitor; use rustc_middle::hir::map::Map; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint::LintPass; +use rustc_span::symbol::Symbol; use rustc_span::Span; use log::debug; @@ -192,7 +193,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> fn visit_variant_data( &mut self, s: &'tcx hir::VariantData<'tcx>, - _: ast::Name, + _: Symbol, _: &'tcx hir::Generics<'tcx>, _: hir::HirId, _: Span, @@ -227,7 +228,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> hir_visit::walk_ty(self, t); } - fn visit_name(&mut self, sp: Span, name: ast::Name) { + fn visit_name(&mut self, sp: Span, name: Symbol) { lint_callback!(self, check_name, sp, name); } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 521a0d67b59da..b791d313fc4f4 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -64,6 +64,7 @@ use rustc_session::lint::builtin::{ INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTE, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, }; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; use array_into_iter::ArrayIntoIter; diff --git a/src/librustc_lint/non_ascii_idents.rs b/src/librustc_lint/non_ascii_idents.rs index 94fc1a228df03..ad02b2637d22f 100644 --- a/src/librustc_lint/non_ascii_idents.rs +++ b/src/librustc_lint/non_ascii_idents.rs @@ -1,7 +1,7 @@ use crate::{EarlyContext, EarlyLintPass, LintContext}; use rustc_ast::ast; use rustc_data_structures::fx::FxHashMap; -use rustc_span::symbol::SymbolStr; +use rustc_span::symbol::{Ident, SymbolStr}; use std::hash::{Hash, Hasher}; use std::ops::Deref; @@ -155,7 +155,7 @@ impl EarlyLintPass for NonAsciiIdents { .or_insert((symbol_str, sp)); } } - fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) { + fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) { use unicode_security::GeneralSecurityProfile; let name_str = ident.name.as_str(); if name_str.is_ascii() { diff --git a/src/librustc_lint/passes.rs b/src/librustc_lint/passes.rs index c9e12afedbbab..04a398a29ba7b 100644 --- a/src/librustc_lint/passes.rs +++ b/src/librustc_lint/passes.rs @@ -5,6 +5,7 @@ use rustc_data_structures::sync; use rustc_hir as hir; use rustc_session::lint::builtin::HardwiredLints; use rustc_session::lint::LintPass; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; #[macro_export] @@ -14,7 +15,7 @@ macro_rules! late_lint_methods { fn check_param(a: &$hir hir::Param<$hir>); fn check_body(a: &$hir hir::Body<$hir>); fn check_body_post(a: &$hir hir::Body<$hir>); - fn check_name(a: Span, b: ast::Name); + fn check_name(a: Span, b: Symbol); fn check_crate(a: &$hir hir::Crate<$hir>); fn check_crate_post(a: &$hir hir::Crate<$hir>); fn check_mod(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId); @@ -155,7 +156,7 @@ macro_rules! early_lint_methods { ($macro:path, $args:tt) => ( $macro!($args, [ fn check_param(a: &ast::Param); - fn check_ident(a: ast::Ident); + fn check_ident(a: Ident); fn check_crate(a: &ast::Crate); fn check_crate_post(a: &ast::Crate); fn check_mod(a: &ast::Mod, b: Span, c: ast::NodeId); diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 04f17230717d9..32149c0afd597 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -4,7 +4,7 @@ use crate::creader::CrateMetadataRef; use crate::rmeta::table::{FixedSizeEncoding, Table}; use crate::rmeta::*; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; @@ -33,7 +33,7 @@ use rustc_middle::util::common::record_time; use rustc_serialize::{opaque, Decodable, Decoder, SpecializedDecoder}; use rustc_session::Session; use rustc_span::source_map::{respan, Spanned}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{self, hygiene::MacroKind, BytePos, Pos, Span, DUMMY_SP}; use log::debug; @@ -917,7 +917,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { } /// Iterates over all the stability attributes in the given crate. - fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option)] { + fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Option)] { // FIXME: For a proc macro crate, not sure whether we should return the "host" // features or an empty Vec. Both don't cause ICEs. tcx.arena.alloc_from_iter(self.root.lib_features.decode(self)) @@ -1205,7 +1205,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { .collect::>() } - fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec> { + fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec> { self.root .tables .children @@ -1317,7 +1317,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { } } - fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [ast::Name] { + fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [Symbol] { let param_names = match self.kind(id) { EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names, EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names, diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index c6c06c98ee5c2..b18272675c0b2 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::query::QueryConfig; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::{CrateDisambiguator, Session}; use rustc_span::source_map::{self, Span, Spanned}; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{Ident, Symbol}; use rustc_data_structures::sync::Lrc; use smallvec::SmallVec; @@ -419,7 +419,7 @@ impl CStore { .disambiguated_data .data .get_opt_name() - .map(ast::Ident::with_dummy_span) // FIXME: cross-crate hygiene + .map(Ident::with_dummy_span) // FIXME: cross-crate hygiene .expect("no name in load_macro"); LoadedMacro::MacroDef( diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 4ac2092bb069a..2589e162dffe2 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -2,7 +2,7 @@ use crate::rmeta::table::FixedSizeEncoding; use crate::rmeta::*; use log::{debug, trace}; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_ast::attr; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -32,7 +32,7 @@ use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt}; use rustc_serialize::{opaque, Encodable, Encoder, SpecializedEncoder}; use rustc_session::config::CrateType; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{self, ExternalSource, FileName, SourceFile, Span}; use rustc_target::abi::VariantIdx; use std::hash::Hash; @@ -989,7 +989,7 @@ impl EncodeContext<'tcx> { } } - fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[ast::Name]> { + fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Symbol]> { self.tcx.dep_graph.with_ignore(|| { let body = self.tcx.hir().body(body_id); self.lazy(body.params.iter().map(|arg| match arg.pat.kind { @@ -999,7 +999,7 @@ impl EncodeContext<'tcx> { }) } - fn encode_fn_param_names(&mut self, param_names: &[ast::Ident]) -> Lazy<[ast::Name]> { + fn encode_fn_param_names(&mut self, param_names: &[Ident]) -> Lazy<[Symbol]> { self.lazy(param_names.iter().map(|ident| ident.name)) } @@ -1410,7 +1410,7 @@ impl EncodeContext<'tcx> { self.lazy(deps.iter().map(|&(_, ref dep)| dep)) } - fn encode_lib_features(&mut self) -> Lazy<[(ast::Name, Option)]> { + fn encode_lib_features(&mut self) -> Lazy<[(Symbol, Option)]> { let tcx = self.tcx; let lib_features = tcx.lib_features(); self.lazy(lib_features.to_vec()) diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index e2d979ae48828..669307612055a 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -215,7 +215,7 @@ crate struct CrateRoot<'tcx> { #[derive(RustcEncodable, RustcDecodable)] crate struct CrateDep { - pub name: ast::Name, + pub name: Symbol, pub hash: Svh, pub host_hash: Option, pub kind: DepKind, @@ -327,7 +327,7 @@ struct ModData { struct FnData { asyncness: hir::IsAsync, constness: hir::Constness, - param_names: Lazy<[ast::Name]>, + param_names: Lazy<[Symbol]>, } #[derive(RustcEncodable, RustcDecodable)] diff --git a/src/librustc_middle/arena.rs b/src/librustc_middle/arena.rs index 96ef4b3741200..a97db3134dc9e 100644 --- a/src/librustc_middle/arena.rs +++ b/src/librustc_middle/arena.rs @@ -65,7 +65,7 @@ macro_rules! arena_types { [] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation, [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>, [] attribute: rustc_ast::ast::Attribute, - [] name_set: rustc_data_structures::fx::FxHashSet, + [] name_set: rustc_data_structures::fx::FxHashSet, [] hir_id_set: rustc_hir::HirIdSet, // Interned types diff --git a/src/librustc_middle/hir/exports.rs b/src/librustc_middle/hir/exports.rs index 4c144a54d6345..83baf6cc43345 100644 --- a/src/librustc_middle/hir/exports.rs +++ b/src/librustc_middle/hir/exports.rs @@ -1,9 +1,9 @@ use crate::ty; -use rustc_ast::ast; use rustc_hir::def::Res; use rustc_hir::def_id::DefIdMap; use rustc_macros::HashStable; +use rustc_span::symbol::Ident; use rustc_span::Span; use std::fmt::Debug; @@ -15,7 +15,7 @@ pub type ExportMap = DefIdMap>>; #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct Export { /// The name of the target. - pub ident: ast::Ident, + pub ident: Ident, /// The resolution of the target. pub res: Res, /// The span of the target. diff --git a/src/librustc_middle/hir/map/blocks.rs b/src/librustc_middle/hir/map/blocks.rs index 7024e86f95d06..a2e4372f017ce 100644 --- a/src/librustc_middle/hir/map/blocks.rs +++ b/src/librustc_middle/hir/map/blocks.rs @@ -12,10 +12,11 @@ //! for the `Code` associated with a particular NodeId. use crate::hir::map::Map; -use rustc_ast::ast::{Attribute, Ident}; +use rustc_ast::ast::Attribute; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; use rustc_hir::{Expr, FnDecl, Node}; +use rustc_span::symbol::Ident; use rustc_span::Span; /// An FnLikeNode is a Node that is like a fn, in that it has a decl diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs index 1c71fc57bea5a..5ea2b8b8e49dc 100644 --- a/src/librustc_middle/hir/map/mod.rs +++ b/src/librustc_middle/hir/map/mod.rs @@ -3,7 +3,7 @@ use self::collector::NodeCollector; use crate::hir::{Owner, OwnerNodes}; use crate::ty::query::Providers; use crate::ty::TyCtxt; -use rustc_ast::ast::{self, Name, NodeId}; +use rustc_ast::ast::{self, NodeId}; use rustc_data_structures::svh::Svh; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; @@ -14,7 +14,7 @@ use rustc_hir::*; use rustc_index::vec::IndexVec; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::Spanned; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, Symbol}; use rustc_span::Span; use rustc_target::spec::abi::Abi; @@ -432,7 +432,7 @@ impl<'hir> Map<'hir> { } } - pub fn ty_param_name(&self, id: HirId) -> Name { + pub fn ty_param_name(&self, id: HirId) -> Symbol { match self.get(id) { Node::Item(&Item { kind: ItemKind::Trait(..) | ItemKind::TraitAlias(..), .. }) => { kw::SelfUpper @@ -804,7 +804,7 @@ impl<'hir> Map<'hir> { } } - pub fn opt_name(&self, id: HirId) -> Option { + pub fn opt_name(&self, id: HirId) -> Option { Some(match self.get(id) { Node::Item(i) => i.ident.name, Node::ForeignItem(fi) => fi.ident.name, @@ -820,7 +820,7 @@ impl<'hir> Map<'hir> { }) } - pub fn name(&self, id: HirId) -> Name { + pub fn name(&self, id: HirId) -> Symbol { match self.opt_name(id) { Some(name) => name, None => bug!("no name for {}", self.node_to_string(id)), @@ -932,42 +932,42 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> { } trait Named { - fn name(&self) -> Name; + fn name(&self) -> Symbol; } impl Named for Spanned { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.node.name() } } impl Named for Item<'_> { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.ident.name } } impl Named for ForeignItem<'_> { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.ident.name } } impl Named for Variant<'_> { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.ident.name } } impl Named for StructField<'_> { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.ident.name } } impl Named for TraitItem<'_> { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.ident.name } } impl Named for ImplItem<'_> { - fn name(&self) -> Name { + fn name(&self) -> Symbol { self.ident.name } } diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 8d416536155ac..4faf8461b8a80 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -19,7 +19,6 @@ use rustc_target::abi::VariantIdx; use polonius_engine::Atom; pub use rustc_ast::ast::Mutability; -use rustc_ast::ast::Name; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::dominators::{dominators, Dominators}; use rustc_data_structures::graph::{self, GraphSuccessors}; @@ -971,7 +970,7 @@ impl<'tcx> LocalDecl<'tcx> { /// Debug information pertaining to a user variable. #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)] pub struct VarDebugInfo<'tcx> { - pub name: Name, + pub name: Symbol, /// Source info of the user variable, including the scope /// within which the variable is visible (to debuginfo) diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index b0c442381484c..bd7e3b31b97da 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -639,7 +639,7 @@ rustc_queries! { } Other { - query fn_arg_names(_: DefId) -> &'tcx [ast::Name] {} + query fn_arg_names(_: DefId) -> &'tcx [Symbol] {} /// Gets the rendered value of the specified constant or associated constant. /// Used by rustdoc. query rendered_const(_: DefId) -> String {} @@ -1052,7 +1052,7 @@ rustc_queries! { desc { "looking up all possibly unused extern crates" } } query names_imported_by_glob_use(def_id: LocalDefId) - -> &'tcx FxHashSet { + -> &'tcx FxHashSet { eval_always desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) } } diff --git a/src/librustc_middle/traits/mod.rs b/src/librustc_middle/traits/mod.rs index 3a05d577bfa7e..6cc00b8d3b764 100644 --- a/src/librustc_middle/traits/mod.rs +++ b/src/librustc_middle/traits/mod.rs @@ -11,9 +11,9 @@ use crate::mir::interpret::ErrorHandled; use crate::ty::subst::SubstsRef; use crate::ty::{self, AdtKind, Ty, TyCtxt}; -use rustc_ast::ast; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -198,14 +198,14 @@ pub enum ObligationCauseCode<'tcx> { /// Error derived when matching traits/impls; see ObligationCause for more details CompareImplMethodObligation { - item_name: ast::Name, + item_name: Symbol, impl_item_def_id: DefId, trait_item_def_id: DefId, }, /// Error derived when matching traits/impls; see ObligationCause for more details CompareImplTypeObligation { - item_name: ast::Name, + item_name: Symbol, impl_item_def_id: DefId, trait_item_def_id: DefId, }, @@ -566,10 +566,10 @@ pub enum ObjectSafetyViolation { SupertraitSelf(SmallVec<[Span; 1]>), /// Method has something illegal. - Method(ast::Name, MethodViolationCode, Span), + Method(Symbol, MethodViolationCode, Span), /// Associated const. - AssocConst(ast::Name, Span), + AssocConst(Symbol, Span), } impl ObjectSafetyViolation { diff --git a/src/librustc_middle/traits/specialization_graph.rs b/src/librustc_middle/traits/specialization_graph.rs index bc743666e4a21..4f02aaa96acd3 100644 --- a/src/librustc_middle/traits/specialization_graph.rs +++ b/src/librustc_middle/traits/specialization_graph.rs @@ -1,11 +1,11 @@ use crate::ich::{self, StableHashingContext}; use crate::ty::fast_reject::SimplifiedType; use crate::ty::{self, TyCtxt}; -use rustc_ast::ast::Ident; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_errors::ErrorReported; use rustc_hir::def_id::{DefId, DefIdMap}; +use rustc_span::symbol::Ident; /// A per-trait graph of impls in specialization order. At the moment, this /// graph forms a tree rooted with the trait itself, with all other nodes diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index e43eb01ad96f7..d6fdc71b1ac87 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -376,7 +376,7 @@ pub struct TypeckTables<'tcx> { /// Records the reasons that we picked the kind of each closure; /// not all closures are present in the map. - closure_kind_origins: ItemLocalMap<(Span, ast::Name)>, + closure_kind_origins: ItemLocalMap<(Span, Symbol)>, /// For each fn, records the "liberated" types of its arguments /// and return type. Liberated means that all bound regions @@ -621,11 +621,11 @@ impl<'tcx> TypeckTables<'tcx> { self.upvar_capture_map[&upvar_id] } - pub fn closure_kind_origins(&self) -> LocalTableInContext<'_, (Span, ast::Name)> { + pub fn closure_kind_origins(&self) -> LocalTableInContext<'_, (Span, Symbol)> { LocalTableInContext { hir_owner: self.hir_owner, data: &self.closure_kind_origins } } - pub fn closure_kind_origins_mut(&mut self) -> LocalTableInContextMut<'_, (Span, ast::Name)> { + pub fn closure_kind_origins_mut(&mut self) -> LocalTableInContextMut<'_, (Span, Symbol)> { LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.closure_kind_origins } } @@ -941,10 +941,10 @@ pub struct GlobalCtxt<'tcx> { maybe_unused_extern_crates: Vec<(DefId, Span)>, /// A map of glob use to a set of names it actually imports. Currently only /// used in save-analysis. - glob_map: FxHashMap>, + glob_map: FxHashMap>, /// Extern prelude entries. The value is `true` if the entry was introduced /// via `extern crate` item and not `--extern` option or compiler built-in. - pub extern_prelude: FxHashMap, + pub extern_prelude: FxHashMap, // Internal cache for metadata decoding. No need to track deps on this. pub rcache: Lock>>, diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index ade89ab39d472..7c4e4d095bc5d 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -4,13 +4,14 @@ use crate::mir::{GeneratorLayout, GeneratorSavedLocal}; use crate::ty::subst::Subst; use crate::ty::{self, subst::SubstsRef, ReprOptions, Ty, TyCtxt, TypeFoldable}; -use rustc_ast::ast::{self, Ident, IntTy, UintTy}; +use rustc_ast::ast::{self, IntTy, UintTy}; use rustc_attr as attr; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir as hir; use rustc_index::bit_set::BitSet; use rustc_index::vec::{Idx, IndexVec}; use rustc_session::{DataTypeKind, FieldInfo, SizeKind, VariantInfo}; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ ArgAbi, ArgAttribute, ArgAttributes, Conv, FnAbi, PassMode, Reg, RegKind, @@ -1628,9 +1629,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { let adt_kind = adt_def.adt_kind(); let adt_packed = adt_def.repr.pack.is_some(); - let build_variant_info = |n: Option, - flds: &[ast::Name], - layout: TyAndLayout<'tcx>| { + let build_variant_info = |n: Option, flds: &[Symbol], layout: TyAndLayout<'tcx>| { let mut min_size = Size::ZERO; let field_info: Vec<_> = flds .iter() diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 8bb9934789a23..02fe7adcd0738 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -17,7 +17,7 @@ use crate::traits::{self, Reveal}; use crate::ty; use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; use crate::ty::util::{Discr, IntTypeExt}; -use rustc_ast::ast::{self, Ident, Name}; +use rustc_ast::ast; use rustc_ast::node_id::{NodeId, NodeMap, NodeSet}; use rustc_attr as attr; use rustc_data_structures::captures::Captures; @@ -38,7 +38,7 @@ use rustc_macros::HashStable; use rustc_serialize::{self, Encodable, Encoder}; use rustc_session::DataTypeKind; use rustc_span::hygiene::ExpnId; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use rustc_target::abi::{Align, VariantIdx}; @@ -128,7 +128,7 @@ pub struct ResolverOutputs { pub glob_map: GlobMap, /// Extern prelude entries. The value is `true` if the entry was introduced /// via `extern crate` item and not `--extern` option or compiler built-in. - pub extern_prelude: FxHashMap, + pub extern_prelude: FxHashMap, } #[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)] diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 2d2704fc2bd89..32cad07bd7934 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -12,7 +12,7 @@ use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_target::abi::{Integer, Size}; use rustc_target::spec::abi::Abi; @@ -1456,7 +1456,7 @@ impl Printer<'tcx> for FmtPrinter<'_, 'tcx, F> { if !self.empty_path { write!(self, "::")?; } - if ast::Ident::from_str(&name).is_raw_guess() { + if Ident::from_str(&name).is_raw_guess() { write!(self, "r#")?; } write!(self, "{}", name)?; diff --git a/src/librustc_middle/ty/query/on_disk_cache.rs b/src/librustc_middle/ty/query/on_disk_cache.rs index 760fdbe8522f4..71c2c24cc0a9f 100644 --- a/src/librustc_middle/ty/query/on_disk_cache.rs +++ b/src/librustc_middle/ty/query/on_disk_cache.rs @@ -4,7 +4,6 @@ use crate::mir::{self, interpret}; use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder}; use crate::ty::context::TyCtxt; use crate::ty::{self, Ty}; -use rustc_ast::ast::Ident; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{HashMapExt, Lock, Lrc, Once}; @@ -20,6 +19,7 @@ use rustc_serialize::{ use rustc_session::{CrateDisambiguator, Session}; use rustc_span::hygiene::{ExpnId, SyntaxContext}; use rustc_span::source_map::{SourceMap, StableSourceFileId}; +use rustc_span::symbol::Ident; use rustc_span::CachingSourceMapView; use rustc_span::{BytePos, SourceFile, Span, DUMMY_SP}; use std::mem; diff --git a/src/librustc_middle/ty/sty.rs b/src/librustc_middle/ty/sty.rs index ac5477edcc3c0..a6cf3b7e2ee74 100644 --- a/src/librustc_middle/ty/sty.rs +++ b/src/librustc_middle/ty/sty.rs @@ -16,14 +16,14 @@ use crate::ty::{ }; use crate::ty::{List, ParamEnv, ParamEnvAnd, TyS}; use polonius_engine::Atom; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_data_structures::captures::Captures; use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_index::vec::Idx; use rustc_macros::HashStable; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_target::abi::{Size, VariantIdx}; use rustc_target::spec::abi; use std::borrow::Cow; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 465aa5847af36..1745a80ca9abf 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1,6 +1,5 @@ //! This query borrow-checks the MIR to (further) ensure it is not broken. -use rustc_ast::ast::Name; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::graph::dominators::Dominators; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; @@ -22,7 +21,7 @@ use rustc_middle::mir::{Terminator, TerminatorKind}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, RegionVid, TyCtxt}; use rustc_session::lint::builtin::{MUTABLE_BORROW_RESERVATION_CONFLICT, UNUSED_MUT}; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::{Span, Symbol, DUMMY_SP}; use either::Either; use smallvec::SmallVec; @@ -76,7 +75,7 @@ crate use region_infer::RegionInferenceContext; // FIXME(eddyb) perhaps move this somewhere more centrally. #[derive(Debug)] crate struct Upvar { - name: Name, + name: Symbol, var_hir_id: HirId, @@ -533,7 +532,7 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> { upvars: Vec, /// Names of local (user) variables (extracted from `var_debug_info`). - local_names: IndexVec>, + local_names: IndexVec>, /// Record the region names generated for each region in the given /// MIR def so that we can reuse them later in help/error messages. diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 1d982d18eeb0d..0f58620d8e2a5 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -1,6 +1,5 @@ use crate::{shim, util}; use required_consts::RequiredConstsVisitor; -use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; @@ -11,7 +10,7 @@ use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::steal::Steal; use rustc_middle::ty::{InstanceDef, TyCtxt, TypeFoldable}; -use rustc_span::Span; +use rustc_span::{Span, Symbol}; use std::borrow::Cow; pub mod add_call_guards; @@ -78,7 +77,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> FxHashSet { fn visit_variant_data( &mut self, v: &'tcx hir::VariantData<'tcx>, - _: ast::Name, + _: Symbol, _: &'tcx hir::Generics<'tcx>, _: hir::HirId, _: Span, diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index b9d61458a839b..e58579acdf2e4 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -10,7 +10,6 @@ use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard}; use crate::build::{BlockAnd, BlockAndExtension, Builder}; use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; use crate::hair::{self, *}; -use rustc_ast::ast::Name; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::HirId; use rustc_index::bit_set::BitSet; @@ -18,6 +17,7 @@ use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty}; use rustc_span::Span; +use rustc_span::symbol::Symbol; use rustc_target::abi::VariantIdx; use smallvec::{smallvec, SmallVec}; @@ -570,7 +570,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { f: &mut impl FnMut( &mut Self, Mutability, - Name, + Symbol, BindingMode, HirId, Span, @@ -737,7 +737,7 @@ fn traverse_candidate<'pat, 'tcx: 'pat, C, T, I>( struct Binding<'tcx> { span: Span, source: Place<'tcx>, - name: Name, + name: Symbol, var_id: HirId, var_ty: Ty<'tcx>, mutability: Mutability, @@ -1924,7 +1924,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info: SourceInfo, visibility_scope: SourceScope, mutability: Mutability, - name: Name, + name: Symbol, mode: BindingMode, var_id: HirId, var_ty: Ty<'tcx>, diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index bd75f11fb8f94..f38471da94ee2 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -24,7 +24,7 @@ use rustc_middle::ty::{self, AdtDef, DefIdTree, Region, Ty, TyCtxt, UserType}; use rustc_middle::ty::{ CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, }; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::{Span, Symbol, DUMMY_SP}; use rustc_target::abi::VariantIdx; use std::cmp::Ordering; @@ -128,7 +128,7 @@ crate enum PatKind<'tcx> { /// `x`, `ref x`, `x @ P`, etc. Binding { mutability: Mutability, - name: ast::Name, + name: Symbol, mode: BindingMode, var: hir::HirId, ty: Ty<'tcx>, @@ -932,7 +932,7 @@ macro_rules! CloneImpls { } CloneImpls! { <'tcx> - Span, Field, Mutability, ast::Name, hir::HirId, usize, ty::Const<'tcx>, + Span, Field, Mutability, Symbol, hir::HirId, usize, ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef, SubstsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>, UserTypeProjection, PatTyProj<'tcx> diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index fe129f2c3a88c..437d0ffa1196d 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -1,9 +1,7 @@ use super::ty::AllowPlus; use super::{BlockMode, Parser, PathStyle, SemiColonMode, SeqSep, TokenExpectType, TokenType}; -use rustc_ast::ast::{ - self, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, Param, -}; +use rustc_ast::ast::{self, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Item, Param}; use rustc_ast::ast::{AttrVec, ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind}; use rustc_ast::ptr::P; use rustc_ast::token::{self, Lit, LitKind, TokenKind}; @@ -13,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::{pluralize, struct_span_err}; use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult}; use rustc_span::source_map::Spanned; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, Ident}; use rustc_span::{MultiSpan, Span, SpanSnippetError, DUMMY_SP}; use log::{debug, trace}; diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index b3bb72554e9c4..ca497a3b06f4a 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -4,7 +4,7 @@ use super::{BlockMode, Parser, PathStyle, Restrictions, TokenType}; use super::{SemiColonMode, SeqSep, TokenExpectType}; use crate::maybe_recover_from_interpolated_ty_qpath; -use rustc_ast::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Ident, Lit, UnOp, DUMMY_NODE_ID}; +use rustc_ast::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Lit, UnOp, DUMMY_NODE_ID}; use rustc_ast::ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind}; use rustc_ast::ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits}; use rustc_ast::ptr::P; @@ -15,7 +15,7 @@ use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity}; use rustc_ast_pretty::pprust; use rustc_errors::{Applicability, DiagnosticBuilder, PResult}; use rustc_span::source_map::{self, Span, Spanned}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use std::mem; /// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 7fb814973e250..4fe0453e9c87f 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -4,7 +4,7 @@ use super::{FollowedByType, Parser, PathStyle}; use crate::maybe_whole; -use rustc_ast::ast::{self, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID}; +use rustc_ast::ast::{self, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID}; use rustc_ast::ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind, Mod}; use rustc_ast::ast::{Async, Const, Defaultness, IsAuto, Mutability, Unsafe, UseTree, UseTreeKind}; use rustc_ast::ast::{BindingMode, Block, FnDecl, FnSig, Param, SelfKind}; @@ -18,7 +18,7 @@ use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, PResult, StashKey}; use rustc_span::edition::Edition; use rustc_span::source_map::{self, Span}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use log::debug; use std::convert::TryFrom; @@ -804,7 +804,7 @@ impl<'a> Parser<'a> { if self.eat_keyword(kw::As) { self.parse_ident_or_underscore().map(Some) } else { Ok(None) } } - fn parse_ident_or_underscore(&mut self) -> PResult<'a, ast::Ident> { + fn parse_ident_or_underscore(&mut self) -> PResult<'a, Ident> { match self.token.ident() { Some((ident @ Ident { name: kw::Underscore, .. }, false)) => { self.bump(); @@ -834,7 +834,7 @@ impl<'a> Parser<'a> { Ok((item_name, ItemKind::ExternCrate(orig_name))) } - fn parse_crate_name_with_dashes(&mut self) -> PResult<'a, ast::Ident> { + fn parse_crate_name_with_dashes(&mut self) -> PResult<'a, Ident> { 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 \ in the code"; diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs index 9264fc8a73518..bdb4d7c9df6be 100644 --- a/src/librustc_parse/parser/mod.rs +++ b/src/librustc_parse/parser/mod.rs @@ -14,7 +14,7 @@ use crate::lexer::UnmatchedBrace; use log::debug; use rustc_ast::ast::DUMMY_NODE_ID; -use rustc_ast::ast::{self, AttrStyle, AttrVec, Const, CrateSugar, Extern, Ident, Unsafe}; +use rustc_ast::ast::{self, AttrStyle, AttrVec, Const, CrateSugar, Extern, Unsafe}; use rustc_ast::ast::{ Async, MacArgs, MacDelimiter, Mutability, StrLit, Visibility, VisibilityKind, }; @@ -26,7 +26,7 @@ use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, FatalError, PResult}; use rustc_session::parse::ParseSess; use rustc_span::source_map::{respan, Span, DUMMY_SP}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use std::{cmp, mem, slice}; @@ -424,11 +424,11 @@ impl<'a> Parser<'a> { } // Public for rustfmt usage. - pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { + pub fn parse_ident(&mut self) -> PResult<'a, Ident> { self.parse_ident_common(true) } - fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { + fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> { match self.token.ident() { Some((ident, is_raw)) => { if !is_raw && ident.is_reserved() { diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index d588373425d65..6603d0afc0248 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -1,14 +1,14 @@ use super::{Parser, PathStyle}; use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; use rustc_ast::ast::{self, AttrVec, Attribute, FieldPat, MacCall, Pat, PatKind, RangeEnd}; -use rustc_ast::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf, RangeSyntax}; +use rustc_ast::ast::{BindingMode, Expr, ExprKind, Mutability, Path, QSelf, RangeSyntax}; use rustc_ast::mut_visit::{noop_visit_mac, noop_visit_pat, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult}; use rustc_span::source_map::{respan, Span, Spanned}; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; type Expected = Option<&'static str>; diff --git a/src/librustc_parse/parser/path.rs b/src/librustc_parse/parser/path.rs index 9fa7bc027b878..5210614548da3 100644 --- a/src/librustc_parse/parser/path.rs +++ b/src/librustc_parse/parser/path.rs @@ -3,12 +3,12 @@ use super::{Parser, TokenType}; use crate::maybe_whole; use rustc_ast::ast::{self, AngleBracketedArg, AngleBracketedArgs, GenericArg, ParenthesizedArgs}; use rustc_ast::ast::{AnonConst, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode}; -use rustc_ast::ast::{Ident, Path, PathSegment, QSelf}; +use rustc_ast::ast::{Path, PathSegment, QSelf}; use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_errors::{pluralize, Applicability, PResult}; use rustc_span::source_map::{BytePos, Span}; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; use log::debug; use std::mem; diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index 1b8c053b16e0b..93caa8697744d 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -16,7 +16,7 @@ use rustc_middle::ty::{self, DefIdTree, TyCtxt}; use rustc_session::lint; use rustc_ast::{ast, attr}; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Symbol}; // Any local node that may call something in its body block should be // explored. For example, if it's a live Node::Item that is a @@ -229,7 +229,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { fn visit_variant_data( &mut self, def: &'tcx hir::VariantData<'tcx>, - _: ast::Name, + _: Symbol, _: &hir::Generics<'_>, _: hir::HirId, _: rustc_span::Span, @@ -551,7 +551,7 @@ impl DeadVisitor<'tcx> { &mut self, id: hir::HirId, span: rustc_span::Span, - name: ast::Name, + name: Symbol, participle: &str, ) { if !name.as_str().starts_with('_') { diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 8f736c1dd549b..75ac8e731b5da 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -96,7 +96,6 @@ use self::LiveNodeKind::*; use self::VarKind::*; -use rustc_ast::ast; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::Applicability; use rustc_hir as hir; @@ -108,7 +107,7 @@ use rustc_middle::hir::map::Map; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use std::collections::VecDeque; @@ -245,13 +244,13 @@ struct CaptureInfo { #[derive(Copy, Clone, Debug)] struct LocalInfo { id: HirId, - name: ast::Name, + name: Symbol, is_shorthand: bool, } #[derive(Copy, Clone, Debug)] enum VarKind { - Param(HirId, ast::Name), + Param(HirId, Symbol), Local(LocalInfo), CleanExit, } diff --git a/src/librustc_plugin_impl/load.rs b/src/librustc_plugin_impl/load.rs index f48d2b6c8b5e6..c3a6016696888 100644 --- a/src/librustc_plugin_impl/load.rs +++ b/src/librustc_plugin_impl/load.rs @@ -1,12 +1,12 @@ //! Used by `rustc` when loading a plugin. use crate::Registry; -use rustc_ast::ast::{Crate, Ident}; +use rustc_ast::ast::Crate; use rustc_errors::struct_span_err; use rustc_metadata::locator; use rustc_middle::middle::cstore::MetadataLoader; use rustc_session::Session; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; use std::borrow::ToOwned; diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index 34146113f0e8e..6110d2ef7fc9a 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -15,7 +15,6 @@ rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } rustc_typeck = { path = "../librustc_typeck" } rustc_session = { path = "../librustc_session" } -rustc_ast = { path = "../librustc_ast" } rustc_span = { path = "../librustc_span" } rustc_data_structures = { path = "../librustc_data_structures" } log = "0.4" diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 82b45cf7cf884..917e2f548302f 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -4,7 +4,6 @@ #![feature(or_patterns)] #![recursion_limit = "256"] -use rustc_ast::ast::Ident; use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; @@ -22,7 +21,7 @@ use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::{self, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable}; use rustc_session::lint; use rustc_span::hygiene::Transparency; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Span; use std::marker::PhantomData; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index bd484fc7a90cf..d0eb1cfc222e6 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -17,7 +17,6 @@ use crate::{Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segmen use rustc_ast::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; use rustc_ast::ast::{AssocItem, AssocItemKind, MetaItemKind, StmtKind}; -use rustc_ast::ast::{Ident, Name}; use rustc_ast::token::{self, Token}; use rustc_ast::visit::{self, AssocCtxt, Visitor}; use rustc_attr as attr; @@ -34,7 +33,7 @@ use rustc_middle::middle::cstore::CrateStore; use rustc_middle::ty; use rustc_span::hygiene::{ExpnId, MacroKind}; use rustc_span::source_map::{respan, Spanned}; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use log::debug; @@ -293,7 +292,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { self.insert_field_names(def_id, field_names); } - fn insert_field_names(&mut self, def_id: DefId, field_names: Vec>) { + fn insert_field_names(&mut self, def_id: DefId, field_names: Vec>) { if !field_names.is_empty() { self.r.field_names.insert(def_id, field_names); } @@ -953,7 +952,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { fn add_macro_use_binding( &mut self, - name: ast::Name, + name: Symbol, binding: &'a NameBinding<'a>, span: Span, allow_shadowing: bool, diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 8e82480c6305d..c66e9a6040669 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -2,7 +2,7 @@ use std::cmp::Reverse; use std::ptr; use log::debug; -use rustc_ast::ast::{self, Ident, Path}; +use rustc_ast::ast::{self, Path}; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; @@ -16,7 +16,7 @@ use rustc_middle::ty::{self, DefIdTree}; use rustc_session::Session; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::SourceMap; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::{BytePos, MultiSpan, Span}; use crate::imports::{Import, ImportKind, ImportResolver}; diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs index 5324e370dbdf2..a1e05d21b58d5 100644 --- a/src/librustc_resolve/imports.rs +++ b/src/librustc_resolve/imports.rs @@ -9,7 +9,7 @@ use crate::{BindingKey, ModuleKind, ResolutionError, Resolver, Segment}; use crate::{CrateLint, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet, Weak}; use crate::{NameBinding, NameBindingKind, PathResult, PrivacyError, ToNameBinding}; -use rustc_ast::ast::{Ident, Name, NodeId}; +use rustc_ast::ast::NodeId; use rustc_ast::unwrap_or; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::FxHashSet; @@ -24,7 +24,7 @@ use rustc_session::lint::builtin::{PUB_USE_OF_PRIVATE_EXTERN_CRATE, UNUSED_IMPOR use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::DiagnosticMessageId; use rustc_span::hygiene::ExpnId; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::{MultiSpan, Span}; use log::*; @@ -57,7 +57,7 @@ pub enum ImportKind<'a> { // n.b. `max_vis` is only used in `finalize_import` to check for re-export errors. }, ExternCrate { - source: Option, + source: Option, target: Ident, }, MacroUse, diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 6214186a901a1..e541920e89ed4 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -24,7 +24,7 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_hir::TraitCandidate; use rustc_middle::{bug, span_bug}; use rustc_session::lint; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use smallvec::{smallvec, SmallVec}; @@ -1194,7 +1194,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { fn check_trait_item(&mut self, ident: Ident, ns: Namespace, span: Span, err: F) where - F: FnOnce(Name, &str) -> ResolutionError<'_>, + F: FnOnce(Symbol, &str) -> ResolutionError<'_>, { // If there is a TraitRef in scope for an impl, then the method must be in the // trait. diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index 6041a56d366d3..dc92b465c2bc1 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -5,7 +5,7 @@ use crate::path_names_to_string; use crate::{CrateLint, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{PathResult, PathSource, Segment}; -use rustc_ast::ast::{self, Expr, ExprKind, Ident, Item, ItemKind, NodeId, Path, Ty, TyKind}; +use rustc_ast::ast::{self, Expr, ExprKind, Item, ItemKind, NodeId, Path, Ty, TyKind}; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; @@ -16,7 +16,7 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_hir::PrimTy; use rustc_session::config::nightly_options; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Span; use log::debug; @@ -1047,7 +1047,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { err: &mut DiagnosticBuilder<'_>, span: Span, count: usize, - lifetime_names: &FxHashSet, + lifetime_names: &FxHashSet, params: &[ElisionFailureInfo], ) { let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok(); diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index a062330ba4be6..a3fbb28f22a56 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -6,7 +6,6 @@ //! way. Therefore, we break lifetime name resolution into a separate pass. use crate::late::diagnostics::{ForLifetimeSpanType, MissingLifetimeSpot}; -use rustc_ast::ast; use rustc_ast::attr; use rustc_ast::walk_list; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -22,7 +21,7 @@ use rustc_middle::middle::resolve_lifetime::*; use rustc_middle::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_session::lint; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use std::borrow::Cow; use std::cell::Cell; @@ -175,7 +174,7 @@ crate struct LifetimeContext<'a, 'tcx> { is_in_fn_syntax: bool, /// List of labels in the function/method currently under analysis. - labels_in_fn: Vec, + labels_in_fn: Vec, /// Cache for cross-crate per-definition object lifetime defaults. xcrate_object_lifetime_defaults: DefIdMap>, @@ -1064,7 +1063,7 @@ fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &[hir::Generic } } -fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: ast::Name, orig: Original, shadower: Shadower) { +fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: Symbol, orig: Original, shadower: Shadower) { let mut err = if let (ShadowKind::Lifetime, ShadowKind::Lifetime) = (orig.kind, shadower.kind) { // lifetime/lifetime shadowing is an error struct_span_err!( @@ -1102,7 +1101,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body<'_>) { struct GatherLabels<'a, 'tcx> { tcx: TyCtxt<'tcx>, scope: ScopeRef<'a>, - labels_in_fn: &'a mut Vec, + labels_in_fn: &'a mut Vec, } let mut gather = @@ -1138,15 +1137,11 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body<'_>) { } } - fn expression_label(ex: &hir::Expr<'_>) -> Option { + fn expression_label(ex: &hir::Expr<'_>) -> Option { if let hir::ExprKind::Loop(_, Some(label), _) = ex.kind { Some(label.ident) } else { None } } - fn check_if_label_shadows_lifetime( - tcx: TyCtxt<'_>, - mut scope: ScopeRef<'_>, - label: ast::Ident, - ) { + fn check_if_label_shadows_lifetime(tcx: TyCtxt<'_>, mut scope: ScopeRef<'_>, label: Ident) { loop { match *scope { Scope::Body { s, .. } @@ -1360,11 +1355,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { /// helper method to determine the span to remove when suggesting the /// deletion of a lifetime - fn lifetime_deletion_span( - &self, - name: ast::Ident, - generics: &hir::Generics<'_>, - ) -> Option { + fn lifetime_deletion_span(&self, name: Ident, generics: &hir::Generics<'_>) -> Option { generics.params.iter().enumerate().find_map(|(i, param)| { if param.name.ident() == name { let mut in_band = false; @@ -2394,7 +2385,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { if let Some(params) = error { // If there's no lifetime available, suggest `'static`. if self.report_elision_failure(&mut err, params) && lifetime_names.is_empty() { - lifetime_names.insert(ast::Ident::from_str("'static")); + lifetime_names.insert(Ident::from_str("'static")); } } self.add_missing_lifetime_specifiers_label( diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index d33eaf5a827db..2031b7868c0d0 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -17,7 +17,7 @@ pub use rustc_hir::def::{Namespace, PerNS}; use Determinacy::*; -use rustc_ast::ast::{self, FloatTy, Ident, IntTy, Name, NodeId, UintTy}; +use rustc_ast::ast::{self, FloatTy, IntTy, NodeId, UintTy}; use rustc_ast::ast::{Crate, CRATE_NODE_ID}; use rustc_ast::ast::{ItemKind, Path}; use rustc_ast::attr; @@ -47,7 +47,7 @@ use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer}; use rustc_session::Session; use rustc_span::hygiene::{ExpnId, ExpnKind, MacroKind, SyntaxContext, Transparency}; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use log::debug; @@ -147,7 +147,7 @@ impl<'a> ParentScope<'a> { #[derive(Eq)] struct BindingError { - name: Name, + name: Symbol, origin: BTreeSet, target: BTreeSet, could_be_path: bool, @@ -176,23 +176,23 @@ enum ResolutionError<'a> { GenericParamsFromOuterFunction(Res, HasGenericParams), /// Error E0403: the name is already used for a type or const parameter in this generic /// parameter list. - NameAlreadyUsedInParameterList(Name, Span), + NameAlreadyUsedInParameterList(Symbol, Span), /// Error E0407: method is not a member of trait. - MethodNotMemberOfTrait(Name, &'a str), + MethodNotMemberOfTrait(Symbol, &'a str), /// Error E0437: type is not a member of trait. - TypeNotMemberOfTrait(Name, &'a str), + TypeNotMemberOfTrait(Symbol, &'a str), /// Error E0438: const is not a member of trait. - ConstNotMemberOfTrait(Name, &'a str), + ConstNotMemberOfTrait(Symbol, &'a str), /// Error E0408: variable `{}` is not bound in all patterns. VariableNotBoundInPattern(&'a BindingError), /// Error E0409: variable `{}` is bound in inconsistent ways within the same match arm. - VariableBoundWithDifferentMode(Name, Span), + VariableBoundWithDifferentMode(Symbol, Span), /// Error E0415: identifier is bound more than once in this parameter list. IdentifierBoundMoreThanOnceInParameterList(&'a str), /// Error E0416: identifier is bound more than once in the same pattern. IdentifierBoundMoreThanOnceInSamePattern(&'a str), /// Error E0426: use of undeclared label. - UndeclaredLabel(&'a str, Option), + UndeclaredLabel(&'a str, Option), /// Error E0429: `self` imports are only allowed within a `{ }` list. SelfImportsOnlyAllowedWithin, /// Error E0430: `self` import can only appear once in the list. @@ -206,7 +206,7 @@ enum ResolutionError<'a> { /// Error E0435: attempt to use a non-constant value in a constant. AttemptToUseNonConstantValueInConstant, /// Error E0530: `X` bindings cannot shadow `Y`s. - BindingShadowsSomethingUnacceptable(&'a str, Name, &'a NameBinding<'a>), + BindingShadowsSomethingUnacceptable(&'a str, Symbol, &'a NameBinding<'a>), /// Error E0128: type parameters with a default cannot use forward-declared identifiers. ForwardDeclaredTyParam, // FIXME(const_generics:defaults) /// Error E0735: type parameters with a default cannot use `Self` @@ -406,12 +406,12 @@ enum ModuleKind { /// * A normal module ‒ either `mod from_file;` or `mod from_block { }`. /// * A trait or an enum (it implicitly contains associated types, methods and variant /// constructors). - Def(DefKind, DefId, Name), + Def(DefKind, DefId, Symbol), } impl ModuleKind { /// Get name of the module. - pub fn name(&self) -> Option { + pub fn name(&self) -> Option { match self { ModuleKind::Block(..) => None, ModuleKind::Def(.., name) => Some(*name), @@ -786,7 +786,7 @@ impl<'a> NameBinding<'a> { /// All other types are defined somewhere and possibly imported, but the primitive ones need /// special handling, since they have no place of origin. struct PrimitiveTypeTable { - primitive_types: FxHashMap, + primitive_types: FxHashMap, } impl PrimitiveTypeTable { @@ -838,7 +838,7 @@ pub struct Resolver<'a> { /// Names of fields of an item `DefId` accessible with dot syntax. /// Used for hints during error reporting. - field_names: FxHashMap>>, + field_names: FxHashMap>>, /// All imports known to succeed or fail. determined_imports: Vec<&'a Import<'a>>, @@ -913,11 +913,11 @@ pub struct Resolver<'a> { crate_loader: CrateLoader<'a>, macro_names: FxHashSet, - builtin_macros: FxHashMap, + builtin_macros: FxHashMap, registered_attrs: FxHashSet, registered_tools: FxHashSet, - macro_use_prelude: FxHashMap>, - all_macros: FxHashMap, + macro_use_prelude: FxHashMap>, + all_macros: FxHashMap, macro_map: FxHashMap>, dummy_ext_bang: Lrc, dummy_ext_derive: Lrc, @@ -947,7 +947,7 @@ pub struct Resolver<'a> { helper_attrs: FxHashMap>, /// Avoid duplicated errors for "name already defined". - name_already_seen: FxHashMap, + name_already_seen: FxHashMap, potentially_unused_imports: Vec<&'a Import<'a>>, @@ -956,7 +956,7 @@ pub struct Resolver<'a> { struct_constructors: DefIdMap<(Res, ty::Visibility)>, /// Features enabled for this crate. - active_features: FxHashSet, + active_features: FxHashSet, /// Stores enum visibilities to properly build a reduced graph /// when visiting the correspondent variants. @@ -1044,8 +1044,8 @@ impl rustc_ast_lowering::Resolver for Resolver<'_> { fn resolve_str_path( &mut self, span: Span, - crate_root: Option, - components: &[Name], + crate_root: Option, + components: &[Symbol], ns: Namespace, ) -> (ast::Path, Res) { let root = if crate_root.is_some() { kw::PathRoot } else { kw::Crate }; @@ -2678,7 +2678,7 @@ impl<'a> Resolver<'a> { fn add_suggestion_for_rename_of_use( &self, err: &mut DiagnosticBuilder<'_>, - name: Name, + name: Symbol, import: &Import<'_>, binding_span: Span, ) { @@ -2914,12 +2914,12 @@ impl<'a> Resolver<'a> { } // For rustdoc. - pub fn all_macros(&self) -> &FxHashMap { + pub fn all_macros(&self) -> &FxHashMap { &self.all_macros } } -fn names_to_string(names: &[Name]) -> String { +fn names_to_string(names: &[Symbol]) -> String { let mut result = String::new(); for (i, name) in names.iter().filter(|name| **name != kw::PathRoot).enumerate() { if i > 0 { @@ -2941,14 +2941,14 @@ fn path_names_to_string(path: &Path) -> String { fn module_to_string(module: Module<'_>) -> Option { let mut names = Vec::new(); - fn collect_mod(names: &mut Vec, module: Module<'_>) { + fn collect_mod(names: &mut Vec, module: Module<'_>) { if let ModuleKind::Def(.., name) = module.kind { if let Some(parent) = module.parent { names.push(name); collect_mod(names, parent); } } else { - names.push(Name::intern("")); + names.push(Symbol::intern("")); collect_mod(names, module.parent.unwrap()); } } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index aa78ac609457f..1b6268dc8cbcf 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -6,7 +6,7 @@ use crate::Namespace::*; use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy}; use crate::{CrateLint, ParentScope, ResolutionError, Resolver, Scope, ScopeSet, Weak}; use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding}; -use rustc_ast::ast::{self, Ident, NodeId}; +use rustc_ast::ast::{self, NodeId}; use rustc_ast_pretty::pprust; use rustc_attr::{self as attr, StabilityLevel}; use rustc_data_structures::fx::FxHashSet; @@ -23,7 +23,7 @@ use rustc_session::lint::builtin::UNUSED_MACROS; use rustc_session::Session; use rustc_span::edition::Edition; use rustc_span::hygiene::{self, ExpnData, ExpnId, ExpnKind}; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_data_structures::sync::Lrc; @@ -165,7 +165,7 @@ impl<'a> base::Resolver for Resolver<'a> { parent_scope.module.unexpanded_invocations.borrow_mut().remove(&expansion); } - fn register_builtin_macro(&mut self, ident: ast::Ident, ext: SyntaxExtension) { + fn register_builtin_macro(&mut self, ident: Ident, ext: SyntaxExtension) { if self.builtin_macros.insert(ident.name, ext).is_some() { self.session .span_err(ident.span, &format!("built-in macro `{}` was already defined", ident)); diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index ccce72fb0ac24..534fe172bef9c 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -26,6 +26,7 @@ use rustc_middle::span_bug; use rustc_middle::ty::{self, DefIdTree, TyCtxt}; use rustc_session::config::Input; use rustc_span::source_map::{respan, DUMMY_SP}; +use rustc_span::symbol::Ident; use rustc_span::*; use std::env; @@ -264,7 +265,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { sig: &'l ast::FnSig, body: Option<&'l ast::Block>, id: ast::NodeId, - ident: ast::Ident, + ident: Ident, generics: &'l ast::Generics, vis: ast::Visibility, span: Span, @@ -419,7 +420,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { fn process_assoc_const( &mut self, id: ast::NodeId, - ident: ast::Ident, + ident: Ident, typ: &'l ast::Ty, expr: Option<&'l ast::Expr>, parent_id: DefId, diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 8456a0304fec6..8ae6853210f18 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -24,6 +24,7 @@ use rustc_middle::{bug, span_bug}; use rustc_session::config::{CrateType, Input, OutputType}; use rustc_session::output::{filename_for_metadata, out_filename}; use rustc_span::source_map::Spanned; +use rustc_span::symbol::Ident; use rustc_span::*; use std::cell::Cell; @@ -405,7 +406,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { // FIXME would be nice to take a MethodItem here, but the ast provides both // trait and impl flavours, so the caller must do the disassembly. - pub fn get_method_data(&self, id: ast::NodeId, ident: ast::Ident, span: Span) -> Option { + pub fn get_method_data(&self, id: ast::NodeId, ident: Ident, span: Span) -> Option { // The qualname for a method is the trait name or name of the struct in an impl in // which the method is declared in, followed by the method's name. let (qualname, parent_scope, decl_id, docs, attributes) = match self @@ -914,7 +915,7 @@ fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String { // variables (idents) from patterns. struct PathCollector<'l> { collected_paths: Vec<(NodeId, &'l ast::Path)>, - collected_idents: Vec<(NodeId, ast::Ident, ast::Mutability)>, + collected_idents: Vec<(NodeId, Ident, ast::Mutability)>, } impl<'l> PathCollector<'l> { diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index a2b973cda9112..bda9ff93b02ef 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -32,6 +32,7 @@ use rls_data::{SigElement, Signature}; use rustc_ast::ast::{self, Extern, NodeId}; use rustc_ast_pretty::pprust; use rustc_hir::def::{DefKind, Res}; +use rustc_span::symbol::{Ident, Symbol}; pub fn item_signature(item: &ast::Item, scx: &SaveContext<'_, '_>) -> Option { if !scx.config.signatures { @@ -69,7 +70,7 @@ pub fn variant_signature(variant: &ast::Variant, scx: &SaveContext<'_, '_>) -> O pub fn method_signature( id: NodeId, - ident: ast::Ident, + ident: Ident, generics: &ast::Generics, m: &ast::FnSig, scx: &SaveContext<'_, '_>, @@ -82,7 +83,7 @@ pub fn method_signature( pub fn assoc_const_signature( id: NodeId, - ident: ast::Name, + ident: Symbol, ty: &ast::Ty, default: Option<&ast::Expr>, scx: &SaveContext<'_, '_>, @@ -95,7 +96,7 @@ pub fn assoc_const_signature( pub fn assoc_type_signature( id: NodeId, - ident: ast::Ident, + ident: Ident, bounds: Option<&ast::GenericBounds>, default: Option<&ast::Ty>, scx: &SaveContext<'_, '_>, @@ -803,7 +804,7 @@ fn name_and_generics( offset: usize, generics: &ast::Generics, id: NodeId, - name: ast::Ident, + name: Ident, scx: &SaveContext<'_, '_>, ) -> Result { let name = name.to_string(); @@ -821,7 +822,7 @@ fn name_and_generics( fn make_assoc_type_signature( id: NodeId, - ident: ast::Ident, + ident: Ident, bounds: Option<&ast::GenericBounds>, default: Option<&ast::Ty>, scx: &SaveContext<'_, '_>, @@ -853,7 +854,7 @@ fn make_assoc_type_signature( fn make_assoc_const_signature( id: NodeId, - ident: ast::Name, + ident: Symbol, ty: &ast::Ty, default: Option<&ast::Expr>, scx: &SaveContext<'_, '_>, @@ -884,7 +885,7 @@ fn make_assoc_const_signature( fn make_method_signature( id: NodeId, - ident: ast::Ident, + ident: Ident, generics: &ast::Generics, m: &ast::FnSig, scx: &SaveContext<'_, '_>, diff --git a/src/librustc_trait_selection/traits/project.rs b/src/librustc_trait_selection/traits/project.rs index bf0e1ed7b89c3..47df82690e07d 100644 --- a/src/librustc_trait_selection/traits/project.rs +++ b/src/librustc_trait_selection/traits/project.rs @@ -17,14 +17,13 @@ use super::{VtableClosureData, VtableFnPointerData, VtableGeneratorData, VtableI use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime}; use crate::traits::error_reporting::InferCtxtExt; -use rustc_ast::ast::Ident; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::ErrorReported; use rustc_hir::def_id::DefId; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder}; use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, WithConstness}; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident}; use rustc_span::DUMMY_SP; pub use rustc_middle::traits::Reveal; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index cd6cd94b14356..6529d784ad452 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -8,7 +8,6 @@ use crate::collect::PlaceholderHirTyCollector; use crate::middle::resolve_lifetime as rl; use crate::require_c_abi_if_c_variadic; -use rustc_ast::ast; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::ErrorReported; @@ -27,7 +26,7 @@ use rustc_middle::ty::{GenericParamDef, GenericParamDefKind}; use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, LATE_BOUND_LIFETIME_ARGUMENTS}; use rustc_session::parse::feature_err; use rustc_session::Session; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use rustc_target::spec::abi; use rustc_trait_selection::traits; @@ -114,7 +113,7 @@ pub enum SizedByDefault { } struct ConvertedBinding<'a, 'tcx> { - item_name: ast::Ident, + item_name: Ident, kind: ConvertedBindingKind<'a, 'tcx>, span: Span, } @@ -1183,11 +1182,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ) } - fn trait_defines_associated_type_named( - &self, - trait_def_id: DefId, - assoc_name: ast::Ident, - ) -> bool { + fn trait_defines_associated_type_named(&self, trait_def_id: DefId, assoc_name: Ident) -> bool { self.tcx() .associated_items(trait_def_id) .find_by_name_and_kind(self.tcx(), assoc_name, ty::AssocKind::Type, trait_def_id) @@ -1938,7 +1933,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { span: Span, type_str: &str, trait_str: &str, - name: ast::Name, + name: Symbol, ) { let mut err = struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type"); if let (Some(_), Ok(snippet)) = ( @@ -1969,7 +1964,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { fn find_bound_for_assoc_item( &self, ty_param_def_id: LocalDefId, - assoc_name: ast::Ident, + assoc_name: Ident, span: Span, ) -> Result, ErrorReported> { let tcx = self.tcx(); @@ -2006,7 +2001,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { &self, all_candidates: impl Fn() -> I, ty_param_name: impl Fn() -> String, - assoc_name: ast::Ident, + assoc_name: Ident, span: Span, is_equality: impl Fn() -> Option, ) -> Result, ErrorReported> @@ -2124,7 +2119,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { &self, all_candidates: impl Fn() -> I, ty_param_name: &str, - assoc_name: ast::Ident, + assoc_name: Ident, span: Span, ) where I: Iterator>, diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index 2bb00553232ad..ae6c1738da77d 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -1,7 +1,6 @@ use super::method::MethodCallee; use super::{FnCtxt, Needs, PlaceOp}; -use rustc_ast::ast::Ident; use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_infer::infer::{InferCtxt, InferOk}; @@ -9,6 +8,7 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref}; use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt, WithConstness}; use rustc_middle::ty::{ToPredicate, TypeFoldable}; use rustc_session::DiagnosticMessageId; +use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use rustc_trait_selection::traits::{self, TraitEngine}; diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 0d254412203aa..52ddacc1c4b1a 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -3,7 +3,6 @@ use super::method::MethodCallee; use super::{Expectation, FnCtxt, Needs, TupleArgumentsFlag}; use crate::type_error_struct; -use rustc_ast::ast::Ident; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def::Res; @@ -15,6 +14,7 @@ use rustc_middle::ty::adjustment::{ }; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_target::spec::abi; diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 92ddfbff824cd..71e1b32aeaa90 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -37,7 +37,7 @@ use rustc_middle::ty::TypeFoldable; use rustc_middle::ty::{AdtKind, Visibility}; use rustc_span::hygiene::DesugaringKind; use rustc_span::source_map::Span; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_trait_selection::traits::{self, ObligationCauseCode}; use std::fmt::Display; @@ -1411,7 +1411,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { find_best_match_for_name(names, field, None) } - fn available_field_names(&self, variant: &'tcx ty::VariantDef) -> Vec { + fn available_field_names(&self, variant: &'tcx ty::VariantDef) -> Vec { variant .fields .iter() @@ -1426,7 +1426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .collect() } - fn name_series_display(&self, names: Vec) -> String { + fn name_series_display(&self, names: Vec) -> String { // dynamic limit, to never omit just one field let limit = if names.len() == 6 { 6 } else { 5 }; let mut display = @@ -1443,7 +1443,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, needs: Needs, base: &'tcx hir::Expr<'tcx>, - field: ast::Ident, + field: Ident, ) -> Ty<'tcx> { let expr_t = self.check_expr_with_needs(base, needs); let expr_t = self.structurally_resolved_type(base.span, expr_t); @@ -1522,7 +1522,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn ban_nonexisting_field( &self, - field: ast::Ident, + field: Ident, base: &'tcx hir::Expr<'tcx>, expr: &'tcx hir::Expr<'tcx>, expr_t: Ty<'tcx>, @@ -1560,7 +1560,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &hir::Expr<'_>, expr_t: Ty<'tcx>, - field: ast::Ident, + field: Ident, base_did: DefId, ) { let struct_path = self.tcx().def_path_str(base_did); @@ -1589,7 +1589,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } - fn ban_take_value_of_method(&self, expr: &hir::Expr<'_>, expr_t: Ty<'tcx>, field: ast::Ident) { + fn ban_take_value_of_method(&self, expr: &hir::Expr<'_>, expr_t: Ty<'tcx>, field: Ident) { let mut err = type_error_struct!( self.tcx().sess, field.span, @@ -1636,7 +1636,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, err: &mut DiagnosticBuilder<'_>, def: &'tcx ty::AdtDef, - field: ast::Ident, + field: Ident, ) { if let Some(suggested_field_name) = Self::suggest_field_name(def.non_enum_variant(), &field.as_str(), vec![]) @@ -1665,7 +1665,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err: &mut DiagnosticBuilder<'_>, expr: &hir::Expr<'_>, base: &hir::Expr<'_>, - field: ast::Ident, + field: Ident, len: &ty::Const<'tcx>, ) { if let (Some(len), Ok(user_index)) = @@ -1689,7 +1689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err: &mut DiagnosticBuilder<'_>, expr: &hir::Expr<'_>, base: &hir::Expr<'_>, - field: ast::Ident, + field: Ident, ) { if let Ok(base) = self.tcx.sess.source_map().span_to_snippet(base.span) { let msg = format!("`{}` is a raw pointer; try dereferencing it", base); diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index ae2061a2e3f3c..a254aecf07bab 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -11,7 +11,6 @@ pub use self::CandidateSource::*; pub use self::MethodError::*; use crate::check::FnCtxt; -use rustc_ast::ast; use rustc_data_structures::sync::Lrc; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir as hir; @@ -22,6 +21,7 @@ use rustc_middle::ty::subst::Subst; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; use rustc_middle::ty::GenericParamDefKind; use rustc_middle::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TypeFoldable, WithConstness}; +use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_trait_selection::traits; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; @@ -104,7 +104,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Determines whether the type `self_ty` supports a method name `method_name` or not. pub fn method_exists( &self, - method_name: ast::Ident, + method_name: Ident, self_ty: Ty<'tcx>, call_expr_id: hir::HirId, allow_private: bool, @@ -133,7 +133,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, err: &mut DiagnosticBuilder<'a>, msg: &str, - method_name: ast::Ident, + method_name: Ident, self_ty: Ty<'tcx>, call_expr: &hir::Expr<'_>, ) { @@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn lookup_probe( &self, span: Span, - method_name: ast::Ident, + method_name: Ident, self_ty: Ty<'tcx>, call_expr: &'tcx hir::Expr<'tcx>, scope: ProbeScope, @@ -290,7 +290,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn lookup_method_in_trait( &self, span: Span, - m_name: ast::Ident, + m_name: Ident, trait_def_id: DefId, self_ty: Ty<'tcx>, opt_input_types: Option<&[Ty<'tcx>]>, @@ -414,7 +414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn resolve_ufcs( &self, span: Span, - method_name: ast::Ident, + method_name: Ident, self_ty: Ty<'tcx>, expr_id: hir::HirId, ) -> Result<(DefKind, DefId), MethodError<'tcx>> { @@ -478,7 +478,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn associated_item( &self, def_id: DefId, - item_name: ast::Ident, + item_name: Ident, ns: Namespace, ) -> Option { self.tcx diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 03e32c21a54ac..7f1d77e5b97d8 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -28,7 +28,7 @@ use rustc_middle::ty::{ }; use rustc_session::config::nightly_options; use rustc_session::lint; -use rustc_span::{symbol::Symbol, Span, DUMMY_SP}; +use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy; use rustc_trait_selection::traits::query::method_autoderef::{ @@ -55,7 +55,7 @@ struct ProbeContext<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, span: Span, mode: Mode, - method_name: Option, + method_name: Option, return_type: Option>, /// This is the OriginalQueryValues for the steps queries @@ -268,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, span: Span, mode: Mode, - item_name: ast::Ident, + item_name: Ident, is_suggestion: IsSuggestion, self_ty: Ty<'tcx>, scope_expr_id: hir::HirId, @@ -295,7 +295,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &'a self, span: Span, mode: Mode, - method_name: Option, + method_name: Option, return_type: Option>, is_suggestion: IsSuggestion, self_ty: Ty<'tcx>, @@ -518,7 +518,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, span: Span, mode: Mode, - method_name: Option, + method_name: Option, return_type: Option>, orig_steps_var_values: OriginalQueryValues<'tcx>, steps: Lrc>>, @@ -978,7 +978,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { Ok(()) } - fn candidate_method_names(&self) -> Vec { + fn candidate_method_names(&self) -> Vec { let mut set = FxHashSet::default(); let mut names: Vec<_> = self .inherent_candidates diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 857cc972559e4..cf26c94418e2d 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -2,7 +2,6 @@ //! found or is otherwise invalid. use crate::check::FnCtxt; -use rustc_ast::ast; use rustc_ast::util::lev_distance; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; @@ -18,7 +17,7 @@ use rustc_middle::ty::print::with_crate_prefix; use rustc_middle::ty::{ self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness, }; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, Ident}; use rustc_span::{source_map, FileName, Span}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use rustc_trait_selection::traits::Obligation; @@ -72,7 +71,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, span: Span, rcvr_ty: Ty<'tcx>, - item_name: ast::Ident, + item_name: Ident, source: SelfSource<'b>, error: MethodError<'tcx>, args: Option<&'tcx [hir::Expr<'tcx>]>, @@ -923,7 +922,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err: &mut DiagnosticBuilder<'_>, span: Span, rcvr_ty: Ty<'tcx>, - item_name: ast::Ident, + item_name: Ident, source: SelfSource<'b>, valid_out_of_scope_traits: Vec, unsatisfied_predicates: &[(ty::Predicate<'tcx>, Option>)], @@ -1378,7 +1377,7 @@ impl intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> { } fn print_disambiguation_help( - item_name: ast::Ident, + item_name: Ident, args: Option<&'tcx [hir::Expr<'tcx>]>, err: &mut DiagnosticBuilder<'_>, trait_name: String, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index bff1ca2433a83..956e09ec52b4a 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3718,14 +3718,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None } - fn resolve_place_op(&self, op: PlaceOp, is_mut: bool) -> (Option, ast::Ident) { + fn resolve_place_op(&self, op: PlaceOp, is_mut: bool) -> (Option, Ident) { let (tr, name) = match (op, is_mut) { (PlaceOp::Deref, false) => (self.tcx.lang_items().deref_trait(), sym::deref), (PlaceOp::Deref, true) => (self.tcx.lang_items().deref_mut_trait(), sym::deref_mut), (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_dummy_span(name)) + (tr, Ident::with_dummy_span(name)) } fn try_overloaded_place_op( @@ -4824,19 +4824,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise. - fn get_parent_fn_decl( - &self, - blk_id: hir::HirId, - ) -> Option<(&'tcx hir::FnDecl<'tcx>, ast::Ident)> { + fn get_parent_fn_decl(&self, blk_id: hir::HirId) -> Option<(&'tcx hir::FnDecl<'tcx>, Ident)> { let parent = self.tcx.hir().get(self.tcx.hir().get_parent_item(blk_id)); self.get_node_fn_decl(parent).map(|(fn_decl, ident, _)| (fn_decl, ident)) } /// Given a function `Node`, return its `FnDecl` if it exists, or `None` otherwise. - fn get_node_fn_decl( - &self, - node: Node<'tcx>, - ) -> Option<(&'tcx hir::FnDecl<'tcx>, ast::Ident, bool)> { + fn get_node_fn_decl(&self, node: Node<'tcx>) -> Option<(&'tcx hir::FnDecl<'tcx>, Ident, bool)> { match node { Node::Item(&hir::Item { ident, kind: hir::ItemKind::Fn(ref sig, ..), .. }) => { // This is less than ideal, it will not suggest a return type span on any diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index e6cbc8ab7230c..00ff2af82e303 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -2,7 +2,6 @@ use super::method::MethodCallee; use super::{FnCtxt, Needs}; -use rustc_ast::ast::Ident; use rustc_errors::{self, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; @@ -11,6 +10,7 @@ use rustc_middle::ty::adjustment::{ }; use rustc_middle::ty::TyKind::{Adt, Array, Char, FnDef, Never, Ref, Str, Tuple, Uint}; use rustc_middle::ty::{self, suggest_constraining_type_param, Ty, TyCtxt, TypeFoldable}; +use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_trait_selection::infer::InferCtxtExt; diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 8e109efbcb576..8a10427260eee 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -13,6 +13,7 @@ use rustc_middle::ty::subst::GenericArg; use rustc_middle::ty::{self, BindingMode, Ty, TypeFoldable}; use rustc_span::hygiene::DesugaringKind; use rustc_span::source_map::{Span, Spanned}; +use rustc_span::symbol::Ident; use rustc_trait_selection::traits::{ObligationCause, Pattern}; use std::cmp; @@ -1133,7 +1134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } - fn error_field_already_bound(&self, span: Span, ident: ast::Ident, other_field: Span) { + fn error_field_already_bound(&self, span: Span, ident: Ident, other_field: Span) { struct_span_err!( self.tcx.sess, span, @@ -1149,8 +1150,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn error_inexistent_fields( &self, kind_name: &str, - inexistent_fields: &[ast::Ident], - unmentioned_fields: &mut Vec, + inexistent_fields: &[Ident], + unmentioned_fields: &mut Vec, variant: &ty::VariantDef, ) { let tcx = self.tcx; @@ -1225,7 +1226,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn error_unmentioned_fields( &self, span: Span, - unmentioned_fields: &[ast::Ident], + unmentioned_fields: &[Ident], variant: &ty::VariantDef, ) { let field_names = if unmentioned_fields.len() == 1 { diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 55802c140bc9f..6aa8242193d5f 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -35,7 +35,6 @@ use super::FnCtxt; use crate::expr_use_visitor as euv; use crate::mem_categorization as mc; use crate::mem_categorization::PlaceBase; -use rustc_ast::ast; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -43,7 +42,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_infer::infer::UpvarRegion; use rustc_middle::ty::{self, Ty, TyCtxt, UpvarSubsts}; -use rustc_span::Span; +use rustc_span::{Span, Symbol}; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn closure_analyze(&self, body: &'tcx hir::Body<'tcx>) { @@ -261,7 +260,7 @@ struct InferBorrowKind<'a, 'tcx> { // If we modified `current_closure_kind`, this field contains a `Some()` with the // variable access that caused us to do so. - current_origin: Option<(Span, ast::Name)>, + current_origin: Option<(Span, Symbol)>, // For each upvar that we access, we track the minimal kind of // access we need (ref, ref mut, move, etc). @@ -415,7 +414,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> { closure_id: LocalDefId, new_kind: ty::ClosureKind, upvar_span: Span, - var_name: ast::Name, + var_name: Symbol, ) { debug!( "adjust_closure_kind(closure_id={:?}, new_kind={:?}, upvar_span={:?}, var_name={})", @@ -480,6 +479,6 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { } } -fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> ast::Name { +fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { tcx.hir().name(var_hir_id) } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index e82e40503e08b..b79ac50da8fa3 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -15,7 +15,7 @@ use rustc_middle::ty::{ self, AdtKind, GenericParamDefKind, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness, }; use rustc_session::parse::feature_err; -use rustc_span::symbol::sym; +use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use rustc_trait_selection::opaque_types::may_define_opaque_type; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; @@ -1226,7 +1226,7 @@ fn check_variances_for_type_defn<'tcx>( } } -fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: ast::Name) { +fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) { let mut err = error_392(tcx, span, param_name); let suggested_marker_id = tcx.lang_items().phantom_data(); @@ -1368,7 +1368,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } -fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: ast::Name) -> DiagnosticBuilder<'_> { +fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> { let mut err = struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name); err.span_label(span, "unused parameter"); diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index ce1538bfa49c3..dfe86aecbf727 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -1,4 +1,3 @@ -use rustc_ast::ast; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_hir as hir; @@ -6,7 +5,7 @@ use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE}; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_middle::ty::TyCtxt; use rustc_session::lint; -use rustc_span::Span; +use rustc_span::{Span, Symbol}; pub fn check_crate(tcx: TyCtxt<'_>) { let mut used_trait_imports = DefIdSet::default(); @@ -202,7 +201,7 @@ struct ExternCrateToLint { /// if `Some`, then this is renamed (`extern crate orig_name as /// crate_name`), and -- perhaps surprisingly -- this stores the /// *original* name (`item.name` will contain the new name) - orig_name: Option, + orig_name: Option, /// if `false`, the original name started with `_`, so we shouldn't lint /// about it going unused (but we should still emit idiom lints). diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 0fad328459890..854bd03b26486 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -19,7 +19,7 @@ use crate::check::intrinsic::intrinsic_operation_unsafety; use crate::constrained_generic_params as cgp; use crate::middle::resolve_lifetime as rl; use rustc_ast::ast; -use rustc_ast::ast::{Ident, MetaItemKind}; +use rustc_ast::ast::MetaItemKind; use rustc_attr::{list_contains_name, mark_used, InlineAttr, OptimizeAttr}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -42,7 +42,7 @@ use rustc_middle::ty::{self, AdtKind, Const, ToPolyTraitRef, Ty, TyCtxt}; use rustc_middle::ty::{ReprOptions, ToPredicate, WithConstness}; use rustc_session::lint; use rustc_session::parse::feature_err; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi; use rustc_trait_selection::traits::error_reporting::suggestions::NextTypeParamName; @@ -813,7 +813,7 @@ fn convert_variant( adt_kind: ty::AdtKind, parent_did: LocalDefId, ) -> ty::VariantDef { - let mut seen_fields: FxHashMap = Default::default(); + let mut seen_fields: FxHashMap = Default::default(); let hir_id = tcx.hir().as_local_hir_id(variant_did.unwrap_or(parent_did)); let fields = def .fields() diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index cd098936ed6a5..4bf3649dcc2e2 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -12,6 +12,7 @@ use rustc_metadata::creader::LoadedMacro; use rustc_middle::ty; use rustc_mir::const_eval::is_min_const_fn; use rustc_span::hygiene::MacroKind; +use rustc_span::symbol::Symbol; use rustc_span::Span; use crate::clean::{self, GetDefId, ToSource, TypeKind}; @@ -37,7 +38,7 @@ type Attrs<'hir> = rustc_middle::ty::Attributes<'hir>; pub fn try_inline( cx: &DocContext<'_>, res: Res, - name: ast::Name, + name: Symbol, attrs: Option>, visited: &mut FxHashSet, ) -> Option> { @@ -515,7 +516,7 @@ fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static } } -fn build_macro(cx: &DocContext<'_>, did: DefId, name: ast::Name) -> clean::ItemEnum { +fn build_macro(cx: &DocContext<'_>, did: DefId, name: Symbol) -> clean::ItemEnum { let imported_from = cx.tcx.original_crate_name(did.krate); match cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())) { LoadedMacro::MacroDef(def, _) => { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 55c32e917f25c..8cd9ab41aa40a 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -9,7 +9,7 @@ mod simplify; pub mod types; pub mod utils; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; @@ -24,7 +24,7 @@ use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt}; use rustc_mir::const_eval::is_min_const_fn; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{self, Pos}; use rustc_typeck::hir_ty_to_ty; @@ -921,7 +921,7 @@ impl Clean for doctree::Function<'_> { } } -impl<'a> Clean for (&'a [hir::Ty<'a>], &'a [ast::Ident]) { +impl<'a> Clean for (&'a [hir::Ty<'a>], &'a [Ident]) { fn clean(&self, cx: &DocContext<'_>) -> Arguments { Arguments { values: self @@ -2006,7 +2006,7 @@ impl Clean for Ident { } } -impl Clean for ast::Name { +impl Clean for Symbol { #[inline] fn clean(&self, _: &DocContext<'_>) -> String { self.to_string() diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 0a682857b1825..8bf811877a6a8 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -8,7 +8,7 @@ use std::rc::Rc; use std::sync::Arc; use std::{slice, vec}; -use rustc_ast::ast::{self, AttrStyle, Ident}; +use rustc_ast::ast::{self, AttrStyle}; use rustc_ast::attr; use rustc_ast::util::comments::strip_doc_comment_decoration; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -21,7 +21,7 @@ use rustc_index::vec::IndexVec; use rustc_middle::middle::stability; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::DUMMY_SP; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{self, FileName}; use rustc_target::abi::VariantIdx; use rustc_target::spec::abi::Abi; diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 41b8e66d26592..5b13832742770 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -3,15 +3,14 @@ pub use self::StructType::*; use rustc_ast::ast; -use rustc_ast::ast::Name; use rustc_span::hygiene::MacroKind; -use rustc_span::{self, Span}; +use rustc_span::{self, Span, Symbol}; use rustc_hir as hir; use rustc_hir::def_id::CrateNum; pub struct Module<'hir> { - pub name: Option, + pub name: Option, pub attrs: &'hir [ast::Attribute], pub where_outer: Span, pub where_inner: Span, @@ -39,7 +38,7 @@ pub struct Module<'hir> { impl Module<'hir> { pub fn new( - name: Option, + name: Option, attrs: &'hir [ast::Attribute], vis: &'hir hir::Visibility<'hir>, ) -> Module<'hir> { @@ -86,7 +85,7 @@ pub struct Struct<'hir> { pub vis: &'hir hir::Visibility<'hir>, pub id: hir::HirId, pub struct_type: StructType, - pub name: Name, + pub name: Symbol, pub generics: &'hir hir::Generics<'hir>, pub attrs: &'hir [ast::Attribute], pub fields: &'hir [hir::StructField<'hir>], @@ -97,7 +96,7 @@ pub struct Union<'hir> { pub vis: &'hir hir::Visibility<'hir>, pub id: hir::HirId, pub struct_type: StructType, - pub name: Name, + pub name: Symbol, pub generics: &'hir hir::Generics<'hir>, pub attrs: &'hir [ast::Attribute], pub fields: &'hir [hir::StructField<'hir>], @@ -111,11 +110,11 @@ pub struct Enum<'hir> { pub attrs: &'hir [ast::Attribute], pub id: hir::HirId, pub whence: Span, - pub name: Name, + pub name: Symbol, } pub struct Variant<'hir> { - pub name: Name, + pub name: Symbol, pub id: hir::HirId, pub attrs: &'hir [ast::Attribute], pub def: &'hir hir::VariantData<'hir>, @@ -126,7 +125,7 @@ pub struct Function<'hir> { pub decl: &'hir hir::FnDecl<'hir>, pub attrs: &'hir [ast::Attribute], pub id: hir::HirId, - pub name: Name, + pub name: Symbol, pub vis: &'hir hir::Visibility<'hir>, pub header: hir::FnHeader, pub whence: Span, @@ -137,7 +136,7 @@ pub struct Function<'hir> { pub struct Typedef<'hir> { pub ty: &'hir hir::Ty<'hir>, pub gen: &'hir hir::Generics<'hir>, - pub name: Name, + pub name: Symbol, pub id: hir::HirId, pub attrs: &'hir [ast::Attribute], pub whence: Span, @@ -146,7 +145,7 @@ pub struct Typedef<'hir> { pub struct OpaqueTy<'hir> { pub opaque_ty: &'hir hir::OpaqueTy<'hir>, - pub name: Name, + pub name: Symbol, pub id: hir::HirId, pub attrs: &'hir [ast::Attribute], pub whence: Span, @@ -158,7 +157,7 @@ pub struct Static<'hir> { pub type_: &'hir hir::Ty<'hir>, pub mutability: hir::Mutability, pub expr: hir::BodyId, - pub name: Name, + pub name: Symbol, pub attrs: &'hir [ast::Attribute], pub vis: &'hir hir::Visibility<'hir>, pub id: hir::HirId, @@ -168,7 +167,7 @@ pub struct Static<'hir> { pub struct Constant<'hir> { pub type_: &'hir hir::Ty<'hir>, pub expr: hir::BodyId, - pub name: Name, + pub name: Symbol, pub attrs: &'hir [ast::Attribute], pub vis: &'hir hir::Visibility<'hir>, pub id: hir::HirId, @@ -178,7 +177,7 @@ pub struct Constant<'hir> { pub struct Trait<'hir> { pub is_auto: hir::IsAuto, pub unsafety: hir::Unsafety, - pub name: Name, + pub name: Symbol, pub items: Vec<&'hir hir::TraitItem<'hir>>, pub generics: &'hir hir::Generics<'hir>, pub bounds: &'hir [hir::GenericBound<'hir>], @@ -189,7 +188,7 @@ pub struct Trait<'hir> { } pub struct TraitAlias<'hir> { - pub name: Name, + pub name: Symbol, pub generics: &'hir hir::Generics<'hir>, pub bounds: &'hir [hir::GenericBound<'hir>], pub attrs: &'hir [ast::Attribute], @@ -217,7 +216,7 @@ pub struct Impl<'hir> { pub struct ForeignItem<'hir> { pub vis: &'hir hir::Visibility<'hir>, pub id: hir::HirId, - pub name: Name, + pub name: Symbol, pub kind: &'hir hir::ForeignItemKind<'hir>, pub attrs: &'hir [ast::Attribute], pub whence: Span, @@ -226,17 +225,17 @@ pub struct ForeignItem<'hir> { // For Macro we store the DefId instead of the NodeId, since we also create // these imported macro_rules (which only have a DUMMY_NODE_ID). pub struct Macro<'hir> { - pub name: Name, + pub name: Symbol, pub hid: hir::HirId, pub def_id: hir::def_id::DefId, pub attrs: &'hir [ast::Attribute], pub whence: Span, pub matchers: Vec, - pub imported_from: Option, + pub imported_from: Option, } pub struct ExternCrate<'hir> { - pub name: Name, + pub name: Symbol, pub cnum: CrateNum, pub path: Option, pub vis: &'hir hir::Visibility<'hir>, @@ -245,7 +244,7 @@ pub struct ExternCrate<'hir> { } pub struct Import<'hir> { - pub name: Name, + pub name: Symbol, pub id: hir::HirId, pub vis: &'hir hir::Visibility<'hir>, pub attrs: &'hir [ast::Attribute], @@ -255,10 +254,10 @@ pub struct Import<'hir> { } pub struct ProcMacro<'hir> { - pub name: Name, + pub name: Symbol, pub id: hir::HirId, pub kind: MacroKind, - pub helpers: Vec, + pub helpers: Vec, pub attrs: &'hir [ast::Attribute], pub whence: Span, } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 43b641c7fe61a..fbdb538cd874c 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1,4 +1,4 @@ -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_errors::Applicability; use rustc_expand::base::SyntaxExtensionKind; use rustc_feature::UnstableFeatures; @@ -12,7 +12,7 @@ use rustc_hir::def_id::DefId; use rustc_middle::ty; use rustc_resolve::ParentScope; use rustc_session::lint; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::DUMMY_SP; use std::ops::Range; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index acfcfe9d0159b..d2a950027cf87 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -11,7 +11,7 @@ use rustc_middle::middle::privacy::AccessLevel; use rustc_middle::ty::TyCtxt; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{self, Span}; use std::mem; @@ -85,7 +85,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { fn visit_variant_data( &mut self, item: &'tcx hir::Item, - name: ast::Name, + name: Symbol, sd: &'tcx hir::VariantData, generics: &'tcx hir::Generics, ) -> Struct<'tcx> { @@ -106,7 +106,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { fn visit_union_data( &mut self, item: &'tcx hir::Item, - name: ast::Name, + name: Symbol, sd: &'tcx hir::VariantData, generics: &'tcx hir::Generics, ) -> Union<'tcx> { @@ -127,7 +127,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { fn visit_enum_def( &mut self, it: &'tcx hir::Item, - name: ast::Name, + name: Symbol, def: &'tcx hir::EnumDef, generics: &'tcx hir::Generics, ) -> Enum<'tcx> { @@ -157,7 +157,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { &mut self, om: &mut Module<'tcx>, item: &'tcx hir::Item, - name: ast::Name, + name: Symbol, decl: &'tcx hir::FnDecl, header: hir::FnHeader, generics: &'tcx hir::Generics, @@ -234,7 +234,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { vis: &'tcx hir::Visibility, id: hir::HirId, m: &'tcx hir::Mod<'tcx>, - name: Option, + name: Option, ) -> Module<'tcx> { let mut om = Module::new(name, attrs, vis); om.where_outer = span; @@ -264,7 +264,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { &mut self, id: hir::HirId, res: Res, - renamed: Option, + renamed: Option, glob: bool, om: &mut Module<'tcx>, please_inline: bool, @@ -375,12 +375,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { ret } - fn visit_item( - &mut self, - item: &'tcx hir::Item, - renamed: Option, - om: &mut Module<'tcx>, - ) { + fn visit_item(&mut self, item: &'tcx hir::Item, renamed: Option, om: &mut Module<'tcx>) { debug!("visiting item {:?}", item); let ident = renamed.unwrap_or(item.ident); @@ -593,7 +588,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { fn visit_foreign_item( &mut self, item: &'tcx hir::ForeignItem, - renamed: Option, + renamed: Option, om: &mut Module<'tcx>, ) { // If inlining we only want to include public functions. @@ -612,11 +607,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { } // Convert each `exported_macro` into a doc item. - fn visit_local_macro( - &self, - def: &'tcx hir::MacroDef, - renamed: Option, - ) -> Macro<'tcx> { + fn visit_local_macro(&self, def: &'tcx hir::MacroDef, renamed: Option) -> Macro<'tcx> { debug!("visit_local_macro: {}", def.ident); let tts = def.ast.body.inner_tokens().trees().collect::>(); // Extract the spans of all matchers. They represent the "interface" of the macro. From 7bf21d48387fbcdca39ef9acd3abc601ee8bd7c9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 8 May 2020 13:57:01 +0200 Subject: [PATCH 2/3] Fix clippy. --- src/tools/clippy/clippy_lints/src/bytecount.rs | 7 ++++--- .../clippy/clippy_lints/src/inline_fn_without_body.rs | 5 +++-- src/tools/clippy/clippy_lints/src/len_zero.rs | 6 +++--- src/tools/clippy/clippy_lints/src/lib.rs | 2 +- src/tools/clippy/clippy_lints/src/map_clone.rs | 4 ++-- .../clippy/clippy_lints/src/non_expressive_names.rs | 4 ++-- .../clippy_lints/src/unsafe_removed_from_name.rs | 4 ++-- src/tools/clippy/clippy_lints/src/utils/hir_utils.rs | 4 ++-- .../clippy/clippy_lints/src/utils/internal_lints.rs | 10 +++++----- src/tools/clippy/clippy_lints/src/utils/mod.rs | 2 +- src/tools/clippy/clippy_lints/src/utils/ptr.rs | 9 ++++----- src/tools/clippy/clippy_lints/src/utils/usage.rs | 5 ++--- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/bytecount.rs b/src/tools/clippy/clippy_lints/src/bytecount.rs index 91d3e47d7870c..278d043732f49 100644 --- a/src/tools/clippy/clippy_lints/src/bytecount.rs +++ b/src/tools/clippy/clippy_lints/src/bytecount.rs @@ -3,12 +3,13 @@ use crate::utils::{ span_lint_and_sugg, walk_ptrs_ty, }; use if_chain::if_chain; -use rustc_ast::ast::{Name, UintTy}; +use rustc_ast::ast::{UintTy}; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::Symbol; declare_clippy_lint! { /// **What it does:** Checks for naive byte counts @@ -95,11 +96,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount { } } -fn check_arg(name: Name, arg: Name, needle: &Expr<'_>) -> bool { +fn check_arg(name: Symbol, arg: Symbol, needle: &Expr<'_>) -> bool { name == arg && !contains_name(name, needle) } -fn get_path_name(expr: &Expr<'_>) -> Option { +fn get_path_name(expr: &Expr<'_>) -> Option { match expr.kind { ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => { get_path_name(e) diff --git a/src/tools/clippy/clippy_lints/src/inline_fn_without_body.rs b/src/tools/clippy/clippy_lints/src/inline_fn_without_body.rs index 1ebfb3c8162a1..475610dda4753 100644 --- a/src/tools/clippy/clippy_lints/src/inline_fn_without_body.rs +++ b/src/tools/clippy/clippy_lints/src/inline_fn_without_body.rs @@ -2,11 +2,12 @@ use crate::utils::span_lint_and_then; use crate::utils::sugg::DiagnosticBuilderExt; -use rustc_ast::ast::{Attribute, Name}; +use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::{TraitFn, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::Symbol; declare_clippy_lint! { /// **What it does:** Checks for `#[inline]` on trait methods without bodies @@ -38,7 +39,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody { } } -fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) { +fn check_attrs(cx: &LateContext<'_, '_>, name: Symbol, attrs: &[Attribute]) { for attr in attrs { if !attr.check_name(sym!(inline)) { continue; diff --git a/src/tools/clippy/clippy_lints/src/len_zero.rs b/src/tools/clippy/clippy_lints/src/len_zero.rs index 1d86ca9696f2b..2ec0b5a8d6fb4 100644 --- a/src/tools/clippy/clippy_lints/src/len_zero.rs +++ b/src/tools/clippy/clippy_lints/src/len_zero.rs @@ -1,5 +1,5 @@ use crate::utils::{get_item_name, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty}; -use rustc_ast::ast::{LitKind, Name}; +use rustc_ast::ast::LitKind; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; @@ -7,7 +7,7 @@ use rustc_hir::{AssocItemKind, BinOpKind, Expr, ExprKind, ImplItemRef, Item, Ite use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_span::source_map::{Span, Spanned}; +use rustc_span::source_map::{Span, Spanned, Symbol}; declare_clippy_lint! { /// **What it does:** Checks for getting the length of something via `.len()` @@ -226,7 +226,7 @@ fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr<'_>, lit: &Expr fn check_len( cx: &LateContext<'_, '_>, span: Span, - method_name: Name, + method_name: Symbol, args: &[Expr<'_>], lit: &LitKind, op: &str, diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index c995be5edc25c..1f135cba6e4ee 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -333,7 +333,7 @@ mod zero_div_zero; pub use crate::utils::conf::Conf; mod reexport { - pub use rustc_ast::ast::Name; + pub use rustc_span::Symbol as Name; } /// Register all pre expansion lints diff --git a/src/tools/clippy/clippy_lints/src/map_clone.rs b/src/tools/clippy/clippy_lints/src/map_clone.rs index 0b346393ac389..0163b3f8dbc8e 100644 --- a/src/tools/clippy/clippy_lints/src/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/map_clone.rs @@ -3,14 +3,14 @@ use crate::utils::{ is_copy, is_type_diagnostic_item, match_trait_method, remove_blocks, snippet_with_applicability, span_lint_and_sugg, }; use if_chain::if_chain; -use rustc_ast::ast::Ident; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::Mutability; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_span::source_map::Span; +use rustc_span::Span; +use rustc_span::symbol::Ident; declare_clippy_lint! { /// **What it does:** Checks for usage of `iterator.map(|x| x.clone())` and suggests diff --git a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs index 45809b3598661..2b51b73207585 100644 --- a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs +++ b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs @@ -1,13 +1,13 @@ use crate::utils::{span_lint, span_lint_and_then}; use rustc_ast::ast::{ - Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Ident, Item, ItemKind, Local, MacCall, Pat, PatKind, + Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, MacCall, Pat, PatKind, }; use rustc_ast::attr; use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::Span; -use rustc_span::symbol::SymbolStr; +use rustc_span::symbol::{Ident, SymbolStr}; use std::cmp::Ordering; declare_clippy_lint! { diff --git a/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs b/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs index 86c469a4dccf7..735800e7e7416 100644 --- a/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs +++ b/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs @@ -1,9 +1,9 @@ use crate::utils::span_lint; -use rustc_ast::ast::{Ident, Item, ItemKind, UseTree, UseTreeKind}; +use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; -use rustc_span::symbol::SymbolStr; +use rustc_span::symbol::{Ident, SymbolStr}; declare_clippy_lint! { /// **What it does:** Checks for imports that remove "unsafe" from an item's diff --git a/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs b/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs index 02b721fd378ff..bd7da57c665dc 100644 --- a/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs @@ -1,6 +1,5 @@ use crate::consts::{constant_context, constant_simple}; use crate::utils::differing_macro_contexts; -use rustc_ast::ast::Name; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir::{ BinOpKind, Block, BlockCheckMode, BodyId, BorrowKind, CaptureBy, Expr, ExprKind, Field, FnRetTy, GenericArg, @@ -10,6 +9,7 @@ use rustc_hir::{ use rustc_lint::LateContext; use rustc_middle::ich::StableHashingContextProvider; use rustc_middle::ty::TypeckTables; +use rustc_span::Symbol; use std::hash::Hash; /// Type used to check whether two ast are the same. This is different from the @@ -544,7 +544,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { } } - pub fn hash_name(&mut self, n: Name) { + pub fn hash_name(&mut self, n: Symbol) { n.as_str().hash(&mut self.s); } diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs index 5bf9acdc5f7ce..8e1b047f6f80a 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs @@ -4,7 +4,7 @@ use crate::utils::{ span_lint_and_help, span_lint_and_sugg, walk_ptrs_ty, }; use if_chain::if_chain; -use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, Name, NodeId}; +use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, NodeId}; use rustc_ast::visit::FnKind; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::Applicability; @@ -17,7 +17,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::{Span, Spanned}; -use rustc_span::symbol::SymbolStr; +use rustc_span::symbol::{Symbol, SymbolStr}; use std::borrow::{Borrow, Cow}; @@ -245,8 +245,8 @@ impl EarlyLintPass for ClippyLintsInternal { #[derive(Clone, Debug, Default)] pub struct LintWithoutLintPass { - declared_lints: FxHashMap, - registered_lints: FxHashSet, + declared_lints: FxHashMap, + registered_lints: FxHashSet, } impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS]); @@ -357,7 +357,7 @@ fn is_lint_ref_type<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &Ty<'_>) -> bool { } struct LintCollector<'a, 'tcx> { - output: &'a mut FxHashSet, + output: &'a mut FxHashSet, cx: &'a LateContext<'a, 'tcx>, } diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 04b4b42376193..2fd080e9ef0f8 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -1069,7 +1069,7 @@ pub fn is_allowed(cx: &LateContext<'_, '_>, lint: &'static Lint, id: HirId) -> b cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow } -pub fn get_arg_name(pat: &Pat<'_>) -> Option { +pub fn get_arg_name(pat: &Pat<'_>) -> Option { match pat.kind { PatKind::Binding(.., ident, None) => Some(ident.name), PatKind::Ref(ref subpat, _) => get_arg_name(subpat), diff --git a/src/tools/clippy/clippy_lints/src/utils/ptr.rs b/src/tools/clippy/clippy_lints/src/utils/ptr.rs index 240bf2449cb5e..fb6bd5e815859 100644 --- a/src/tools/clippy/clippy_lints/src/utils/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ptr.rs @@ -1,10 +1,9 @@ use crate::utils::{get_pat_name, match_var, snippet}; -use rustc_ast::ast::Name; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{Body, BodyId, Expr, ExprKind, Param}; use rustc_lint::LateContext; use rustc_middle::hir::map::Map; -use rustc_span::source_map::Span; +use rustc_span::{Span, Symbol}; use std::borrow::Cow; pub fn get_spans( @@ -25,7 +24,7 @@ pub fn get_spans( fn extract_clone_suggestions<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, - name: Name, + name: Symbol, replace: &[(&'static str, &'static str)], body: &'tcx Body<'_>, ) -> Option)>> { @@ -46,7 +45,7 @@ fn extract_clone_suggestions<'a, 'tcx>( struct PtrCloneVisitor<'a, 'tcx> { cx: &'a LateContext<'a, 'tcx>, - name: Name, + name: Symbol, replace: &'a [(&'static str, &'static str)], spans: Vec<(Span, Cow<'static, str>)>, abort: bool, @@ -83,6 +82,6 @@ impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> { } } -fn get_binding_name(arg: &Param<'_>) -> Option { +fn get_binding_name(arg: &Param<'_>) -> Option { get_pat_name(&arg.pat) } diff --git a/src/tools/clippy/clippy_lints/src/utils/usage.rs b/src/tools/clippy/clippy_lints/src/utils/usage.rs index c14da6aacea04..e85356779877c 100644 --- a/src/tools/clippy/clippy_lints/src/utils/usage.rs +++ b/src/tools/clippy/clippy_lints/src/utils/usage.rs @@ -1,5 +1,4 @@ use crate::utils::match_var; -use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::Res; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; @@ -8,7 +7,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::LateContext; use rustc_middle::hir::map::Map; use rustc_middle::ty; -use rustc_span::symbol::Ident; +use rustc_span::symbol::{Ident, Symbol}; use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase}; /// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined. @@ -78,7 +77,7 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate { } pub struct UsedVisitor { - pub var: ast::Name, // var to look for + pub var: Symbol, // var to look for pub used: bool, // has the var been used otherwise? } From 32507d691058d3efae2ad3fce9e7ff14a387f856 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 25 Apr 2020 21:13:56 +0200 Subject: [PATCH 3/3] Fix tests --- src/librustc_ast_pretty/pprust/tests.rs | 7 ++++--- src/librustc_expand/mut_visit/tests.rs | 5 +++-- src/librustc_expand/parse/tests.rs | 8 ++++---- src/librustc_expand/tokenstream/tests.rs | 5 ++--- src/librustdoc/clean/cfg/tests.rs | 2 +- src/test/ui-fulldeps/pprust-expr-roundtrip.rs | 1 + 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/librustc_ast_pretty/pprust/tests.rs b/src/librustc_ast_pretty/pprust/tests.rs index 455f2e3da3680..f51439f89ffbe 100644 --- a/src/librustc_ast_pretty/pprust/tests.rs +++ b/src/librustc_ast_pretty/pprust/tests.rs @@ -4,11 +4,12 @@ use rustc_ast::ast; use rustc_ast::with_default_globals; use rustc_span; use rustc_span::source_map::respan; +use rustc_span::symbol::Ident; fn fun_to_string( decl: &ast::FnDecl, header: ast::FnHeader, - name: ast::Ident, + name: Ident, generics: &ast::Generics, ) -> String { to_string(|s| { @@ -26,7 +27,7 @@ fn variant_to_string(var: &ast::Variant) -> String { #[test] fn test_fun_to_string() { with_default_globals(|| { - let abba_ident = ast::Ident::from_str("abba"); + let abba_ident = Ident::from_str("abba"); let decl = ast::FnDecl { inputs: Vec::new(), output: ast::FnRetTy::Default(rustc_span::DUMMY_SP) }; @@ -41,7 +42,7 @@ fn test_fun_to_string() { #[test] fn test_variant_to_string() { with_default_globals(|| { - let ident = ast::Ident::from_str("principal_skinner"); + let ident = Ident::from_str("principal_skinner"); let var = ast::Variant { ident, diff --git a/src/librustc_expand/mut_visit/tests.rs b/src/librustc_expand/mut_visit/tests.rs index 70fb8975d4d08..48da1a3ccc420 100644 --- a/src/librustc_expand/mut_visit/tests.rs +++ b/src/librustc_expand/mut_visit/tests.rs @@ -1,9 +1,10 @@ use crate::tests::{matches_codepattern, string_to_crate}; -use rustc_ast::ast::{self, Ident}; +use rustc_ast::ast; use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::with_default_globals; use rustc_ast_pretty::pprust; +use rustc_span::symbol::Ident; // This version doesn't care about getting comments or doc-strings in. fn fake_print_crate(s: &mut pprust::State<'_>, krate: &ast::Crate) { @@ -14,7 +15,7 @@ fn fake_print_crate(s: &mut pprust::State<'_>, krate: &ast::Crate) { struct ToZzIdentMutVisitor; impl MutVisitor for ToZzIdentMutVisitor { - fn visit_ident(&mut self, ident: &mut ast::Ident) { + fn visit_ident(&mut self, ident: &mut Ident) { *ident = Ident::from_str("zz"); } fn visit_mac(&mut self, mac: &mut ast::MacCall) { diff --git a/src/librustc_expand/parse/tests.rs b/src/librustc_expand/parse/tests.rs index 4add896258fa8..437f6e62d7d33 100644 --- a/src/librustc_expand/parse/tests.rs +++ b/src/librustc_expand/parse/tests.rs @@ -1,6 +1,6 @@ use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_parse}; -use rustc_ast::ast::{self, Name, PatKind}; +use rustc_ast::ast::{self, PatKind}; use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; @@ -100,12 +100,12 @@ fn string_to_tts_1() { let expected = TokenStream::new(vec![ TokenTree::token(token::Ident(kw::Fn, false), sp(0, 2)).into(), - TokenTree::token(token::Ident(Name::intern("a"), false), sp(3, 4)).into(), + TokenTree::token(token::Ident(Symbol::intern("a"), false), sp(3, 4)).into(), TokenTree::Delimited( DelimSpan::from_pair(sp(5, 6), sp(13, 14)), token::DelimToken::Paren, TokenStream::new(vec![ - TokenTree::token(token::Ident(Name::intern("b"), false), sp(6, 7)).into(), + TokenTree::token(token::Ident(Symbol::intern("b"), false), sp(6, 7)).into(), TokenTree::token(token::Colon, sp(8, 9)).into(), TokenTree::token(token::Ident(sym::i32, false), sp(10, 13)).into(), ]) @@ -116,7 +116,7 @@ fn string_to_tts_1() { DelimSpan::from_pair(sp(15, 16), sp(20, 21)), token::DelimToken::Brace, TokenStream::new(vec![ - TokenTree::token(token::Ident(Name::intern("b"), false), sp(17, 18)).into(), + TokenTree::token(token::Ident(Symbol::intern("b"), false), sp(17, 18)).into(), TokenTree::token(token::Semi, sp(18, 19)).into(), ]) .into(), diff --git a/src/librustc_expand/tokenstream/tests.rs b/src/librustc_expand/tokenstream/tests.rs index db329f22d146f..caaa08df49981 100644 --- a/src/librustc_expand/tokenstream/tests.rs +++ b/src/librustc_expand/tokenstream/tests.rs @@ -1,10 +1,9 @@ use crate::tests::string_to_stream; -use rustc_ast::ast::Name; use rustc_ast::token; use rustc_ast::tokenstream::{TokenStream, TokenStreamBuilder, TokenTree}; use rustc_ast::with_default_globals; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, Span, Symbol}; use smallvec::smallvec; fn string_to_ts(string: &str) -> TokenStream { @@ -87,7 +86,7 @@ fn test_is_empty() { with_default_globals(|| { let test0: TokenStream = Vec::::new().into_iter().collect(); let test1: TokenStream = - TokenTree::token(token::Ident(Name::intern("a"), false), sp(0, 1)).into(); + TokenTree::token(token::Ident(Symbol::intern("a"), false), sp(0, 1)).into(); let test2 = string_to_ts("foo(bar::baz)"); assert_eq!(test0.is_empty(), true); diff --git a/src/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs index 3b26742e716f8..716263393ba8d 100644 --- a/src/librustdoc/clean/cfg/tests.rs +++ b/src/librustdoc/clean/cfg/tests.rs @@ -3,7 +3,7 @@ use super::*; use rustc_ast::ast::*; use rustc_ast::attr; use rustc_ast::with_default_globals; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::DUMMY_SP; fn word_cfg(s: &str) -> Cfg { diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 365ae301c0fb5..a3d31d257748d 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -32,6 +32,7 @@ use rustc_parse::new_parser_from_source_str; use rustc_session::parse::ParseSess; use rustc_span::source_map::{Spanned, DUMMY_SP, FileName}; use rustc_span::source_map::FilePathMapping; +use rustc_span::symbol::Ident; use rustc_ast::ast::*; use rustc_ast::mut_visit::{self, MutVisitor, visit_clobber}; use rustc_ast::ptr::P;