Auto merge of #37824 - jseyfried:symbols, r=eddyb
Clean up `ast::Attribute`, `ast::CrateConfig`, and string interning This PR - removes `ast::Attribute_` (changing `Attribute` from `Spanned<Attribute_>` to a struct), - moves a `MetaItem`'s name from the `MetaItemKind` variants to a field of `MetaItem`, - avoids needlessly wrapping `ast::MetaItem` with `P`, - moves string interning into `syntax::symbol` (`ast::Name` is a reexport of `symbol::Symbol` for now), - replaces `InternedString` with `Symbol` in the AST, HIR, and various other places, and - refactors `ast::CrateConfig` from a `Vec` to a `HashSet`. r? @eddyb
This commit is contained in:
commit
ebec55406b
164 changed files with 1518 additions and 1828 deletions
|
|
@ -64,7 +64,7 @@ impl<'a> CheckAttrVisitor<'a> {
|
|||
None => continue,
|
||||
};
|
||||
|
||||
let (message, label) = match &*name {
|
||||
let (message, label) = match &*name.as_str() {
|
||||
"C" => {
|
||||
conflicting_reprs += 1;
|
||||
if target != Target::Struct &&
|
||||
|
|
@ -120,7 +120,7 @@ impl<'a> CheckAttrVisitor<'a> {
|
|||
}
|
||||
|
||||
fn check_attribute(&self, attr: &ast::Attribute, target: Target) {
|
||||
let name: &str = &attr.name();
|
||||
let name: &str = &attr.name().as_str();
|
||||
match name {
|
||||
"inline" => self.check_inline(attr, target),
|
||||
"repr" => self.check_repr(attr, target),
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ use syntax::ast::*;
|
|||
use syntax::errors;
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap::{respan, Spanned};
|
||||
use syntax::parse::token;
|
||||
use syntax::std_inject;
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax_pos::Span;
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
|
||||
fn str_to_ident(&self, s: &'static str) -> Name {
|
||||
token::gensym(s)
|
||||
Symbol::gensym(s)
|
||||
}
|
||||
|
||||
fn with_parent_def<T, F>(&mut self, parent_id: NodeId, f: F) -> T
|
||||
|
|
@ -400,8 +400,8 @@ impl<'a> LoweringContext<'a> {
|
|||
// Don't expose `Self` (recovered "keyword used as ident" parse error).
|
||||
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
|
||||
// Instead, use gensym("Self") to create a distinct name that looks the same.
|
||||
if name == token::keywords::SelfType.name() {
|
||||
name = token::gensym("Self");
|
||||
if name == keywords::SelfType.name() {
|
||||
name = Symbol::gensym("Self");
|
||||
}
|
||||
|
||||
hir::TyParam {
|
||||
|
|
@ -540,7 +540,7 @@ impl<'a> LoweringContext<'a> {
|
|||
hir::StructField {
|
||||
span: f.span,
|
||||
id: f.id,
|
||||
name: f.ident.map(|ident| ident.name).unwrap_or(token::intern(&index.to_string())),
|
||||
name: f.ident.map(|ident| ident.name).unwrap_or(Symbol::intern(&index.to_string())),
|
||||
vis: self.lower_visibility(&f.vis),
|
||||
ty: self.lower_ty(&f.ty),
|
||||
attrs: self.lower_attrs(&f.attrs),
|
||||
|
|
@ -1189,7 +1189,7 @@ impl<'a> LoweringContext<'a> {
|
|||
e.span,
|
||||
hir::PopUnstableBlock,
|
||||
ThinVec::new());
|
||||
this.field(token::intern(s), signal_block, ast_expr.span)
|
||||
this.field(Symbol::intern(s), signal_block, ast_expr.span)
|
||||
}).collect();
|
||||
let attrs = ast_expr.attrs.clone();
|
||||
|
||||
|
|
@ -1953,9 +1953,9 @@ impl<'a> LoweringContext<'a> {
|
|||
fn std_path_components(&mut self, components: &[&str]) -> Vec<Name> {
|
||||
let mut v = Vec::new();
|
||||
if let Some(s) = self.crate_root {
|
||||
v.push(token::intern(s));
|
||||
v.push(Symbol::intern(s));
|
||||
}
|
||||
v.extend(components.iter().map(|s| token::intern(s)));
|
||||
v.extend(components.iter().map(|s| Symbol::intern(s)));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use middle::cstore::InlinedItem;
|
|||
use syntax::ast::*;
|
||||
use syntax::ext::hygiene::Mark;
|
||||
use syntax::visit;
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
|
||||
/// Creates def ids for nodes in the HIR.
|
||||
pub struct DefCollector<'a> {
|
||||
|
|
@ -169,7 +169,7 @@ impl<'a> visit::Visitor for DefCollector<'a> {
|
|||
this.with_parent(variant_def_index, |this| {
|
||||
for (index, field) in v.node.data.fields().iter().enumerate() {
|
||||
let name = field.ident.map(|ident| ident.name)
|
||||
.unwrap_or_else(|| token::intern(&index.to_string()));
|
||||
.unwrap_or_else(|| Symbol::intern(&index.to_string()));
|
||||
this.create_def(field.id, DefPathData::Field(name.as_str()));
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ impl<'a> visit::Visitor for DefCollector<'a> {
|
|||
|
||||
for (index, field) in struct_def.fields().iter().enumerate() {
|
||||
let name = field.ident.map(|ident| ident.name.as_str())
|
||||
.unwrap_or(token::intern(&index.to_string()).as_str());
|
||||
.unwrap_or(Symbol::intern(&index.to_string()).as_str());
|
||||
this.create_def(field.id, DefPathData::Field(name));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use std::fmt::Write;
|
|||
use std::hash::{Hash, Hasher};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::{self, InternedString};
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use ty::TyCtxt;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
|
|
@ -115,9 +115,9 @@ impl DefPath {
|
|||
pub fn to_string(&self, tcx: TyCtxt) -> String {
|
||||
let mut s = String::with_capacity(self.data.len() * 16);
|
||||
|
||||
s.push_str(&tcx.original_crate_name(self.krate));
|
||||
s.push_str(&tcx.original_crate_name(self.krate).as_str());
|
||||
s.push_str("/");
|
||||
s.push_str(&tcx.crate_disambiguator(self.krate));
|
||||
s.push_str(&tcx.crate_disambiguator(self.krate).as_str());
|
||||
|
||||
for component in &self.data {
|
||||
write!(s,
|
||||
|
|
@ -137,8 +137,8 @@ impl DefPath {
|
|||
}
|
||||
|
||||
pub fn deterministic_hash_to<H: Hasher>(&self, tcx: TyCtxt, state: &mut H) {
|
||||
tcx.original_crate_name(self.krate).hash(state);
|
||||
tcx.crate_disambiguator(self.krate).hash(state);
|
||||
tcx.original_crate_name(self.krate).as_str().hash(state);
|
||||
tcx.crate_disambiguator(self.krate).as_str().hash(state);
|
||||
self.data.hash(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ impl DefPathData {
|
|||
LifetimeDef(ref name) |
|
||||
EnumVariant(ref name) |
|
||||
Binding(ref name) |
|
||||
Field(ref name) => Some(token::intern(name)),
|
||||
Field(ref name) => Some(Symbol::intern(name)),
|
||||
|
||||
Impl |
|
||||
CrateRoot |
|
||||
|
|
@ -343,7 +343,7 @@ impl DefPathData {
|
|||
|
||||
pub fn as_interned_str(&self) -> InternedString {
|
||||
use self::DefPathData::*;
|
||||
match *self {
|
||||
let s = match *self {
|
||||
TypeNs(ref name) |
|
||||
ValueNs(ref name) |
|
||||
Module(ref name) |
|
||||
|
|
@ -353,43 +353,24 @@ impl DefPathData {
|
|||
EnumVariant(ref name) |
|
||||
Binding(ref name) |
|
||||
Field(ref name) => {
|
||||
name.clone()
|
||||
}
|
||||
|
||||
Impl => {
|
||||
InternedString::new("{{impl}}")
|
||||
return name.clone();
|
||||
}
|
||||
|
||||
// note that this does not show up in user printouts
|
||||
CrateRoot => {
|
||||
InternedString::new("{{root}}")
|
||||
}
|
||||
CrateRoot => "{{root}}",
|
||||
|
||||
// note that this does not show up in user printouts
|
||||
InlinedRoot(_) => {
|
||||
InternedString::new("{{inlined-root}}")
|
||||
}
|
||||
InlinedRoot(_) => "{{inlined-root}}",
|
||||
|
||||
Misc => {
|
||||
InternedString::new("{{?}}")
|
||||
}
|
||||
Impl => "{{impl}}",
|
||||
Misc => "{{?}}",
|
||||
ClosureExpr => "{{closure}}",
|
||||
StructCtor => "{{constructor}}",
|
||||
Initializer => "{{initializer}}",
|
||||
ImplTrait => "{{impl-Trait}}",
|
||||
};
|
||||
|
||||
ClosureExpr => {
|
||||
InternedString::new("{{closure}}")
|
||||
}
|
||||
|
||||
StructCtor => {
|
||||
InternedString::new("{{constructor}}")
|
||||
}
|
||||
|
||||
Initializer => {
|
||||
InternedString::new("{{initializer}}")
|
||||
}
|
||||
|
||||
ImplTrait => {
|
||||
InternedString::new("{{impl-Trait}}")
|
||||
}
|
||||
}
|
||||
Symbol::intern(s).as_str()
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
|
|
|
|||
|
|
@ -765,7 +765,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
|||
None => return false,
|
||||
Some((node_id, name)) => (node_id, name),
|
||||
};
|
||||
if &part[..] != mod_name.as_str() {
|
||||
if mod_name != &**part {
|
||||
return false;
|
||||
}
|
||||
cursor = self.map.get_parent(mod_id);
|
||||
|
|
@ -803,8 +803,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
|||
// We are looking at some node `n` with a given name and parent
|
||||
// id; do their names match what I am seeking?
|
||||
fn matches_names(&self, parent_of_n: NodeId, name: Name) -> bool {
|
||||
name.as_str() == &self.item_name[..] &&
|
||||
self.suffix_matches(parent_of_n)
|
||||
name == &**self.item_name && self.suffix_matches(parent_of_n)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ use syntax::codemap::{self, respan, Spanned};
|
|||
use syntax::abi::Abi;
|
||||
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, AsmDialect};
|
||||
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
|
||||
use syntax::parse::token::{keywords, InternedString};
|
||||
use syntax::ptr::P;
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax::tokenstream::TokenTree;
|
||||
use syntax::util::ThinVec;
|
||||
|
||||
|
|
@ -1163,18 +1163,18 @@ pub enum Ty_ {
|
|||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct InlineAsmOutput {
|
||||
pub constraint: InternedString,
|
||||
pub constraint: Symbol,
|
||||
pub is_rw: bool,
|
||||
pub is_indirect: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct InlineAsm {
|
||||
pub asm: InternedString,
|
||||
pub asm: Symbol,
|
||||
pub asm_str_style: StrStyle,
|
||||
pub outputs: HirVec<InlineAsmOutput>,
|
||||
pub inputs: HirVec<InternedString>,
|
||||
pub clobbers: HirVec<InternedString>,
|
||||
pub inputs: HirVec<Symbol>,
|
||||
pub clobbers: HirVec<Symbol>,
|
||||
pub volatile: bool,
|
||||
pub alignstack: bool,
|
||||
pub dialect: AsmDialect,
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ pub use self::AnnNode::*;
|
|||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{CodeMap, Spanned};
|
||||
use syntax::parse::token::{self, keywords, BinOpToken};
|
||||
use syntax::parse::token::{self, BinOpToken};
|
||||
use syntax::parse::lexer::comments;
|
||||
use syntax::print::pp::{self, break_offset, word, space, hardbreak};
|
||||
use syntax::print::pp::{Breaks, eof};
|
||||
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
|
||||
use syntax::print::pprust::{self as ast_pp, PrintState};
|
||||
use syntax::ptr::P;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::{self, BytePos};
|
||||
use errors;
|
||||
|
||||
|
|
@ -1499,19 +1500,19 @@ impl<'a> State<'a> {
|
|||
hir::ExprInlineAsm(ref a, ref outputs, ref inputs) => {
|
||||
word(&mut self.s, "asm!")?;
|
||||
self.popen()?;
|
||||
self.print_string(&a.asm, a.asm_str_style)?;
|
||||
self.print_string(&a.asm.as_str(), a.asm_str_style)?;
|
||||
self.word_space(":")?;
|
||||
|
||||
let mut out_idx = 0;
|
||||
self.commasep(Inconsistent, &a.outputs, |s, out| {
|
||||
let mut ch = out.constraint.chars();
|
||||
let constraint = out.constraint.as_str();
|
||||
let mut ch = constraint.chars();
|
||||
match ch.next() {
|
||||
Some('=') if out.is_rw => {
|
||||
s.print_string(&format!("+{}", ch.as_str()),
|
||||
ast::StrStyle::Cooked)?
|
||||
}
|
||||
_ => s.print_string(&out.constraint,
|
||||
ast::StrStyle::Cooked)?,
|
||||
_ => s.print_string(&constraint, ast::StrStyle::Cooked)?,
|
||||
}
|
||||
s.popen()?;
|
||||
s.print_expr(&outputs[out_idx])?;
|
||||
|
|
@ -1524,7 +1525,7 @@ impl<'a> State<'a> {
|
|||
|
||||
let mut in_idx = 0;
|
||||
self.commasep(Inconsistent, &a.inputs, |s, co| {
|
||||
s.print_string(&co, ast::StrStyle::Cooked)?;
|
||||
s.print_string(&co.as_str(), ast::StrStyle::Cooked)?;
|
||||
s.popen()?;
|
||||
s.print_expr(&inputs[in_idx])?;
|
||||
s.pclose()?;
|
||||
|
|
@ -1535,7 +1536,7 @@ impl<'a> State<'a> {
|
|||
self.word_space(":")?;
|
||||
|
||||
self.commasep(Inconsistent, &a.clobbers, |s, co| {
|
||||
s.print_string(&co, ast::StrStyle::Cooked)?;
|
||||
s.print_string(&co.as_str(), ast::StrStyle::Cooked)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ use std::cell::{Cell, RefCell};
|
|||
use std::char::from_u32;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{self, Pos, Span};
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
|
|
@ -1219,7 +1219,7 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
|
|||
names.push(lt_name);
|
||||
}
|
||||
names.sort();
|
||||
let name = token::intern(&names[0]);
|
||||
let name = Symbol::intern(&names[0]);
|
||||
return (name_to_dummy_lifetime(name), Kept);
|
||||
}
|
||||
return (self.life_giver.give_lifetime(), Fresh);
|
||||
|
|
@ -1931,7 +1931,7 @@ impl LifeGiver {
|
|||
let mut s = String::from("'");
|
||||
s.push_str(&num_to_string(self.counter.get()));
|
||||
if !self.taken.contains(&s) {
|
||||
lifetime = name_to_dummy_lifetime(token::intern(&s[..]));
|
||||
lifetime = name_to_dummy_lifetime(Symbol::intern(&s));
|
||||
self.generated.borrow_mut().push(lifetime);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ use std::default::Default as StdDefault;
|
|||
use std::mem;
|
||||
use std::fmt;
|
||||
use syntax::attr;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::ast;
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
use errors::{self, Diagnostic, DiagnosticBuilder};
|
||||
|
|
@ -384,8 +383,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $ps:ident, $($args:expr),*) => ({
|
|||
/// Parse the lint attributes into a vector, with `Err`s for malformed lint
|
||||
/// attributes. Writing this as an iterator is an enormous mess.
|
||||
// See also the hir version just below.
|
||||
pub fn gather_attrs(attrs: &[ast::Attribute])
|
||||
-> Vec<Result<(InternedString, Level, Span), Span>> {
|
||||
pub fn gather_attrs(attrs: &[ast::Attribute]) -> Vec<Result<(ast::Name, Level, Span), Span>> {
|
||||
let mut out = vec![];
|
||||
for attr in attrs {
|
||||
let r = gather_attr(attr);
|
||||
|
|
@ -394,18 +392,17 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
|
|||
out
|
||||
}
|
||||
|
||||
pub fn gather_attr(attr: &ast::Attribute)
|
||||
-> Vec<Result<(InternedString, Level, Span), Span>> {
|
||||
pub fn gather_attr(attr: &ast::Attribute) -> Vec<Result<(ast::Name, Level, Span), Span>> {
|
||||
let mut out = vec![];
|
||||
|
||||
let level = match Level::from_str(&attr.name()) {
|
||||
let level = match Level::from_str(&attr.name().as_str()) {
|
||||
None => return out,
|
||||
Some(lvl) => lvl,
|
||||
};
|
||||
|
||||
attr::mark_used(attr);
|
||||
|
||||
let meta = &attr.node.value;
|
||||
let meta = &attr.value;
|
||||
let metas = if let Some(metas) = meta.meta_item_list() {
|
||||
metas
|
||||
} else {
|
||||
|
|
@ -414,9 +411,7 @@ pub fn gather_attr(attr: &ast::Attribute)
|
|||
};
|
||||
|
||||
for li in metas {
|
||||
out.push(li.word().map_or(Err(li.span), |word| {
|
||||
Ok((word.name().clone(), level, word.span))
|
||||
}));
|
||||
out.push(li.word().map_or(Err(li.span), |word| Ok((word.name(), level, word.span))));
|
||||
}
|
||||
|
||||
out
|
||||
|
|
@ -629,10 +624,10 @@ pub trait LintContext: Sized {
|
|||
continue;
|
||||
}
|
||||
Ok((lint_name, level, span)) => {
|
||||
match self.lints().find_lint(&lint_name, &self.sess(), Some(span)) {
|
||||
match self.lints().find_lint(&lint_name.as_str(), &self.sess(), Some(span)) {
|
||||
Ok(lint_id) => vec![(lint_id, level, span)],
|
||||
Err(FindLintError::NotFound) => {
|
||||
match self.lints().lint_groups.get(&lint_name[..]) {
|
||||
match self.lints().lint_groups.get(&*lint_name.as_str()) {
|
||||
Some(&(ref v, _)) => v.iter()
|
||||
.map(|lint_id: &LintId|
|
||||
(*lint_id, level, span))
|
||||
|
|
@ -1193,8 +1188,7 @@ fn check_lint_name_attribute(cx: &LateContext, attr: &ast::Attribute) {
|
|||
continue;
|
||||
}
|
||||
Ok((lint_name, _, span)) => {
|
||||
match check_lint_name(&cx.lints,
|
||||
&lint_name[..]) {
|
||||
match check_lint_name(&cx.lints, &lint_name.as_str()) {
|
||||
CheckLintNameResult::Ok => (),
|
||||
CheckLintNameResult::Warning(ref msg) => {
|
||||
cx.span_lint(builtin::RENAMED_AND_REMOVED_LINTS,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::ast;
|
||||
use std::rc::Rc;
|
||||
use hir::def_id::DefId;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use syntax::ast;
|
|||
use syntax::attr;
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax::ptr::P;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
use rustc_back::target::Target;
|
||||
use hir;
|
||||
|
|
@ -52,7 +52,7 @@ pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown};
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct LinkMeta {
|
||||
pub crate_name: String,
|
||||
pub crate_name: Symbol,
|
||||
pub crate_hash: Svh,
|
||||
}
|
||||
|
||||
|
|
@ -92,8 +92,8 @@ pub enum NativeLibraryKind {
|
|||
#[derive(Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub struct NativeLibrary {
|
||||
pub kind: NativeLibraryKind,
|
||||
pub name: String,
|
||||
pub cfg: Option<P<ast::MetaItem>>,
|
||||
pub name: Symbol,
|
||||
pub cfg: Option<ast::MetaItem>,
|
||||
}
|
||||
|
||||
/// The data we save and restore about an inlined item or method. This is not
|
||||
|
|
@ -205,11 +205,11 @@ pub trait CrateStore<'tcx> {
|
|||
fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate>;
|
||||
/// The name of the crate as it is referred to in source code of the current
|
||||
/// crate.
|
||||
fn crate_name(&self, cnum: CrateNum) -> InternedString;
|
||||
fn crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||
/// The name of the crate as it is stored in the crate's metadata.
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> InternedString;
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||
fn crate_hash(&self, cnum: CrateNum) -> Svh;
|
||||
fn crate_disambiguator(&self, cnum: CrateNum) -> InternedString;
|
||||
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
|
||||
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
|
||||
fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>;
|
||||
fn reachable_ids(&self, cnum: CrateNum) -> Vec<DefId>;
|
||||
|
|
@ -375,13 +375,13 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
bug!("panic_strategy")
|
||||
}
|
||||
fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
|
||||
fn crate_name(&self, cnum: CrateNum) -> InternedString { bug!("crate_name") }
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> InternedString {
|
||||
fn crate_name(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
|
||||
bug!("original_crate_name")
|
||||
}
|
||||
fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
|
||||
fn crate_disambiguator(&self, cnum: CrateNum)
|
||||
-> InternedString { bug!("crate_disambiguator") }
|
||||
-> Symbol { bug!("crate_disambiguator") }
|
||||
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
|
||||
{ bug!("plugin_registrar_fn") }
|
||||
fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
|
||||
|
|
|
|||
|
|
@ -309,8 +309,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
|
|||
let dead_code = lint::builtin::DEAD_CODE.name_lower();
|
||||
for attr in lint::gather_attrs(attrs) {
|
||||
match attr {
|
||||
Ok((ref name, lint::Allow, _))
|
||||
if &name[..] == dead_code => return true,
|
||||
Ok((name, lint::Allow, _)) if name == &*dead_code => return true,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
@ -499,8 +498,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
|||
span: syntax_pos::Span,
|
||||
name: ast::Name,
|
||||
node_type: &str) {
|
||||
let name = name.as_str();
|
||||
if !name.starts_with("_") {
|
||||
if !name.as_str().starts_with("_") {
|
||||
self.tcx
|
||||
.sess
|
||||
.add_lint(lint::builtin::DEAD_CODE,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
|
|||
EntryPointType::Start
|
||||
} else if attr::contains_name(&item.attrs, "main") {
|
||||
EntryPointType::MainAttr
|
||||
} else if item.name.as_str() == "main" {
|
||||
} else if item.name == "main" {
|
||||
if at_root {
|
||||
// This is a top-level function so can be 'main'
|
||||
EntryPointType::MainNamed
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
|||
ty::TyFnDef(.., ref bfty) => bfty.abi == RustIntrinsic,
|
||||
_ => return false
|
||||
};
|
||||
intrinsic && self.infcx.tcx.item_name(def_id).as_str() == "transmute"
|
||||
intrinsic && self.infcx.tcx.item_name(def_id) == "transmute"
|
||||
}
|
||||
|
||||
fn check_transmute(&self, span: Span, from: Ty<'gcx>, to: Ty<'gcx>, id: ast::NodeId) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use middle::weak_lang_items;
|
|||
use util::nodemap::FxHashMap;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use hir::itemlikevisit::ItemLikeVisitor;
|
||||
use hir;
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ struct LanguageItemCollector<'a, 'tcx: 'a> {
|
|||
impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let Some(value) = extract(&item.attrs) {
|
||||
let item_index = self.item_refs.get(&value[..]).cloned();
|
||||
let item_index = self.item_refs.get(&*value.as_str()).cloned();
|
||||
|
||||
if let Some(item_index) = item_index {
|
||||
self.collect_item(item_index, self.ast_map.local_def_id(item.id))
|
||||
|
|
@ -160,7 +160,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
|
|||
let span = self.ast_map.span(item.id);
|
||||
span_err!(self.session, span, E0522,
|
||||
"definition of an unknown language item: `{}`.",
|
||||
&value[..]);
|
||||
value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -243,12 +243,10 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
|
||||
pub fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
|
||||
for attribute in attrs {
|
||||
match attribute.value_str() {
|
||||
Some(ref value) if attribute.check_name("lang") => {
|
||||
return Some(value.clone());
|
||||
}
|
||||
Some(value) if attribute.check_name("lang") => return Some(value),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ use std::io::prelude::*;
|
|||
use std::io;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::ptr::P;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir::Expr;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
|
|||
}
|
||||
|
||||
if let Some(s) = attr.value_str() {
|
||||
if let Some(n) = s.parse().ok() {
|
||||
if let Some(n) = s.as_str().parse().ok() {
|
||||
sess.recursion_limit.set(n);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use middle::region;
|
|||
use ty;
|
||||
use std::mem::replace;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::Span;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use hir::def::Def;
|
|||
use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, DefIndex, LOCAL_CRATE};
|
||||
use ty::{self, TyCtxt, AdtKind};
|
||||
use middle::privacy::AccessLevels;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use syntax::ast;
|
||||
use syntax::ast::{NodeId, Attribute};
|
||||
|
|
@ -36,7 +36,6 @@ use hir::pat_util::EnumerateAndAdjustIterator;
|
|||
|
||||
use std::mem::replace;
|
||||
use std::cmp::Ordering;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Copy, Debug, Eq, Hash)]
|
||||
pub enum StabilityLevel {
|
||||
|
|
@ -151,10 +150,11 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
|||
|
||||
// Check if deprecated_since < stable_since. If it is,
|
||||
// this is *almost surely* an accident.
|
||||
if let (&Some(attr::RustcDeprecation {since: ref dep_since, ..}),
|
||||
&attr::Stable {since: ref stab_since}) = (&stab.rustc_depr, &stab.level) {
|
||||
if let (&Some(attr::RustcDeprecation {since: dep_since, ..}),
|
||||
&attr::Stable {since: stab_since}) = (&stab.rustc_depr, &stab.level) {
|
||||
// Explicit version of iter::order::lt to handle parse errors properly
|
||||
for (dep_v, stab_v) in dep_since.split(".").zip(stab_since.split(".")) {
|
||||
for (dep_v, stab_v) in
|
||||
dep_since.as_str().split(".").zip(stab_since.as_str().split(".")) {
|
||||
if let (Ok(dep_v), Ok(stab_v)) = (dep_v.parse::<u64>(), stab_v.parse()) {
|
||||
match dep_v.cmp(&stab_v) {
|
||||
Ordering::Less => {
|
||||
|
|
@ -356,7 +356,7 @@ impl<'a, 'tcx> Index<'tcx> {
|
|||
/// features and possibly prints errors. Returns a list of all
|
||||
/// features used.
|
||||
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> FxHashMap<InternedString, attr::StabilityLevel> {
|
||||
-> FxHashMap<Symbol, attr::StabilityLevel> {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck);
|
||||
let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
|
||||
|
||||
|
|
@ -376,8 +376,8 @@ pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
|||
|
||||
struct Checker<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
active_features: FxHashSet<InternedString>,
|
||||
used_features: FxHashMap<InternedString, attr::StabilityLevel>,
|
||||
active_features: FxHashSet<Symbol>,
|
||||
used_features: FxHashMap<Symbol, attr::StabilityLevel>,
|
||||
// Within a block where feature gate checking can be skipped.
|
||||
in_skip_block: u32,
|
||||
}
|
||||
|
|
@ -407,10 +407,10 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
|||
if !self.active_features.contains(feature) {
|
||||
let msg = match *reason {
|
||||
Some(ref r) => format!("use of unstable library feature '{}': {}",
|
||||
&feature, &r),
|
||||
&feature.as_str(), &r),
|
||||
None => format!("use of unstable library feature '{}'", &feature)
|
||||
};
|
||||
emit_feature_err(&self.tcx.sess.parse_sess, &feature, span,
|
||||
emit_feature_err(&self.tcx.sess.parse_sess, &feature.as_str(), span,
|
||||
GateIssue::Library(Some(issue)), &msg);
|
||||
}
|
||||
}
|
||||
|
|
@ -455,7 +455,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||
// When compiling with --test we don't enforce stability on the
|
||||
// compiler-generated test module, demarcated with `DUMMY_SP` plus the
|
||||
// name `__test`
|
||||
if item.span == DUMMY_SP && item.name.as_str() == "__test" { return }
|
||||
if item.span == DUMMY_SP && item.name == "__test" { return }
|
||||
|
||||
check_item(self.tcx, item, true,
|
||||
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
|
||||
|
|
@ -735,10 +735,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
|||
/// were expected to be library features), and the list of features used from
|
||||
/// libraries, identify activated features that don't exist and error about them.
|
||||
pub fn check_unused_or_stable_features(sess: &Session,
|
||||
lib_features_used: &FxHashMap<InternedString,
|
||||
lib_features_used: &FxHashMap<Symbol,
|
||||
attr::StabilityLevel>) {
|
||||
let ref declared_lib_features = sess.features.borrow().declared_lib_features;
|
||||
let mut remaining_lib_features: FxHashMap<InternedString, Span>
|
||||
let mut remaining_lib_features: FxHashMap<Symbol, Span>
|
||||
= declared_lib_features.clone().into_iter().collect();
|
||||
|
||||
fn format_stable_since_msg(version: &str) -> String {
|
||||
|
|
@ -746,7 +746,7 @@ pub fn check_unused_or_stable_features(sess: &Session,
|
|||
}
|
||||
|
||||
for &(ref stable_lang_feature, span) in &sess.features.borrow().declared_stable_lang_features {
|
||||
let version = find_lang_feature_accepted_version(stable_lang_feature.deref())
|
||||
let version = find_lang_feature_accepted_version(&stable_lang_feature.as_str())
|
||||
.expect("unexpectedly couldn't find version feature was stabilized");
|
||||
sess.add_lint(lint::builtin::STABLE_FEATURES,
|
||||
ast::CRATE_NODE_ID,
|
||||
|
|
@ -761,7 +761,7 @@ pub fn check_unused_or_stable_features(sess: &Session,
|
|||
sess.add_lint(lint::builtin::STABLE_FEATURES,
|
||||
ast::CRATE_NODE_ID,
|
||||
span,
|
||||
format_stable_since_msg(version.deref()));
|
||||
format_stable_since_msg(&version.as_str()));
|
||||
}
|
||||
}
|
||||
None => ( /* used but undeclared, handled during the previous ast visit */ )
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use middle::lang_items;
|
|||
|
||||
use rustc_back::PanicStrategy;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::Visitor;
|
||||
use hir::intravisit;
|
||||
|
|
@ -55,10 +55,10 @@ pub fn check_crate(krate: &hir::Crate,
|
|||
verify(sess, items);
|
||||
}
|
||||
|
||||
pub fn link_name(attrs: &[ast::Attribute]) -> Option<InternedString> {
|
||||
pub fn link_name(attrs: &[ast::Attribute]) -> Option<Symbol> {
|
||||
lang_items::extract(attrs).and_then(|name| {
|
||||
$(if &name[..] == stringify!($name) {
|
||||
Some(InternedString::new(stringify!($sym)))
|
||||
$(if name == stringify!($name) {
|
||||
Some(Symbol::intern(stringify!($sym)))
|
||||
} else)* {
|
||||
None
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ impl<'a> Context<'a> {
|
|||
impl<'a, 'v> Visitor<'v> for Context<'a> {
|
||||
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
|
||||
if let Some(lang_item) = lang_items::extract(&i.attrs) {
|
||||
self.register(&lang_item, i.span);
|
||||
self.register(&lang_item.as_str(), i.span);
|
||||
}
|
||||
intravisit::walk_foreign_item(self, i)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ use lint;
|
|||
use middle::cstore;
|
||||
|
||||
use syntax::ast::{self, IntTy, UintTy};
|
||||
use syntax::attr;
|
||||
use syntax::parse;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
|
||||
use errors::{ColorConfig, FatalError, Handler};
|
||||
|
|
@ -41,6 +40,7 @@ use std::collections::btree_map::Values as BTreeMapValuesIter;
|
|||
use std::fmt;
|
||||
use std::hash::Hasher;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::HashSet;
|
||||
use std::iter::FromIterator;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
|
@ -927,8 +927,6 @@ pub fn default_lib_output() -> CrateType {
|
|||
}
|
||||
|
||||
pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
||||
use syntax::parse::token::intern_and_get_ident as intern;
|
||||
|
||||
let end = &sess.target.target.target_endian;
|
||||
let arch = &sess.target.target.arch;
|
||||
let wordsz = &sess.target.target.target_pointer_width;
|
||||
|
|
@ -938,55 +936,46 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||
let max_atomic_width = sess.target.target.max_atomic_width();
|
||||
|
||||
let fam = if let Some(ref fam) = sess.target.target.options.target_family {
|
||||
intern(fam)
|
||||
Symbol::intern(fam)
|
||||
} else if sess.target.target.options.is_like_windows {
|
||||
InternedString::new("windows")
|
||||
Symbol::intern("windows")
|
||||
} else {
|
||||
InternedString::new("unix")
|
||||
Symbol::intern("unix")
|
||||
};
|
||||
|
||||
let mk = attr::mk_name_value_item_str;
|
||||
let mut ret = vec![ // Target bindings.
|
||||
mk(InternedString::new("target_os"), intern(os)),
|
||||
mk(InternedString::new("target_family"), fam.clone()),
|
||||
mk(InternedString::new("target_arch"), intern(arch)),
|
||||
mk(InternedString::new("target_endian"), intern(end)),
|
||||
mk(InternedString::new("target_pointer_width"), intern(wordsz)),
|
||||
mk(InternedString::new("target_env"), intern(env)),
|
||||
mk(InternedString::new("target_vendor"), intern(vendor)),
|
||||
];
|
||||
match &fam[..] {
|
||||
"windows" | "unix" => ret.push(attr::mk_word_item(fam)),
|
||||
_ => (),
|
||||
let mut ret = HashSet::new();
|
||||
// Target bindings.
|
||||
ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os))));
|
||||
ret.insert((Symbol::intern("target_family"), Some(fam)));
|
||||
ret.insert((Symbol::intern("target_arch"), Some(Symbol::intern(arch))));
|
||||
ret.insert((Symbol::intern("target_endian"), Some(Symbol::intern(end))));
|
||||
ret.insert((Symbol::intern("target_pointer_width"), Some(Symbol::intern(wordsz))));
|
||||
ret.insert((Symbol::intern("target_env"), Some(Symbol::intern(env))));
|
||||
ret.insert((Symbol::intern("target_vendor"), Some(Symbol::intern(vendor))));
|
||||
if fam == "windows" || fam == "unix" {
|
||||
ret.insert((fam, None));
|
||||
}
|
||||
if sess.target.target.options.has_elf_tls {
|
||||
ret.push(attr::mk_word_item(InternedString::new("target_thread_local")));
|
||||
ret.insert((Symbol::intern("target_thread_local"), None));
|
||||
}
|
||||
for &i in &[8, 16, 32, 64, 128] {
|
||||
if i <= max_atomic_width {
|
||||
let s = i.to_string();
|
||||
ret.push(mk(InternedString::new("target_has_atomic"), intern(&s)));
|
||||
ret.insert((Symbol::intern("target_has_atomic"), Some(Symbol::intern(&s))));
|
||||
if &s == wordsz {
|
||||
ret.push(mk(InternedString::new("target_has_atomic"), intern("ptr")));
|
||||
ret.insert((Symbol::intern("target_has_atomic"), Some(Symbol::intern("ptr"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
if sess.opts.debug_assertions {
|
||||
ret.push(attr::mk_word_item(InternedString::new("debug_assertions")));
|
||||
ret.insert((Symbol::intern("debug_assertions"), None));
|
||||
}
|
||||
if sess.opts.crate_types.contains(&CrateTypeProcMacro) {
|
||||
ret.push(attr::mk_word_item(InternedString::new("proc_macro")));
|
||||
ret.insert((Symbol::intern("proc_macro"), None));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub fn append_configuration(cfg: &mut ast::CrateConfig,
|
||||
name: InternedString) {
|
||||
if !cfg.iter().any(|mi| mi.name() == name) {
|
||||
cfg.push(attr::mk_word_item(name))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_configuration(sess: &Session,
|
||||
mut user_cfg: ast::CrateConfig)
|
||||
-> ast::CrateConfig {
|
||||
|
|
@ -995,11 +984,10 @@ pub fn build_configuration(sess: &Session,
|
|||
let default_cfg = default_configuration(sess);
|
||||
// If the user wants a test runner, then add the test cfg
|
||||
if sess.opts.test {
|
||||
append_configuration(&mut user_cfg, InternedString::new("test"))
|
||||
user_cfg.insert((Symbol::intern("test"), None));
|
||||
}
|
||||
let mut v = user_cfg.into_iter().collect::<Vec<_>>();
|
||||
v.extend_from_slice(&default_cfg[..]);
|
||||
v
|
||||
user_cfg.extend(default_cfg.iter().cloned());
|
||||
user_cfg
|
||||
}
|
||||
|
||||
pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
|
||||
|
|
@ -1245,11 +1233,14 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
|
|||
let meta_item = panictry!(parser.parse_meta_item());
|
||||
|
||||
if !parser.reader.is_eof() {
|
||||
early_error(ErrorOutputType::default(), &format!("invalid --cfg argument: {}",
|
||||
s))
|
||||
early_error(ErrorOutputType::default(), &format!("invalid --cfg argument: {}", s))
|
||||
} else if meta_item.is_meta_item_list() {
|
||||
let msg =
|
||||
format!("invalid predicate in --cfg command line argument: `{}`", meta_item.name());
|
||||
early_error(ErrorOutputType::default(), &msg)
|
||||
}
|
||||
|
||||
meta_item
|
||||
(meta_item.name(), meta_item.value_str())
|
||||
}).collect::<ast::CrateConfig>()
|
||||
}
|
||||
|
||||
|
|
@ -1773,9 +1764,7 @@ mod tests {
|
|||
use std::rc::Rc;
|
||||
use super::{OutputType, OutputTypes, Externs};
|
||||
use rustc_back::PanicStrategy;
|
||||
use syntax::{ast, attr};
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::codemap::dummy_spanned;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
fn optgroups() -> Vec<OptGroup> {
|
||||
super::rustc_optgroups().into_iter()
|
||||
|
|
@ -1804,9 +1793,7 @@ mod tests {
|
|||
let (sessopts, cfg) = build_session_options_and_crate_config(matches);
|
||||
let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore));
|
||||
let cfg = build_configuration(&sess, cfg);
|
||||
assert!(attr::contains(&cfg, &dummy_spanned(ast::MetaItemKind::Word({
|
||||
InternedString::new("test")
|
||||
}))));
|
||||
assert!(cfg.contains(&(Symbol::intern("test"), None)));
|
||||
}
|
||||
|
||||
// When the user supplies --test and --cfg test, don't implicitly add
|
||||
|
|
@ -1827,7 +1814,7 @@ mod tests {
|
|||
let sess = build_session(sessopts, &dep_graph, None, registry,
|
||||
Rc::new(DummyCrateStore));
|
||||
let cfg = build_configuration(&sess, cfg);
|
||||
let mut test_items = cfg.iter().filter(|m| m.name() == "test");
|
||||
let mut test_items = cfg.iter().filter(|&&(name, _)| name == "test");
|
||||
assert!(test_items.next().is_some());
|
||||
assert!(test_items.next().is_none());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use syntax::json::JsonEmitter;
|
|||
use syntax::feature_gate;
|
||||
use syntax::parse;
|
||||
use syntax::parse::ParseSess;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::feature_gate::AttributeType;
|
||||
use syntax_pos::{Span, MultiSpan};
|
||||
|
|
@ -89,7 +89,7 @@ pub struct Session {
|
|||
// forms a unique global identifier for the crate. It is used to allow
|
||||
// multiple crates with the same name to coexist. See the
|
||||
// trans::back::symbol_names module for more information.
|
||||
pub crate_disambiguator: RefCell<token::InternedString>,
|
||||
pub crate_disambiguator: RefCell<Symbol>,
|
||||
pub features: RefCell<feature_gate::Features>,
|
||||
|
||||
/// The maximum recursion limit for potentially infinitely recursive
|
||||
|
|
@ -129,8 +129,8 @@ pub struct PerfStats {
|
|||
}
|
||||
|
||||
impl Session {
|
||||
pub fn local_crate_disambiguator(&self) -> token::InternedString {
|
||||
self.crate_disambiguator.borrow().clone()
|
||||
pub fn local_crate_disambiguator(&self) -> Symbol {
|
||||
*self.crate_disambiguator.borrow()
|
||||
}
|
||||
pub fn struct_span_warn<'a, S: Into<MultiSpan>>(&'a self,
|
||||
sp: S,
|
||||
|
|
@ -610,7 +610,7 @@ pub fn build_session_(sopts: config::Options,
|
|||
plugin_attributes: RefCell::new(Vec::new()),
|
||||
crate_types: RefCell::new(Vec::new()),
|
||||
dependency_formats: RefCell::new(FxHashMap()),
|
||||
crate_disambiguator: RefCell::new(token::intern("").as_str()),
|
||||
crate_disambiguator: RefCell::new(Symbol::intern("")),
|
||||
features: RefCell::new(feature_gate::Features::new()),
|
||||
recursion_limit: Cell::new(64),
|
||||
next_node_id: Cell::new(NodeId::new(1)),
|
||||
|
|
|
|||
|
|
@ -246,12 +246,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let err_sp = item.meta().span.substitute_dummy(span);
|
||||
let def = self.tcx.lookup_trait_def(trait_ref.def_id);
|
||||
let trait_str = def.trait_ref.to_string();
|
||||
if let Some(ref istring) = item.value_str() {
|
||||
if let Some(istring) = item.value_str() {
|
||||
let istring = &*istring.as_str();
|
||||
let generic_map = def.generics.types.iter().map(|param| {
|
||||
(param.name.as_str().to_string(),
|
||||
trait_ref.substs.type_for_def(param).to_string())
|
||||
}).collect::<FxHashMap<String, String>>();
|
||||
let parser = Parser::new(&istring);
|
||||
let parser = Parser::new(istring);
|
||||
let mut errored = false;
|
||||
let err: String = parser.filter_map(|p| {
|
||||
match p {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ use super::util;
|
|||
use hir::def_id::DefId;
|
||||
use infer::InferOk;
|
||||
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
|
||||
use syntax::parse::token;
|
||||
use syntax::ast;
|
||||
use syntax::symbol::Symbol;
|
||||
use ty::subst::Subst;
|
||||
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
|
||||
use ty::fold::{TypeFoldable, TypeFolder};
|
||||
|
|
@ -1245,7 +1245,7 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
|
|||
let predicate = ty::Binder(ty::ProjectionPredicate { // (1) recreate binder here
|
||||
projection_ty: ty::ProjectionTy {
|
||||
trait_ref: trait_ref,
|
||||
item_name: token::intern(FN_OUTPUT_NAME),
|
||||
item_name: Symbol::intern(FN_OUTPUT_NAME),
|
||||
},
|
||||
ty: ret_type
|
||||
});
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ use std::rc::Rc;
|
|||
use std::iter;
|
||||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
|
||||
use hir;
|
||||
|
||||
|
|
@ -561,7 +561,7 @@ pub struct GlobalCtxt<'tcx> {
|
|||
|
||||
/// The definite name of the current crate after taking into account
|
||||
/// attributes, commandline parameters, etc.
|
||||
pub crate_name: token::InternedString,
|
||||
pub crate_name: Symbol,
|
||||
|
||||
/// Data layout specification for the current target.
|
||||
pub data_layout: TargetDataLayout,
|
||||
|
|
@ -574,7 +574,7 @@ pub struct GlobalCtxt<'tcx> {
|
|||
|
||||
/// Map from function to the `#[derive]` mode that it's defining. Only used
|
||||
/// by `proc-macro` crates.
|
||||
pub derive_macros: RefCell<NodeMap<token::InternedString>>,
|
||||
pub derive_macros: RefCell<NodeMap<Symbol>>,
|
||||
}
|
||||
|
||||
impl<'tcx> GlobalCtxt<'tcx> {
|
||||
|
|
@ -588,15 +588,15 @@ impl<'tcx> GlobalCtxt<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn crate_name(self, cnum: CrateNum) -> token::InternedString {
|
||||
pub fn crate_name(self, cnum: CrateNum) -> Symbol {
|
||||
if cnum == LOCAL_CRATE {
|
||||
self.crate_name.clone()
|
||||
self.crate_name
|
||||
} else {
|
||||
self.sess.cstore.crate_name(cnum)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn original_crate_name(self, cnum: CrateNum) -> token::InternedString {
|
||||
pub fn original_crate_name(self, cnum: CrateNum) -> Symbol {
|
||||
if cnum == LOCAL_CRATE {
|
||||
self.crate_name.clone()
|
||||
} else {
|
||||
|
|
@ -604,7 +604,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn crate_disambiguator(self, cnum: CrateNum) -> token::InternedString {
|
||||
pub fn crate_disambiguator(self, cnum: CrateNum) -> Symbol {
|
||||
if cnum == LOCAL_CRATE {
|
||||
self.sess.local_crate_disambiguator()
|
||||
} else {
|
||||
|
|
@ -835,7 +835,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
custom_coerce_unsized_kinds: RefCell::new(DefIdMap()),
|
||||
cast_kinds: RefCell::new(NodeMap()),
|
||||
fragment_infos: RefCell::new(DefIdMap()),
|
||||
crate_name: token::intern_and_get_ident(crate_name),
|
||||
crate_name: Symbol::intern(crate_name),
|
||||
data_layout: data_layout,
|
||||
layout_cache: RefCell::new(FxHashMap()),
|
||||
layout_depth: Cell::new(0),
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use hir::map::DefPathData;
|
|||
use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
|
|
@ -94,14 +94,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
if let Some(extern_crate_def_id) = opt_extern_crate {
|
||||
self.push_item_path(buffer, extern_crate_def_id);
|
||||
} else {
|
||||
buffer.push(&self.crate_name(cnum));
|
||||
buffer.push(&self.crate_name(cnum).as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
RootMode::Absolute => {
|
||||
// In absolute mode, just write the crate name
|
||||
// unconditionally.
|
||||
buffer.push(&self.original_crate_name(cnum));
|
||||
buffer.push(&self.original_crate_name(cnum).as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
return true;
|
||||
}
|
||||
None => {
|
||||
buffer.push(&self.crate_name(cur_def.krate));
|
||||
buffer.push(&self.crate_name(cur_def.krate).as_str());
|
||||
cur_path.iter().rev().map(|segment| buffer.push(&segment.as_str())).count();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
cur_path.push(self.sess.cstore.def_key(cur_def)
|
||||
.disambiguated_data.data.get_opt_name().unwrap_or_else(||
|
||||
token::intern("<unnamed>")));
|
||||
Symbol::intern("<unnamed>")));
|
||||
match visible_parent_map.get(&cur_def) {
|
||||
Some(&def) => cur_def = def,
|
||||
None => return false,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ use std::vec::IntoIter;
|
|||
use std::mem;
|
||||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::parse::token::{self, InternedString};
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
|
||||
use rustc_const_math::ConstInt;
|
||||
|
|
@ -2344,7 +2344,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
if let Some(id) = self.map.as_local_node_id(id) {
|
||||
self.map.name(id)
|
||||
} else if id.index == CRATE_DEF_INDEX {
|
||||
token::intern(&self.sess.cstore.original_crate_name(id.krate))
|
||||
self.sess.cstore.original_crate_name(id.krate)
|
||||
} else {
|
||||
let def_key = self.sess.cstore.def_key(id);
|
||||
// The name of a StructCtor is that of its struct parent.
|
||||
|
|
@ -2747,7 +2747,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
/// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
|
||||
/// with the name of the crate containing the impl.
|
||||
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, InternedString> {
|
||||
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
|
||||
if impl_did.is_local() {
|
||||
let node_id = self.map.as_local_node_id(impl_did).unwrap();
|
||||
Ok(self.map.span(node_id))
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use std::fmt;
|
|||
use std::ops;
|
||||
use syntax::abi;
|
||||
use syntax::ast::{self, Name};
|
||||
use syntax::parse::token::{keywords, InternedString};
|
||||
use syntax::symbol::{keywords, InternedString};
|
||||
|
||||
use serialize;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ use std::fmt;
|
|||
use std::usize;
|
||||
|
||||
use syntax::abi::Abi;
|
||||
use syntax::parse::token;
|
||||
use syntax::ast::CRATE_NODE_ID;
|
||||
use syntax::symbol::Symbol;
|
||||
use hir;
|
||||
|
||||
pub fn verbose() -> bool {
|
||||
|
|
@ -284,7 +284,7 @@ fn in_binder<'a, 'gcx, 'tcx, T, U>(f: &mut fmt::Formatter,
|
|||
ty::BrAnon(_) |
|
||||
ty::BrFresh(_) |
|
||||
ty::BrEnv => {
|
||||
let name = token::intern("'r");
|
||||
let name = Symbol::intern("'r");
|
||||
let _ = write!(f, "{}", name);
|
||||
ty::BrNamed(tcx.map.local_def_id(CRATE_NODE_ID),
|
||||
name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue