Auto merge of #72041 - RalfJung:rollup-xivrvy2, r=RalfJung

Rollup of 5 pull requests

Successful merges:

 - #69406 (upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir)
 - #71185 (Move tests from `test/run-fail` to UI)
 - #71234 (rustllvm: Use .init_array rather than .ctors)
 - #71508 (Simplify the `tcx.alloc_map` API)
 - #71555 (Remove ast::{Ident, Name} reexports.)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-05-09 17:31:08 +00:00
commit bad3bf622b
380 changed files with 4111 additions and 874 deletions

View file

@ -429,6 +429,77 @@ dependencies = [
"rustc-std-workspace-core",
]
[[package]]
name = "chalk-derive"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d4620afad4d4d9e63f915cfa10c930b7a3c9c3ca5cd88dd771ff8e5bf04ea10"
dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
]
[[package]]
name = "chalk-engine"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ca6e5cef10197789da0b4ec310eda58da4c55530613b2323432642a97372735"
dependencies = [
"chalk-macros",
"rustc-hash",
]
[[package]]
name = "chalk-ir"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d45df5fb6328527f976e8a32c9e1c9970084d937ebe93d0d34f5bbf4231cb956"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-macros",
]
[[package]]
name = "chalk-macros"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e4782d108e420a1fcf94d8a919cf248db33c5071678e87d9c2d4f20ed1feb32"
dependencies = [
"lazy_static 1.4.0",
]
[[package]]
name = "chalk-rust-ir"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0ec96dbe0ab5fdbadfca4179ec2e1d35f0439c3b53a74988b1aec239c63eb08"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"chalk-macros",
]
[[package]]
name = "chalk-solve"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfb99fa9530f0e101475fb60adc931f51bdea05b4642a48928b814d7f0141a6b"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"chalk-macros",
"chalk-rust-ir",
"ena 0.13.1",
"itertools 0.9.0",
"petgraph",
"rustc-hash",
]
[[package]]
name = "chrono"
version = "0.4.6"
@ -1102,6 +1173,12 @@ dependencies = [
"winapi 0.3.8",
]
[[package]]
name = "fixedbitset"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
[[package]]
name = "flate2"
version = "1.0.12"
@ -2328,6 +2405,12 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "ordermap"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
[[package]]
name = "ordslice"
version = "0.3.0"
@ -2496,6 +2579,16 @@ dependencies = [
"sha-1",
]
[[package]]
name = "petgraph"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
dependencies = [
"fixedbitset",
"ordermap",
]
[[package]]
name = "phf"
version = "0.7.24"
@ -4002,6 +4095,7 @@ dependencies = [
"arena",
"bitflags",
"byteorder",
"chalk-ir",
"log",
"measureme",
"polonius-engine",
@ -4132,7 +4226,6 @@ name = "rustc_privacy"
version = "0.0.0"
dependencies = [
"log",
"rustc_ast",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -4301,10 +4394,14 @@ dependencies = [
name = "rustc_traits"
version = "0.0.0"
dependencies = [
"chalk-ir",
"chalk-rust-ir",
"chalk-solve",
"log",
"rustc_ast",
"rustc_data_structures",
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_middle",
"rustc_span",

View file

@ -359,7 +359,6 @@ impl<'a> Builder<'a> {
test::Tidy,
test::Ui,
test::CompileFail,
test::RunFail,
test::RunPassValgrind,
test::MirOpt,
test::Codegen,
@ -370,7 +369,6 @@ impl<'a> Builder<'a> {
test::UiFullDeps,
test::Rustdoc,
test::Pretty,
test::RunFailPretty,
test::RunPassValgrindPretty,
test::Crate,
test::CrateLibrustc,

View file

@ -48,7 +48,6 @@ check:
$(Q)$(BOOTSTRAP) test $(BOOTSTRAP_ARGS)
check-aux:
$(Q)$(BOOTSTRAP) test \
src/test/run-fail/pretty \
src/test/run-pass-valgrind/pretty \
$(AUX_ARGS) \
$(BOOTSTRAP_ARGS)

View file

@ -898,8 +898,6 @@ default_test!(CompileFail {
suite: "compile-fail"
});
default_test!(RunFail { path: "src/test/run-fail", mode: "run-fail", suite: "run-fail" });
default_test!(RunPassValgrind {
path: "src/test/run-pass-valgrind",
mode: "run-pass-valgrind",
@ -929,13 +927,6 @@ host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-ful
host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" });
host_test!(Pretty { path: "src/test/pretty", mode: "pretty", suite: "pretty" });
test!(RunFailPretty {
path: "src/test/run-fail/pretty",
mode: "pretty",
suite: "run-fail",
default: false,
host: true
});
test!(RunPassValgrindPretty {
path: "src/test/run-pass-valgrind/pretty",
mode: "pretty",

View file

@ -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<Name>),
ExternCrate(Option<Symbol>),
/// A use declaration item (`use`).
///
/// E.g., `use foo;`, `use foo::bar;` or `use foo::bar as FooBar;`.

View file

@ -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 {

View file

@ -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};

View file

@ -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<Nonterminal>),
// 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<ast::Ident> {
pub fn lifetime(&self) -> Option<Ident> {
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<ast::Pat>),
NtExpr(P<ast::Expr>),
NtTy(P<ast::Ty>),
NtIdent(ast::Ident, /* is_raw */ bool),
NtLifetime(ast::Ident),
NtIdent(Ident, /* is_raw */ bool),
NtLifetime(Ident),
NtLiteral(P<ast::Expr>),
/// Stuff inside brackets for attributes
NtMeta(P<ast::AttrItem>),

View file

@ -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) {

View file

@ -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<Expr>]) -> &'hir [hir::Expr<'hir>] {

View file

@ -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;

View file

@ -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};

View file

@ -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> {

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -2,6 +2,7 @@
use rustc_ast::ast::*;
use rustc_ast::visit::*;
use rustc_span::symbol::Ident;
use rustc_span::Span;
pub struct NodeCounter {

View file

@ -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<Target = pp::Printer> + std::ops::DerefMut {
fn comments(&mut self) -> &mut Option<Comments<'a>>;
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<T, F>(
@ -671,7 +671,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
&mut self,
header: Option<MacHeader<'_>>,
has_bang: bool,
ident: Option<ast::Ident>,
ident: Option<Ident>,
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<ast::Mutability>,
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<ast::Ident>,
name: Option<Ident>,
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<ast::Ident>,
name: Option<Ident>,
generic_params: &[ast::GenericParam],
) {
self.ibox(INDENT_UNIT);

View file

@ -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,

View file

@ -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>(

View file

@ -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 {

View file

@ -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<Self>;
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 {

View file

@ -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(

View file

@ -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<ast::Expr> {
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<Expr> {
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]);

View file

@ -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<ast::Expr> {
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<Expr> {
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);

View file

@ -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(

View file

@ -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<MethodDef<'a>>,
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<P<ast::Ty>> {
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<P<ast::Ty>>,
}
@ -620,7 +620,7 @@ impl<'a> TraitDef<'a> {
.peekable();
if ty_params.peek().is_some() {
let ty_param_names: Vec<ast::Name> =
let ty_param_names: Vec<Symbol> =
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::<Vec<String>>();
let self_arg_idents =
self_arg_names.iter().map(|name| cx.ident_of(name, sp)).collect::<Vec<ast::Ident>>();
self_arg_names.iter().map(|name| cx.ident_of(name, sp)).collect::<Vec<Ident>>();
// 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::<Vec<ast::Ident>>();
.collect::<Vec<Ident>>();
// 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<ast::Ident>,
field_paths: Vec<Ident>,
mutbl: ast::Mutability,
use_temporaries: bool,
) -> Vec<P<ast::Pat>> {
@ -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,

View file

@ -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

View file

@ -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,

View file

@ -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;

View file

@ -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<ast::Ident> {
fn rtpath(ecx: &ExtCtxt<'_>, s: &str) -> Vec<Ident> {
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<ast::Expr> {
sp = ecx.with_def_site_ctxt(sp);
let arg = ecx.expr_ident(sp, arg);

View file

@ -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(

View file

@ -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<dyn base::MacResult + 'cx> {
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)),

View file

@ -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;

View file

@ -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<ast::Name>,
attrs: Vec<Symbol>,
}
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,
);

View file

@ -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),

View file

@ -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))

View file

@ -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};

View file

@ -165,6 +165,13 @@ pub fn target_machine_factory(
let asm_comments = sess.asm_comments();
let relax_elf_relocations = sess.target.target.options.relax_elf_relocations;
let use_init_array = !sess
.opts
.debugging_opts
.use_ctors_section
.unwrap_or(sess.target.target.options.use_ctors_section);
Arc::new(move || {
let tm = unsafe {
llvm::LLVMRustCreateTargetMachine(
@ -184,6 +191,7 @@ pub fn target_machine_factory(
asm_comments,
emit_stack_size_section,
relax_elf_relocations,
use_init_array,
)
};

View file

@ -244,9 +244,8 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
}
Scalar::Ptr(ptr) => {
let alloc_kind = self.tcx.alloc_map.lock().get(ptr.alloc_id);
let base_addr = match alloc_kind {
Some(GlobalAlloc::Memory(alloc)) => {
let base_addr = match self.tcx.global_alloc(ptr.alloc_id) {
GlobalAlloc::Memory(alloc) => {
let init = const_alloc_to_llvm(self, alloc);
let value = match alloc.mutability {
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
@ -257,12 +256,11 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
value
}
Some(GlobalAlloc::Function(fn_instance)) => self.get_fn_addr(fn_instance),
Some(GlobalAlloc::Static(def_id)) => {
GlobalAlloc::Function(fn_instance) => self.get_fn_addr(fn_instance),
GlobalAlloc::Static(def_id) => {
assert!(self.tcx.is_static(def_id));
self.get_static(def_id)
}
None => bug!("missing allocation {:?}", ptr.alloc_id),
};
let llval = unsafe {
llvm::LLVMConstInBoundsGEP(

View file

@ -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<mir::GeneratorSavedLocal, Option<ast::Name>>) {
) -> (&'tcx GeneratorLayout<'tcx>, IndexVec<mir::GeneratorSavedLocal, Option<Symbol>>) {
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<mir::GeneratorSavedLocal, Option<ast::Name>>,
generator_saved_local_names: &'a IndexVec<mir::GeneratorSavedLocal, Option<Symbol>>,
variant_index: VariantIdx,
},
}

View file

@ -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,

View file

@ -1956,6 +1956,7 @@ extern "C" {
AsmComments: bool,
EmitStackSizeSection: bool,
RelaxELFRelocations: bool,
UseInitArray: bool,
) -> Option<&'static mut TargetMachine>;
pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
pub fn LLVMRustAddBuilderLibraryInfo(

View file

@ -92,7 +92,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
_ => bug!("from_const: invalid ScalarPair layout: {:#?}", layout),
};
let a = Scalar::from(Pointer::new(
bx.tcx().alloc_map.lock().create_memory_alloc(data),
bx.tcx().create_memory_alloc(data),
Size::from_bytes(start),
));
let a_llval = bx.scalar_to_backend(

View file

@ -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<Self::DIScope>,
variable_name: Name,
variable_name: Symbol,
variable_type: Ty<'tcx>,
scope_metadata: Self::DIScope,
variable_kind: VariableKind,

View file

@ -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()))
}

View file

@ -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<Symbol>,
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<ast::Ident>,
pub mod_path: Vec<Ident>,
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<ast::Ident> {
pub fn std_path(&self, components: &[Symbol]) -> Vec<Ident> {
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)
}

View file

@ -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::Ident>) -> ast::Path {
pub fn path(&self, span: Span, strs: Vec<Ident>) -> 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::Ident>) -> ast::Path {
pub fn path_global(&self, span: Span, strs: Vec<Ident>) -> ast::Path {
self.path_all(span, true, strs, vec![])
}
pub fn path_all(
&self,
span: Span,
global: bool,
mut idents: Vec<ast::Ident>,
mut idents: Vec<Ident>,
args: Vec<ast::GenericArg>,
) -> 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<ast::Ty> {
pub fn ty_ident(&self, span: Span, ident: Ident) -> P<ast::Ty> {
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<ast::Attribute>,
bounds: ast::GenericBounds,
default: Option<P<ast::Ty>>,
@ -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<ast::Attribute>,
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::Expr>,
) -> ast::Stmt {
pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P<ast::Expr>) -> 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<ast::Expr> {
pub fn expr_ident(&self, span: Span, id: Ident) -> P<ast::Expr> {
self.expr_path(self.path_ident(span, id))
}
pub fn expr_self(&self, span: Span) -> P<ast::Expr> {
@ -251,18 +245,13 @@ impl<'a> ExtCtxt<'a> {
) -> P<ast::Expr> {
self.expr(span, ast::ExprKind::Call(expr, args))
}
pub fn expr_call_ident(
&self,
span: Span,
id: ast::Ident,
args: Vec<P<ast::Expr>>,
) -> P<ast::Expr> {
pub fn expr_call_ident(&self, span: Span, id: Ident, args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
self.expr(span, ast::ExprKind::Call(self.expr_ident(span, id), args))
}
pub fn expr_call_global(
&self,
sp: Span,
fn_path: Vec<ast::Ident>,
fn_path: Vec<Ident>,
args: Vec<P<ast::Expr>>,
) -> P<ast::Expr> {
let pathexpr = self.expr_path(self.path_global(sp, fn_path));
@ -272,7 +261,7 @@ impl<'a> ExtCtxt<'a> {
&self,
span: Span,
expr: P<ast::Expr>,
ident: ast::Ident,
ident: Ident,
mut args: Vec<P<ast::Expr>>,
) -> P<ast::Expr> {
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<ast::Field>,
) -> P<ast::Expr> {
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<ast::Expr>) -> P<ast::Pat> {
self.pat(span, PatKind::Lit(expr))
}
pub fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
pub fn pat_ident(&self, span: Span, ident: Ident) -> P<ast::Pat> {
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<ast::Pat> {
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<ast::Ident>, body: P<ast::Expr>) -> P<ast::Expr> {
pub fn lambda(&self, span: Span, ids: Vec<Ident>, body: P<ast::Expr>) -> P<ast::Expr> {
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<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
pub fn lambda1(&self, span: Span, body: P<ast::Expr>, ident: Ident) -> P<ast::Expr> {
self.lambda(span, vec![ident], body)
}
pub fn lambda_stmts_1(
&self,
span: Span,
stmts: Vec<ast::Stmt>,
ident: ast::Ident,
) -> P<ast::Expr> {
pub fn lambda_stmts_1(&self, span: Span, stmts: Vec<ast::Stmt>, ident: Ident) -> P<ast::Expr> {
self.lambda1(span, self.expr_block(self.block(span, stmts)), ident)
}
pub fn param(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Param {
pub fn param(&self, span: Span, ident: Ident, ty: P<ast::Ty>) -> 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))
}
}

View file

@ -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};

View file

@ -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<SequenceRepetition>),
/// 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 {

View file

@ -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 {

View file

@ -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<mbe::TokenTree>,
@ -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 {

View file

@ -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.

View file

@ -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<ast::Ident>,
relative: Option<Ident>,
},
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<Attribute>,
@ -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<Pat
// Public for rustfmt usage.
pub fn default_submod_path<'a>(
sess: &'a ParseSess,
id: ast::Ident,
id: Ident,
span: Span,
relative: Option<ast::Ident>,
relative: Option<Ident>,
dir_path: &Path,
) -> ModulePath<'a> {
// If we're in a foo.rs file instead of a mod.rs file,

View file

@ -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) {

View file

@ -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(),

View file

@ -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;

View file

@ -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<Self>)>
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))
}

View file

@ -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::<TokenTree>::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);

View file

@ -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;
@ -2443,7 +2443,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<Name>),
ExternCrate(Option<Symbol>),
/// `use foo::bar::*;` or `use foo::bar::baz as quux;`
///
@ -2611,7 +2611,7 @@ pub type TraitMap<ID = HirId> = NodeMap<Vec<TraitCandidate<ID>>>;
// Map from the NodeId of a glob import to a list of items which are actually
// imported.
pub type GlobMap = NodeMap<FxHashSet<Name>>;
pub type GlobMap = NodeMap<FxHashSet<Symbol>>;
#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum Node<'hir> {

View file

@ -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,

View file

@ -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<ast::Ident> {
pub fn simple_ident(&self) -> Option<Ident> {
match self.kind {
PatKind::Binding(
hir::BindingAnnotation::Unannotated | hir::BindingAnnotation::Mutable,

View file

@ -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<hir::BodyId>,
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<hir::GenericBounds<'_>>,
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<hir::BodyId>,
) {
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<ast::Name>,
name: Option<Symbol>,
generics: &hir::Generics<'_>,
vis: &hir::Visibility<'_>,
arg_names: &[ast::Ident],
arg_names: &[Ident],
body_id: Option<hir::BodyId>,
) {
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<ast::Name>,
name: Option<Symbol>,
generic_params: &[hir::GenericParam<'_>],
arg_names: &[ast::Ident],
arg_names: &[Ident],
) {
self.ibox(INDENT_UNIT);
if !generic_params.is_empty() {

View file

@ -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<ast::Name> {
fn argument(&self, attr: &ast::Attribute) -> Option<Symbol> {
let mut value = None;
for list_item in attr.meta_item_list().unwrap_or_default() {
match list_item.ident() {

View file

@ -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() {

View file

@ -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 {

View file

@ -353,8 +353,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
// `TyVar(vid)` is unresolved, track its universe index in the canonicalized
// result.
Err(mut ui) => {
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
}
self.canonicalize_ty_var(
CanonicalVarInfo {
kind: CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui)),
@ -439,8 +441,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
// `ConstVar(vid)` is unresolved, track its universe index in the
// canonicalized result
Err(mut ui) => {
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
}
return self.canonicalize_const_var(
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui) },
ct,

View file

@ -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.

View file

@ -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,

View file

@ -525,6 +525,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(always_encode_mir, true);
tracked!(asm_comments, true);
tracked!(binary_dep_depinfo, true);
tracked!(chalk, true);
tracked!(codegen_backend, Some("abc".to_string()));
tracked!(crate_attr, vec!["abc".to_string()]);
tracked!(debug_macros, true);
@ -570,6 +571,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
tracked!(treat_err_as_bug, Some(1));
tracked!(unleash_the_miri_inside_of_you, true);
tracked!(use_ctors_section, Some(true));
tracked!(verify_llvm_ir, true);
}

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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,

View file

@ -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);
}

View file

@ -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;

View file

@ -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() {

View file

@ -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);

View file

@ -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<ast::Name>)] {
fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Option<Symbol>)] {
// 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::<Vec<_>>()
}
fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<ast::Name>> {
fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<Symbol>> {
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,

View file

@ -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(

View file

@ -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<ast::Name>)]> {
fn encode_lib_features(&mut self) -> Lazy<[(Symbol, Option<Symbol>)]> {
let tcx = self.tcx;
let lib_features = tcx.lib_features();
self.lazy(lib_features.to_vec())

View file

@ -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<Svh>,
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)]

View file

@ -31,6 +31,7 @@ rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_ast = { path = "../librustc_ast" }
rustc_span = { path = "../librustc_span" }
byteorder = { version = "1.3" }
chalk-ir = "0.10.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "0.7.1"
rustc_session = { path = "../librustc_session" }

View file

@ -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<rustc_ast::ast::Name>,
[] name_set: rustc_data_structures::fx::FxHashSet<rustc_span::symbol::Symbol>,
[] hir_id_set: rustc_hir::HirIdSet,
// Interned types

View file

@ -51,6 +51,7 @@
use crate::mir;
use crate::mir::interpret::{GlobalId, LitToConstInput};
use crate::traits;
use crate::traits::query::{
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,

View file

@ -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<Id> = DefIdMap<Vec<Export<Id>>>;
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct Export<Id> {
/// The name of the target.
pub ident: ast::Ident,
pub ident: Ident,
/// The resolution of the target.
pub res: Res<Id>,
/// The span of the target.

View file

@ -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

View file

@ -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;
@ -452,7 +452,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
@ -824,7 +824,7 @@ impl<'hir> Map<'hir> {
}
}
pub fn opt_name(&self, id: HirId) -> Option<Name> {
pub fn opt_name(&self, id: HirId) -> Option<Symbol> {
Some(match self.get(id) {
Node::Item(i) => i.ident.name,
Node::ForeignItem(fi) => fi.ident.name,
@ -840,7 +840,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)),
@ -952,42 +952,42 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> {
}
trait Named {
fn name(&self) -> Name;
fn name(&self) -> Symbol;
}
impl<T: Named> Named for Spanned<T> {
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
}
}

View file

@ -136,8 +136,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
ty::tls::with_opt(|tcx| {
trace!("hashing {:?}", *self);
let tcx = tcx.expect("can't hash AllocIds during hir lowering");
let alloc_kind = tcx.alloc_map.lock().get(*self);
alloc_kind.hash_stable(hcx, hasher);
tcx.get_global_alloc(*self).hash_stable(hcx, hasher);
});
}
}

View file

@ -42,6 +42,7 @@
#![feature(or_patterns)]
#![feature(range_is_empty)]
#![feature(specialization)]
#![feature(track_caller)]
#![feature(trusted_len)]
#![feature(vec_remove_item)]
#![feature(stmt_expr_attributes)]

View file

@ -197,9 +197,7 @@ pub fn specialized_encode_alloc_id<'tcx, E: Encoder>(
tcx: TyCtxt<'tcx>,
alloc_id: AllocId,
) -> Result<(), E::Error> {
let alloc: GlobalAlloc<'tcx> =
tcx.alloc_map.lock().get(alloc_id).expect("no value for given alloc ID");
match alloc {
match tcx.global_alloc(alloc_id) {
GlobalAlloc::Memory(alloc) => {
trace!("encoding {:?} with {:#?}", alloc_id, alloc);
AllocDiscriminant::Alloc.encode(encoder)?;
@ -294,7 +292,7 @@ impl<'s> AllocDecodingSession<'s> {
AllocDiscriminant::Alloc => {
// If this is an allocation, we need to reserve an
// `AllocId` so we can decode cyclic graphs.
let alloc_id = decoder.tcx().alloc_map.lock().reserve();
let alloc_id = decoder.tcx().reserve_alloc_id();
*entry =
State::InProgress(TinyList::new_single(self.session_id), alloc_id);
Some(alloc_id)
@ -338,7 +336,7 @@ impl<'s> AllocDecodingSession<'s> {
// We already have a reserved `AllocId`.
let alloc_id = alloc_id.unwrap();
trace!("decoded alloc {:?}: {:#?}", alloc_id, alloc);
decoder.tcx().alloc_map.lock().set_alloc_id_same_memory(alloc_id, alloc);
decoder.tcx().set_alloc_id_same_memory(alloc_id, alloc);
Ok(alloc_id)
}
AllocDiscriminant::Fn => {
@ -346,7 +344,7 @@ impl<'s> AllocDecodingSession<'s> {
trace!("creating fn alloc ID");
let instance = ty::Instance::decode(decoder)?;
trace!("decoded fn alloc instance: {:?}", instance);
let alloc_id = decoder.tcx().alloc_map.lock().create_fn_alloc(instance);
let alloc_id = decoder.tcx().create_fn_alloc(instance);
Ok(alloc_id)
}
AllocDiscriminant::Static => {
@ -354,7 +352,7 @@ impl<'s> AllocDecodingSession<'s> {
trace!("creating extern static alloc ID");
let did = DefId::decode(decoder)?;
trace!("decoded static def-ID: {:?}", did);
let alloc_id = decoder.tcx().alloc_map.lock().create_static_alloc(did);
let alloc_id = decoder.tcx().create_static_alloc(did);
Ok(alloc_id)
}
}
@ -381,7 +379,29 @@ pub enum GlobalAlloc<'tcx> {
Memory(&'tcx Allocation),
}
pub struct AllocMap<'tcx> {
impl GlobalAlloc<'tcx> {
/// Panics if the `GlobalAlloc` does not refer to an `GlobalAlloc::Memory`
#[track_caller]
#[inline]
pub fn unwrap_memory(&self) -> &'tcx Allocation {
match *self {
GlobalAlloc::Memory(mem) => mem,
_ => bug!("expected memory, got {:?}", self),
}
}
/// Panics if the `GlobalAlloc` is not `GlobalAlloc::Function`
#[track_caller]
#[inline]
pub fn unwrap_fn(&self) -> Instance<'tcx> {
match *self {
GlobalAlloc::Function(instance) => instance,
_ => bug!("expected function, got {:?}", self),
}
}
}
crate struct AllocMap<'tcx> {
/// Maps `AllocId`s to their corresponding allocations.
alloc_map: FxHashMap<AllocId, GlobalAlloc<'tcx>>,
@ -397,16 +417,10 @@ pub struct AllocMap<'tcx> {
}
impl<'tcx> AllocMap<'tcx> {
pub fn new() -> Self {
crate fn new() -> Self {
AllocMap { alloc_map: Default::default(), dedup: Default::default(), next_id: AllocId(0) }
}
/// Obtains a new allocation ID that can be referenced but does not
/// yet have an allocation backing it.
///
/// Make sure to call `set_alloc_id_memory` or `set_alloc_id_same_memory` before returning such
/// an `AllocId` from a query.
pub fn reserve(&mut self) -> AllocId {
fn reserve(&mut self) -> AllocId {
let next = self.next_id;
self.next_id.0 = self.next_id.0.checked_add(1).expect(
"You overflowed a u64 by incrementing by 1... \
@ -415,34 +429,46 @@ impl<'tcx> AllocMap<'tcx> {
);
next
}
}
impl<'tcx> TyCtxt<'tcx> {
/// Obtains a new allocation ID that can be referenced but does not
/// yet have an allocation backing it.
///
/// Make sure to call `set_alloc_id_memory` or `set_alloc_id_same_memory` before returning such
/// an `AllocId` from a query.
pub fn reserve_alloc_id(&self) -> AllocId {
self.alloc_map.lock().reserve()
}
/// Reserves a new ID *if* this allocation has not been dedup-reserved before.
/// Should only be used for function pointers and statics, we don't want
/// to dedup IDs for "real" memory!
fn reserve_and_set_dedup(&mut self, alloc: GlobalAlloc<'tcx>) -> AllocId {
fn reserve_and_set_dedup(&self, alloc: GlobalAlloc<'tcx>) -> AllocId {
let mut alloc_map = self.alloc_map.lock();
match alloc {
GlobalAlloc::Function(..) | GlobalAlloc::Static(..) => {}
GlobalAlloc::Memory(..) => bug!("Trying to dedup-reserve memory with real data!"),
}
if let Some(&alloc_id) = self.dedup.get(&alloc) {
if let Some(&alloc_id) = alloc_map.dedup.get(&alloc) {
return alloc_id;
}
let id = self.reserve();
let id = alloc_map.reserve();
debug!("creating alloc {:?} with id {}", alloc, id);
self.alloc_map.insert(id, alloc.clone());
self.dedup.insert(alloc, id);
alloc_map.alloc_map.insert(id, alloc.clone());
alloc_map.dedup.insert(alloc, id);
id
}
/// Generates an `AllocId` for a static or return a cached one in case this function has been
/// called on the same static before.
pub fn create_static_alloc(&mut self, static_id: DefId) -> AllocId {
pub fn create_static_alloc(&self, static_id: DefId) -> AllocId {
self.reserve_and_set_dedup(GlobalAlloc::Static(static_id))
}
/// Generates an `AllocId` for a function. Depending on the function type,
/// this might get deduplicated or assigned a new ID each time.
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
pub fn create_fn_alloc(&self, instance: Instance<'tcx>) -> AllocId {
// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
// by the linker (we set the "unnamed_addr" attribute for LLVM) and functions can be
// duplicated across crates.
@ -456,8 +482,9 @@ impl<'tcx> AllocMap<'tcx> {
});
if is_generic {
// Get a fresh ID.
let id = self.reserve();
self.alloc_map.insert(id, GlobalAlloc::Function(instance));
let mut alloc_map = self.alloc_map.lock();
let id = alloc_map.reserve();
alloc_map.alloc_map.insert(id, GlobalAlloc::Function(instance));
id
} else {
// Deduplicate.
@ -470,8 +497,8 @@ impl<'tcx> AllocMap<'tcx> {
/// Statics with identical content will still point to the same `Allocation`, i.e.,
/// their data will be deduplicated through `Allocation` interning -- but they
/// are different places in memory and as such need different IDs.
pub fn create_memory_alloc(&mut self, mem: &'tcx Allocation) -> AllocId {
let id = self.reserve();
pub fn create_memory_alloc(&self, mem: &'tcx Allocation) -> AllocId {
let id = self.reserve_alloc_id();
self.set_alloc_id_memory(id, mem);
id
}
@ -482,38 +509,35 @@ impl<'tcx> AllocMap<'tcx> {
/// This function exists to allow const eval to detect the difference between evaluation-
/// local dangling pointers and allocations in constants/statics.
#[inline]
pub fn get(&self, id: AllocId) -> Option<GlobalAlloc<'tcx>> {
self.alloc_map.get(&id).cloned()
pub fn get_global_alloc(&self, id: AllocId) -> Option<GlobalAlloc<'tcx>> {
self.alloc_map.lock().alloc_map.get(&id).cloned()
}
/// Panics if the `AllocId` does not refer to an `Allocation`
pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation {
match self.get(id) {
Some(GlobalAlloc::Memory(mem)) => mem,
_ => bug!("expected allocation ID {} to point to memory", id),
}
}
/// Panics if the `AllocId` does not refer to a function
pub fn unwrap_fn(&self, id: AllocId) -> Instance<'tcx> {
match self.get(id) {
Some(GlobalAlloc::Function(instance)) => instance,
_ => bug!("expected allocation ID {} to point to a function", id),
#[inline]
#[track_caller]
/// Panics in case the `AllocId` is dangling. Since that is impossible for `AllocId`s in
/// constants (as all constants must pass interning and validation that check for dangling
/// ids), this function is frequently used throughout rustc, but should not be used within
/// the miri engine.
pub fn global_alloc(&self, id: AllocId) -> GlobalAlloc<'tcx> {
match self.get_global_alloc(id) {
Some(alloc) => alloc,
None => bug!("could not find allocation for {}", id),
}
}
/// Freezes an `AllocId` created with `reserve` by pointing it at an `Allocation`. Trying to
/// call this function twice, even with the same `Allocation` will ICE the compiler.
pub fn set_alloc_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
if let Some(old) = self.alloc_map.insert(id, GlobalAlloc::Memory(mem)) {
pub fn set_alloc_id_memory(&self, id: AllocId, mem: &'tcx Allocation) {
if let Some(old) = self.alloc_map.lock().alloc_map.insert(id, GlobalAlloc::Memory(mem)) {
bug!("tried to set allocation ID {}, but it was already existing as {:#?}", id, old);
}
}
/// Freezes an `AllocId` created with `reserve` by pointing it at an `Allocation`. May be called
/// twice for the same `(AllocId, Allocation)` pair.
fn set_alloc_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
self.alloc_map.insert_same(id, GlobalAlloc::Memory(mem));
fn set_alloc_id_same_memory(&self, id: AllocId, mem: &'tcx Allocation) {
self.alloc_map.lock().alloc_map.insert_same(id, GlobalAlloc::Memory(mem));
}
}

View file

@ -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};
@ -968,7 +967,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)
@ -2404,13 +2403,9 @@ pub struct Constant<'tcx> {
impl Constant<'tcx> {
pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
match self.literal.val.try_to_scalar() {
Some(Scalar::Ptr(ptr)) => match tcx.alloc_map.lock().get(ptr.alloc_id) {
Some(GlobalAlloc::Static(def_id)) => Some(def_id),
Some(_) => None,
None => {
tcx.sess.delay_span_bug(DUMMY_SP, "MIR cannot contain dangling const pointers");
None
}
Some(Scalar::Ptr(ptr)) => match tcx.global_alloc(ptr.alloc_id) {
GlobalAlloc::Static(def_id) => Some(def_id),
_ => None,
},
_ => None,
}

View file

@ -1,6 +1,7 @@
use crate::dep_graph::SerializedDepNodeIndex;
use crate::mir;
use crate::mir::interpret::{GlobalId, LitToConstInput};
use crate::traits;
use crate::traits::query::{
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
@ -639,7 +640,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 +1053,7 @@ rustc_queries! {
desc { "looking up all possibly unused extern crates" }
}
query names_imported_by_glob_use(def_id: LocalDefId)
-> &'tcx FxHashSet<ast::Name> {
-> &'tcx FxHashSet<Symbol> {
eval_always
desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
}
@ -1154,6 +1155,15 @@ rustc_queries! {
desc { "evaluating trait selection obligation `{}`", goal.value.value }
}
query evaluate_goal(
goal: traits::ChalkCanonicalGoal<'tcx>
) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
NoSolution
> {
desc { "evaluating trait selection obligation `{}`", goal.value }
}
/// Do not call this query directly: part of the `Eq` type-op
query type_op_ascribe_user_type(
goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>

View file

@ -0,0 +1,366 @@
//! Types required for Chalk-related queries
//!
//! The primary purpose of this file is defining an implementation for the
//! `chalk_ir::interner::Interner` trait. The primary purpose of this trait, as
//! its name suggest, is to provide an abstraction boundary for creating
//! interned Chalk types.
use chalk_ir::{GoalData, Parameter};
use rustc_middle::mir::Mutability;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_hir::def_id::DefId;
use smallvec::SmallVec;
use std::cmp::Ordering;
use std::fmt;
use std::hash::{Hash, Hasher};
/// Since Chalk doesn't have full support for all Rust builtin types yet, we
/// need to use an enum here, rather than just `DefId`.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum RustDefId {
Adt(DefId),
Str,
Never,
Slice,
Array,
Ref(Mutability),
RawPtr,
Trait(DefId),
Impl(DefId),
FnDef(DefId),
AssocTy(DefId),
}
#[derive(Copy, Clone)]
pub struct RustInterner<'tcx> {
pub tcx: TyCtxt<'tcx>,
}
/// We don't ever actually need this. It's only required for derives.
impl<'tcx> Hash for RustInterner<'tcx> {
fn hash<H: Hasher>(&self, _state: &mut H) {}
}
/// We don't ever actually need this. It's only required for derives.
impl<'tcx> Ord for RustInterner<'tcx> {
fn cmp(&self, _other: &Self) -> Ordering {
Ordering::Equal
}
}
/// We don't ever actually need this. It's only required for derives.
impl<'tcx> PartialOrd for RustInterner<'tcx> {
fn partial_cmp(&self, _other: &Self) -> Option<Ordering> {
None
}
}
/// We don't ever actually need this. It's only required for derives.
impl<'tcx> PartialEq for RustInterner<'tcx> {
fn eq(&self, _other: &Self) -> bool {
false
}
}
/// We don't ever actually need this. It's only required for derives.
impl<'tcx> Eq for RustInterner<'tcx> {}
impl fmt::Debug for RustInterner<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "RustInterner")
}
}
// Right now, there is no interning at all. I was running into problems with
// adding interning in `ty/context.rs` for Chalk types with
// `parallel-compiler = true`. -jackh726
impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
type InternedType = Box<chalk_ir::TyData<Self>>;
type InternedLifetime = Box<chalk_ir::LifetimeData<Self>>;
type InternedParameter = Box<chalk_ir::ParameterData<Self>>;
type InternedGoal = Box<chalk_ir::GoalData<Self>>;
type InternedGoals = Vec<chalk_ir::Goal<Self>>;
type InternedSubstitution = Vec<chalk_ir::Parameter<Self>>;
type InternedProgramClause = Box<chalk_ir::ProgramClauseData<Self>>;
type InternedProgramClauses = Vec<chalk_ir::ProgramClause<Self>>;
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
type InternedParameterKinds = Vec<chalk_ir::ParameterKind<()>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::ParameterKind<chalk_ir::UniverseIndex>>;
type DefId = RustDefId;
type Identifier = ();
fn debug_program_clause_implication(
pci: &chalk_ir::ProgramClauseImplication<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
let mut write = || {
write!(fmt, "{:?}", pci.consequence)?;
let conditions = pci.conditions.interned();
let conds = conditions.len();
if conds == 0 {
return Ok(());
}
write!(fmt, " :- ")?;
for cond in &conditions[..conds - 1] {
write!(fmt, "{:?}, ", cond)?;
}
write!(fmt, "{:?}", conditions[conds - 1])?;
Ok(())
};
Some(write())
}
fn debug_application_ty(
application_ty: &chalk_ir::ApplicationTy<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
}
fn debug_substitution(
substitution: &chalk_ir::Substitution<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
Some(write!(fmt, "{:?}", substitution.interned()))
}
fn debug_separator_trait_ref(
separator_trait_ref: &chalk_ir::SeparatorTraitRef<'_, Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
let substitution = &separator_trait_ref.trait_ref.substitution;
let parameters = substitution.interned();
Some(write!(
fmt,
"{:?}{}{:?}{:?}",
parameters[0],
separator_trait_ref.separator,
separator_trait_ref.trait_ref.trait_id,
chalk_ir::debug::Angle(&parameters[1..])
))
}
fn debug_quantified_where_clauses(
clauses: &chalk_ir::QuantifiedWhereClauses<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
Some(write!(fmt, "{:?}", clauses.interned()))
}
fn debug_alias(
alias_ty: &chalk_ir::AliasTy<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
match alias_ty {
chalk_ir::AliasTy::Projection(projection_ty) => {
Self::debug_projection_ty(projection_ty, fmt)
}
chalk_ir::AliasTy::Opaque(opaque_ty) => Self::debug_opaque_ty(opaque_ty, fmt),
}
}
fn debug_projection_ty(
projection_ty: &chalk_ir::ProjectionTy<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
Some(write!(
fmt,
"projection: {:?} {:?}",
projection_ty.associated_ty_id, projection_ty.substitution,
))
}
fn debug_opaque_ty(
opaque_ty: &chalk_ir::OpaqueTy<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
Some(write!(fmt, "{:?}", opaque_ty.opaque_ty_id))
}
fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Self::InternedType {
Box::new(ty)
}
fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
ty
}
fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
Box::new(lifetime)
}
fn lifetime_data<'a>(
&self,
lifetime: &'a Self::InternedLifetime,
) -> &'a chalk_ir::LifetimeData<Self> {
&lifetime
}
fn intern_parameter(
&self,
parameter: chalk_ir::ParameterData<Self>,
) -> Self::InternedParameter {
Box::new(parameter)
}
fn parameter_data<'a>(
&self,
parameter: &'a Self::InternedParameter,
) -> &'a chalk_ir::ParameterData<Self> {
&parameter
}
fn intern_goal(&self, goal: GoalData<Self>) -> Self::InternedGoal {
Box::new(goal)
}
fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
&goal
}
fn intern_goals<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::Goal<Self>, E>>,
) -> Result<Self::InternedGoals, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
fn goals_data<'a>(&self, goals: &'a Self::InternedGoals) -> &'a [chalk_ir::Goal<Self>] {
goals
}
fn intern_substitution<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::Parameter<Self>, E>>,
) -> Result<Self::InternedSubstitution, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
fn substitution_data<'a>(
&self,
substitution: &'a Self::InternedSubstitution,
) -> &'a [Parameter<Self>] {
substitution
}
fn intern_program_clause(
&self,
data: chalk_ir::ProgramClauseData<Self>,
) -> Self::InternedProgramClause {
Box::new(data)
}
fn program_clause_data<'a>(
&self,
clause: &'a Self::InternedProgramClause,
) -> &'a chalk_ir::ProgramClauseData<Self> {
&clause
}
fn intern_program_clauses<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>,
) -> Result<Self::InternedProgramClauses, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
fn program_clauses_data<'a>(
&self,
clauses: &'a Self::InternedProgramClauses,
) -> &'a [chalk_ir::ProgramClause<Self>] {
clauses
}
fn intern_quantified_where_clauses<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>,
) -> Result<Self::InternedQuantifiedWhereClauses, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
fn quantified_where_clauses_data<'a>(
&self,
clauses: &'a Self::InternedQuantifiedWhereClauses,
) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] {
clauses
}
fn intern_parameter_kinds<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<()>, E>>,
) -> Result<Self::InternedParameterKinds, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
fn parameter_kinds_data<'a>(
&self,
parameter_kinds: &'a Self::InternedParameterKinds,
) -> &'a [chalk_ir::ParameterKind<()>] {
parameter_kinds
}
fn intern_canonical_var_kinds<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<chalk_ir::UniverseIndex>, E>>,
) -> Result<Self::InternedCanonicalVarKinds, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
fn canonical_var_kinds_data<'a>(
&self,
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
) -> &'a [chalk_ir::ParameterKind<chalk_ir::UniverseIndex>] {
canonical_var_kinds
}
}
impl<'tcx> chalk_ir::interner::HasInterner for RustInterner<'tcx> {
type Interner = Self;
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
pub enum ChalkEnvironmentClause<'tcx> {
/// A normal rust `ty::Predicate` in the environment.
Predicate(ty::Predicate<'tcx>),
/// A special clause in the environment that gets lowered to
/// `chalk_ir::FromEnv::Ty`.
TypeFromEnv(Ty<'tcx>),
}
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ChalkEnvironmentClause<'tcx>> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let v = self.iter().map(|t| t.fold_with(folder)).collect::<SmallVec<[_; 8]>>();
folder.tcx().intern_chalk_environment_clause_list(&v)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.iter().any(|t| t.visit_with(visitor))
}
}
/// We have to elaborate the environment of a chalk goal *before*
/// canonicalization. This type wraps the predicate and the elaborated
/// environment.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
pub struct ChalkEnvironmentAndGoal<'tcx> {
pub environment: &'tcx ty::List<ChalkEnvironmentClause<'tcx>>,
pub goal: ty::Predicate<'tcx>,
}
impl<'tcx> fmt::Display for ChalkEnvironmentAndGoal<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "environment: {:?}, goal: {}", self.environment, self.goal)
}
}

View file

@ -2,18 +2,20 @@
//!
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
mod chalk;
pub mod query;
pub mod select;
pub mod specialization_graph;
mod structural_impls;
use crate::infer::canonical::Canonical;
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;
@ -23,10 +25,17 @@ use std::rc::Rc;
pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
pub type ChalkCanonicalGoal<'tcx> = Canonical<'tcx, ChalkEnvironmentAndGoal<'tcx>>;
pub use self::ObligationCauseCode::*;
pub use self::SelectionError::*;
pub use self::Vtable::*;
pub use self::chalk::{
ChalkEnvironmentAndGoal, ChalkEnvironmentClause, RustDefId as ChalkRustDefId,
RustInterner as ChalkRustInterner,
};
/// Depending on the stage of compilation, we want projection to be
/// more or less conservative.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)]
@ -198,14 +207,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 +575,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 {

View file

@ -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

View file

@ -93,6 +93,8 @@ pub struct CtxtInterners<'tcx> {
projs: InternedSet<'tcx, List<ProjectionKind>>,
place_elems: InternedSet<'tcx, List<PlaceElem<'tcx>>>,
const_: InternedSet<'tcx, Const<'tcx>>,
chalk_environment_clause_list: InternedSet<'tcx, List<traits::ChalkEnvironmentClause<'tcx>>>,
}
impl<'tcx> CtxtInterners<'tcx> {
@ -109,6 +111,8 @@ impl<'tcx> CtxtInterners<'tcx> {
projs: Default::default(),
place_elems: Default::default(),
const_: Default::default(),
chalk_environment_clause_list: Default::default(),
}
}
@ -376,7 +380,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 +625,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 +945,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<LocalDefId, FxHashSet<ast::Name>>,
glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
/// 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<ast::Name, bool>,
pub extern_prelude: FxHashMap<Symbol, bool>,
// Internal cache for metadata decoding. No need to track deps on this.
pub rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
@ -975,7 +979,7 @@ pub struct GlobalCtxt<'tcx> {
allocation_interner: ShardedHashMap<&'tcx Allocation, ()>,
/// Stores memory for globals (statics/consts).
pub alloc_map: Lock<interpret::AllocMap<'tcx>>,
pub(crate) alloc_map: Lock<interpret::AllocMap<'tcx>>,
layout_interner: ShardedHashMap<&'tcx Layout, ()>,
@ -1013,7 +1017,7 @@ impl<'tcx> TyCtxt<'tcx> {
// Create an allocation that just contains these bytes.
let alloc = interpret::Allocation::from_byte_aligned_bytes(bytes);
let alloc = self.intern_const_alloc(alloc);
self.alloc_map.lock().create_memory_alloc(alloc)
self.create_memory_alloc(alloc)
}
pub fn intern_stability(self, stab: attr::Stability) -> &'tcx attr::Stability {
@ -1997,6 +2001,14 @@ impl<'tcx> Borrow<Const<'tcx>> for Interned<'tcx, Const<'tcx>> {
}
}
impl<'tcx> Borrow<[traits::ChalkEnvironmentClause<'tcx>]>
for Interned<'tcx, List<traits::ChalkEnvironmentClause<'tcx>>>
{
fn borrow<'a>(&'a self) -> &'a [traits::ChalkEnvironmentClause<'tcx>] {
&self.0[..]
}
}
macro_rules! direct_interners {
($($name:ident: $method:ident($ty:ty)),+) => {
$(impl<'tcx> PartialEq for Interned<'tcx, $ty> {
@ -2044,7 +2056,9 @@ slice_interners!(
existential_predicates: _intern_existential_predicates(ExistentialPredicate<'tcx>),
predicates: _intern_predicates(Predicate<'tcx>),
projs: _intern_projs(ProjectionKind),
place_elems: _intern_place_elems(PlaceElem<'tcx>)
place_elems: _intern_place_elems(PlaceElem<'tcx>),
chalk_environment_clause_list:
_intern_chalk_environment_clause_list(traits::ChalkEnvironmentClause<'tcx>)
);
impl<'tcx> TyCtxt<'tcx> {
@ -2430,6 +2444,13 @@ impl<'tcx> TyCtxt<'tcx> {
if ts.is_empty() { List::empty() } else { self._intern_canonical_var_infos(ts) }
}
pub fn intern_chalk_environment_clause_list(
self,
ts: &[traits::ChalkEnvironmentClause<'tcx>],
) -> &'tcx List<traits::ChalkEnvironmentClause<'tcx>> {
if ts.is_empty() { List::empty() } else { self._intern_chalk_environment_clause_list(ts) }
}
pub fn mk_fn_sig<I>(
self,
inputs: I,
@ -2487,6 +2508,18 @@ impl<'tcx> TyCtxt<'tcx> {
self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned()))
}
pub fn mk_chalk_environment_clause_list<
I: InternAs<
[traits::ChalkEnvironmentClause<'tcx>],
&'tcx List<traits::ChalkEnvironmentClause<'tcx>>,
>,
>(
self,
iter: I,
) -> I::Output {
iter.intern_with(|xs| self.intern_chalk_environment_clause_list(xs))
}
/// Walks upwards from `id` to find a node which might change lint levels with attributes.
/// It stops at `bound` and just returns it if reached.
pub fn maybe_lint_level_root_bounded(self, mut id: HirId, bound: HirId) -> HirId {

View file

@ -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<Ident>,
flds: &[ast::Name],
layout: TyAndLayout<'tcx>| {
let build_variant_info = |n: Option<Ident>, flds: &[Symbol], layout: TyAndLayout<'tcx>| {
let mut min_size = Size::ZERO;
let field_info: Vec<_> = flds
.iter()

View file

@ -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<Name, bool>,
pub extern_prelude: FxHashMap<Symbol, bool>,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)]

View file

@ -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;
@ -956,9 +956,8 @@ pub trait PrettyPrinter<'tcx>:
) => {
let byte_str = self
.tcx()
.alloc_map
.lock()
.unwrap_memory(ptr.alloc_id)
.global_alloc(ptr.alloc_id)
.unwrap_memory()
.get_bytes(&self.tcx(), ptr, Size::from_bytes(*data))
.unwrap();
p!(pretty_print_byte_str(byte_str));
@ -1021,10 +1020,7 @@ pub trait PrettyPrinter<'tcx>:
)?;
}
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
let instance = {
let alloc_map = self.tcx().alloc_map.lock();
alloc_map.unwrap_fn(ptr.alloc_id)
};
let instance = self.tcx().global_alloc(ptr.alloc_id).unwrap_fn();
self = self.typed_value(
|this| this.print_value_path(instance.def_id(), instance.substs),
|this| this.print_type(ty),
@ -1456,7 +1452,7 @@ impl<F: fmt::Write> 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)?;

View file

@ -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;

Some files were not shown because too many files have changed in this diff Show more