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
|
|
@ -34,8 +34,9 @@ use syntax::codemap::Span;
|
|||
use syntax::ext::base::*;
|
||||
use syntax::ext::base;
|
||||
use syntax::ext::proc_macro_shim::build_block_emitter;
|
||||
use syntax::parse::token::{self, Token, gensym_ident, str_to_ident};
|
||||
use syntax::parse::token::{self, Token};
|
||||
use syntax::print::pprust;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::tokenstream::{TokenTree, TokenStream};
|
||||
|
||||
// ____________________________________________________________________________________________
|
||||
|
|
@ -124,7 +125,7 @@ fn qquote_iter<'cx>(cx: &'cx mut ExtCtxt, depth: i64, ts: TokenStream) -> (Bindi
|
|||
} // produce an error or something first
|
||||
let exp = vec![exp.unwrap().to_owned()];
|
||||
debug!("RHS: {:?}", exp.clone());
|
||||
let new_id = gensym_ident("tmp");
|
||||
let new_id = Ident::with_empty_ctxt(Symbol::gensym("tmp"));
|
||||
debug!("RHS TS: {:?}", TokenStream::from_tts(exp.clone()));
|
||||
debug!("RHS TS TT: {:?}", TokenStream::from_tts(exp.clone()).to_vec());
|
||||
bindings.push((new_id, TokenStream::from_tts(exp)));
|
||||
|
|
@ -179,7 +180,7 @@ fn unravel_concats(tss: Vec<TokenStream>) -> TokenStream {
|
|||
};
|
||||
|
||||
while let Some(ts) = pushes.pop() {
|
||||
output = build_fn_call(str_to_ident("concat"),
|
||||
output = build_fn_call(Ident::from_str("concat"),
|
||||
concat(concat(ts,
|
||||
from_tokens(vec![Token::Comma])),
|
||||
output));
|
||||
|
|
@ -209,18 +210,19 @@ fn convert_complex_tts<'cx>(cx: &'cx mut ExtCtxt, tts: Vec<QTT>) -> (Bindings, T
|
|||
// FIXME handle sequence repetition tokens
|
||||
QTT::QDL(qdl) => {
|
||||
debug!(" QDL: {:?} ", qdl.tts);
|
||||
let new_id = gensym_ident("qdl_tmp");
|
||||
let new_id = Ident::with_empty_ctxt(Symbol::gensym("qdl_tmp"));
|
||||
let mut cct_rec = convert_complex_tts(cx, qdl.tts);
|
||||
bindings.append(&mut cct_rec.0);
|
||||
bindings.push((new_id, cct_rec.1));
|
||||
|
||||
let sep = build_delim_tok(qdl.delim);
|
||||
|
||||
pushes.push(build_mod_call(vec![str_to_ident("proc_macro_tokens"),
|
||||
str_to_ident("build"),
|
||||
str_to_ident("build_delimited")],
|
||||
concat(from_tokens(vec![Token::Ident(new_id)]),
|
||||
concat(lex(","), sep))));
|
||||
pushes.push(build_mod_call(
|
||||
vec![Ident::from_str("proc_macro_tokens"),
|
||||
Ident::from_str("build"),
|
||||
Ident::from_str("build_delimited")],
|
||||
concat(from_tokens(vec![Token::Ident(new_id)]), concat(lex(","), sep)),
|
||||
));
|
||||
}
|
||||
QTT::QIdent(t) => {
|
||||
pushes.push(TokenStream::from_tts(vec![t]));
|
||||
|
|
@ -250,13 +252,13 @@ fn unravel(binds: Bindings) -> TokenStream {
|
|||
|
||||
/// Checks if the Ident is `unquote`.
|
||||
fn is_unquote(id: Ident) -> bool {
|
||||
let qq = str_to_ident("unquote");
|
||||
let qq = Ident::from_str("unquote");
|
||||
id.name == qq.name // We disregard context; unquote is _reserved_
|
||||
}
|
||||
|
||||
/// Checks if the Ident is `quote`.
|
||||
fn is_qquote(id: Ident) -> bool {
|
||||
let qq = str_to_ident("qquote");
|
||||
let qq = Ident::from_str("qquote");
|
||||
id.name == qq.name // We disregard context; qquote is _reserved_
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +268,8 @@ mod int_build {
|
|||
|
||||
use syntax::ast::{self, Ident};
|
||||
use syntax::codemap::{DUMMY_SP};
|
||||
use syntax::parse::token::{self, Token, keywords, str_to_ident};
|
||||
use syntax::parse::token::{self, Token, Lit};
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::tokenstream::{TokenTree, TokenStream};
|
||||
|
||||
// ____________________________________________________________________________________________
|
||||
|
|
@ -277,19 +280,19 @@ mod int_build {
|
|||
build_paren_delimited(build_vec(build_token_tt(t))))
|
||||
}
|
||||
|
||||
pub fn emit_lit(l: token::Lit, n: Option<ast::Name>) -> TokenStream {
|
||||
pub fn emit_lit(l: Lit, n: Option<ast::Name>) -> TokenStream {
|
||||
let suf = match n {
|
||||
Some(n) => format!("Some(ast::Name({}))", n.0),
|
||||
Some(n) => format!("Some(ast::Name({}))", n.as_u32()),
|
||||
None => "None".to_string(),
|
||||
};
|
||||
|
||||
let lit = match l {
|
||||
token::Lit::Byte(n) => format!("Lit::Byte(token::intern(\"{}\"))", n.to_string()),
|
||||
token::Lit::Char(n) => format!("Lit::Char(token::intern(\"{}\"))", n.to_string()),
|
||||
token::Lit::Integer(n) => format!("Lit::Integer(token::intern(\"{}\"))", n.to_string()),
|
||||
token::Lit::Float(n) => format!("Lit::Float(token::intern(\"{}\"))", n.to_string()),
|
||||
token::Lit::Str_(n) => format!("Lit::Str_(token::intern(\"{}\"))", n.to_string()),
|
||||
token::Lit::ByteStr(n) => format!("Lit::ByteStr(token::intern(\"{}\"))", n.to_string()),
|
||||
Lit::Byte(n) => format!("Lit::Byte(Symbol::intern(\"{}\"))", n.to_string()),
|
||||
Lit::Char(n) => format!("Lit::Char(Symbol::intern(\"{}\"))", n.to_string()),
|
||||
Lit::Float(n) => format!("Lit::Float(Symbol::intern(\"{}\"))", n.to_string()),
|
||||
Lit::Str_(n) => format!("Lit::Str_(Symbol::intern(\"{}\"))", n.to_string()),
|
||||
Lit::Integer(n) => format!("Lit::Integer(Symbol::intern(\"{}\"))", n.to_string()),
|
||||
Lit::ByteStr(n) => format!("Lit::ByteStr(Symbol::intern(\"{}\"))", n.to_string()),
|
||||
_ => panic!("Unsupported literal"),
|
||||
};
|
||||
|
||||
|
|
@ -388,9 +391,10 @@ mod int_build {
|
|||
Token::Underscore => lex("_"),
|
||||
Token::Literal(lit, sfx) => emit_lit(lit, sfx),
|
||||
// fix ident expansion information... somehow
|
||||
Token::Ident(ident) => lex(&format!("Token::Ident(str_to_ident(\"{}\"))", ident.name)),
|
||||
Token::Lifetime(ident) => lex(&format!("Token::Ident(str_to_ident(\"{}\"))",
|
||||
ident.name)),
|
||||
Token::Ident(ident) =>
|
||||
lex(&format!("Token::Ident(Ident::from_str(\"{}\"))", ident.name)),
|
||||
Token::Lifetime(ident) =>
|
||||
lex(&format!("Token::Ident(Ident::from_str(\"{}\"))", ident.name)),
|
||||
_ => panic!("Unhandled case!"),
|
||||
}
|
||||
}
|
||||
|
|
@ -408,7 +412,7 @@ mod int_build {
|
|||
|
||||
/// Takes `input` and returns `vec![input]`.
|
||||
pub fn build_vec(ts: TokenStream) -> TokenStream {
|
||||
build_mac_call(str_to_ident("vec"), ts)
|
||||
build_mac_call(Ident::from_str("vec"), ts)
|
||||
// tts.clone().to_owned()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ extern crate syntax_pos;
|
|||
|
||||
use syntax::ast::Ident;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::parse::token::{self, Token, keywords, str_to_ident};
|
||||
use syntax::parse::token::{self, Token};
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::tokenstream::{self, TokenTree, TokenStream};
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
@ -43,13 +44,13 @@ pub fn ident_eq(tident: &TokenTree, id: Ident) -> bool {
|
|||
|
||||
/// Convert a `&str` into a Token.
|
||||
pub fn str_to_token_ident(s: &str) -> Token {
|
||||
Token::Ident(str_to_ident(s))
|
||||
Token::Ident(Ident::from_str(s))
|
||||
}
|
||||
|
||||
/// Converts a keyword (from `syntax::parse::token::keywords`) into a Token that
|
||||
/// corresponds to it.
|
||||
pub fn keyword_to_token_ident(kw: keywords::Keyword) -> Token {
|
||||
Token::Ident(str_to_ident(&kw.name().as_str()[..]))
|
||||
Token::Ident(Ident::from_str(&kw.name().as_str()[..]))
|
||||
}
|
||||
|
||||
// ____________________________________________________________________________________________
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ fn is_rustc_peek<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
{
|
||||
let name = tcx.item_name(def_id);
|
||||
if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
|
||||
if name.as_str() == "rustc_peek" {
|
||||
if name == "rustc_peek" {
|
||||
return Some((args, source_info.span));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
use borrowck::BorrowckCtxt;
|
||||
|
||||
use syntax::ast::{self, MetaItem};
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
use rustc::hir;
|
||||
|
|
@ -35,7 +34,7 @@ use self::dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
|
|||
use self::dataflow::{DefinitelyInitializedLvals};
|
||||
use self::gather_moves::{MoveData, MovePathIndex, LookupResult};
|
||||
|
||||
fn has_rustc_mir_with(attrs: &[ast::Attribute], name: &str) -> Option<P<MetaItem>> {
|
||||
fn has_rustc_mir_with(attrs: &[ast::Attribute], name: &str) -> Option<MetaItem> {
|
||||
for attr in attrs {
|
||||
if attr.check_name("rustc_mir") {
|
||||
let items = attr.meta_item_list();
|
||||
|
|
|
|||
|
|
@ -1221,7 +1221,7 @@ fn lit_to_const<'a, 'tcx>(lit: &ast::LitKind,
|
|||
use syntax::ast::*;
|
||||
use syntax::ast::LitIntType::*;
|
||||
match *lit {
|
||||
LitKind::Str(ref s, _) => Ok(Str((*s).clone())),
|
||||
LitKind::Str(ref s, _) => Ok(Str(s.as_str())),
|
||||
LitKind::ByteStr(ref data) => Ok(ByteStr(data.clone())),
|
||||
LitKind::Byte(n) => Ok(Integral(U8(n))),
|
||||
LitKind::Int(n, Signed(ity)) => {
|
||||
|
|
@ -1249,15 +1249,15 @@ fn lit_to_const<'a, 'tcx>(lit: &ast::LitKind,
|
|||
infer(Infer(n), tcx, &ty::TyUint(ity)).map(Integral)
|
||||
},
|
||||
|
||||
LitKind::Float(ref n, fty) => {
|
||||
parse_float(n, Some(fty)).map(Float)
|
||||
LitKind::Float(n, fty) => {
|
||||
parse_float(&n.as_str(), Some(fty)).map(Float)
|
||||
}
|
||||
LitKind::FloatUnsuffixed(ref n) => {
|
||||
LitKind::FloatUnsuffixed(n) => {
|
||||
let fty_hint = match ty_hint.map(|t| &t.sty) {
|
||||
Some(&ty::TyFloat(fty)) => Some(fty),
|
||||
_ => None
|
||||
};
|
||||
parse_float(n, fty_hint).map(Float)
|
||||
parse_float(&n.as_str(), fty_hint).map(Float)
|
||||
}
|
||||
LitKind::Bool(b) => Ok(Bool(b)),
|
||||
LitKind::Char(c) => Ok(Char(c)),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ use std::path::{Path, PathBuf};
|
|||
use syntax::{ast, diagnostics, visit};
|
||||
use syntax::attr;
|
||||
use syntax::ext::base::ExtCtxt;
|
||||
use syntax::parse::{self, PResult, token};
|
||||
use syntax::parse::{self, PResult};
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::util::node_count::NodeCounter;
|
||||
use syntax;
|
||||
use syntax_ext;
|
||||
|
|
@ -210,9 +211,6 @@ pub fn compile_input(sess: &Session,
|
|||
tcx.print_debug_stats();
|
||||
}
|
||||
|
||||
// Discard interned strings as they are no longer required.
|
||||
token::clear_ident_interner();
|
||||
|
||||
Ok((outputs, trans))
|
||||
})??
|
||||
};
|
||||
|
|
@ -563,8 +561,7 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
|
|||
*sess.features.borrow_mut() = features;
|
||||
|
||||
*sess.crate_types.borrow_mut() = collect_crate_types(sess, &krate.attrs);
|
||||
*sess.crate_disambiguator.borrow_mut() =
|
||||
token::intern(&compute_crate_disambiguator(sess)).as_str();
|
||||
*sess.crate_disambiguator.borrow_mut() = Symbol::intern(&compute_crate_disambiguator(sess));
|
||||
|
||||
time(time_passes, "recursion limit", || {
|
||||
middle::recursion_limit::update_recursion_limit(sess, &krate);
|
||||
|
|
@ -1107,7 +1104,7 @@ pub fn phase_6_link_output(sess: &Session,
|
|||
outputs: &OutputFilenames) {
|
||||
time(sess.time_passes(),
|
||||
"linking",
|
||||
|| link::link_binary(sess, trans, outputs, &trans.link.crate_name));
|
||||
|| link::link_binary(sess, trans, outputs, &trans.link.crate_name.as_str()));
|
||||
}
|
||||
|
||||
fn escape_dep_filename(filename: &str) -> String {
|
||||
|
|
@ -1358,11 +1355,3 @@ pub fn build_output_filenames(input: &Input,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For use by the `rusti` project (https://github.com/murarth/rusti).
|
||||
pub fn reset_thread_local_state() {
|
||||
// These may be left in an incoherent state after a previous compile.
|
||||
syntax::ext::hygiene::reset_hygiene_data();
|
||||
// `clear_ident_interner` can be used to free memory, but it does not restore the initial state.
|
||||
token::reset_ident_interner();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,12 +95,11 @@ use std::str;
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
|
||||
use syntax::{ast, json};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
|
||||
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
|
||||
use syntax::parse::{self, PResult};
|
||||
use syntax_pos::MultiSpan;
|
||||
use errors::emitter::Emitter;
|
||||
use syntax_pos::{DUMMY_SP, MultiSpan};
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test;
|
||||
|
|
@ -374,37 +373,11 @@ fn handle_explain(code: &str,
|
|||
}
|
||||
}
|
||||
|
||||
fn check_cfg(cfg: &ast::CrateConfig,
|
||||
output: ErrorOutputType) {
|
||||
let emitter: Box<Emitter> = match output {
|
||||
config::ErrorOutputType::HumanReadable(color_config) => {
|
||||
Box::new(errors::emitter::EmitterWriter::stderr(color_config, None))
|
||||
}
|
||||
config::ErrorOutputType::Json => Box::new(json::JsonEmitter::basic()),
|
||||
};
|
||||
let handler = errors::Handler::with_emitter(true, false, emitter);
|
||||
|
||||
let mut saw_invalid_predicate = false;
|
||||
for item in cfg.iter() {
|
||||
if item.is_meta_item_list() {
|
||||
saw_invalid_predicate = true;
|
||||
handler.emit(&MultiSpan::new(),
|
||||
&format!("invalid predicate in --cfg command line argument: `{}`",
|
||||
item.name()),
|
||||
errors::Level::Fatal);
|
||||
}
|
||||
}
|
||||
|
||||
if saw_invalid_predicate {
|
||||
panic!(errors::FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
||||
fn early_callback(&mut self,
|
||||
matches: &getopts::Matches,
|
||||
_: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
_: &ast::CrateConfig,
|
||||
descriptions: &errors::registry::Registry,
|
||||
output: ErrorOutputType)
|
||||
-> Compilation {
|
||||
|
|
@ -413,7 +386,6 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
|||
return Compilation::Stop;
|
||||
}
|
||||
|
||||
check_cfg(cfg, output);
|
||||
Compilation::Continue
|
||||
}
|
||||
|
||||
|
|
@ -640,24 +612,27 @@ impl RustcDefaultCalls {
|
|||
let allow_unstable_cfg = UnstableFeatures::from_environment()
|
||||
.is_nightly_build();
|
||||
|
||||
for cfg in &sess.parse_sess.config {
|
||||
if !allow_unstable_cfg && GatedCfg::gate(cfg).is_some() {
|
||||
let mut cfgs = Vec::new();
|
||||
for &(name, ref value) in sess.parse_sess.config.iter() {
|
||||
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
|
||||
name: name,
|
||||
node: ast::MetaItemKind::Word,
|
||||
span: DUMMY_SP,
|
||||
});
|
||||
if !allow_unstable_cfg && gated_cfg.is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if cfg.is_word() {
|
||||
println!("{}", cfg.name());
|
||||
} else if let Some(s) = cfg.value_str() {
|
||||
println!("{}=\"{}\"", cfg.name(), s);
|
||||
} else if cfg.is_meta_item_list() {
|
||||
// Right now there are not and should not be any
|
||||
// MetaItemKind::List items in the configuration returned by
|
||||
// `build_configuration`.
|
||||
panic!("Found an unexpected list in cfg attribute '{}'!", cfg.name())
|
||||
cfgs.push(if let &Some(ref value) = value {
|
||||
format!("{}=\"{}\"", name, value)
|
||||
} else {
|
||||
// There also shouldn't be literals.
|
||||
panic!("Found an unexpected literal in cfg attribute '{}'!", cfg.name())
|
||||
}
|
||||
format!("{}", name)
|
||||
});
|
||||
}
|
||||
|
||||
cfgs.sort();
|
||||
for cfg in cfgs {
|
||||
println!("{}", cfg);
|
||||
}
|
||||
}
|
||||
PrintRequest::TargetCPUs => {
|
||||
|
|
|
|||
|
|
@ -450,15 +450,15 @@ impl<'ast> PrinterSupport<'ast> for HygieneAnnotation<'ast> {
|
|||
impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> {
|
||||
fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
|
||||
match node {
|
||||
pprust::NodeIdent(&ast::Ident { name: ast::Name(nm), ctxt }) => {
|
||||
pprust::NodeIdent(&ast::Ident { name, ctxt }) => {
|
||||
pp::space(&mut s.s)?;
|
||||
// FIXME #16420: this doesn't display the connections
|
||||
// between syntax contexts
|
||||
s.synth_comment(format!("{}{:?}", nm, ctxt))
|
||||
s.synth_comment(format!("{}{:?}", name.as_u32(), ctxt))
|
||||
}
|
||||
pprust::NodeName(&ast::Name(nm)) => {
|
||||
pprust::NodeName(&name) => {
|
||||
pp::space(&mut s.s)?;
|
||||
s.synth_comment(nm.to_string())
|
||||
s.synth_comment(name.as_u32().to_string())
|
||||
}
|
||||
_ => Ok(()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use syntax::{ast, attr};
|
||||
use syntax::ast;
|
||||
use llvm::LLVMRustHasFeature;
|
||||
use rustc::session::Session;
|
||||
use rustc_trans::back::write::create_target_machine;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::parse::token::intern_and_get_ident as intern;
|
||||
use syntax::symbol::Symbol;
|
||||
use libc::c_char;
|
||||
|
||||
// WARNING: the features must be known to LLVM or the feature
|
||||
|
|
@ -41,11 +40,11 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) {
|
|||
_ => &[],
|
||||
};
|
||||
|
||||
let tf = InternedString::new("target_feature");
|
||||
let tf = Symbol::intern("target_feature");
|
||||
for feat in whitelist {
|
||||
assert_eq!(feat.chars().last(), Some('\0'));
|
||||
if unsafe { LLVMRustHasFeature(target_machine, feat.as_ptr() as *const c_char) } {
|
||||
cfg.push(attr::mk_name_value_item_str(tf.clone(), intern(&feat[..feat.len() - 1])))
|
||||
cfg.insert((tf, Some(Symbol::intern(&feat[..feat.len() - 1]))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +73,6 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) {
|
|||
}
|
||||
|
||||
if crt_static {
|
||||
cfg.push(attr::mk_name_value_item_str(tf.clone(), intern("crt-static")));
|
||||
cfg.insert((tf, Some(Symbol::intern("crt-static"))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ use syntax::codemap::CodeMap;
|
|||
use errors;
|
||||
use errors::emitter::Emitter;
|
||||
use errors::{Level, DiagnosticBuilder};
|
||||
use syntax::parse::token;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
|
@ -288,11 +288,11 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn t_param(&self, index: u32) -> Ty<'tcx> {
|
||||
let name = format!("T{}", index);
|
||||
self.infcx.tcx.mk_param(index, token::intern(&name[..]))
|
||||
self.infcx.tcx.mk_param(index, Symbol::intern(&name[..]))
|
||||
}
|
||||
|
||||
pub fn re_early_bound(&self, index: u32, name: &'static str) -> &'tcx ty::Region {
|
||||
let name = token::intern(name);
|
||||
let name = Symbol::intern(name);
|
||||
self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
index: index,
|
||||
name: name,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ use std::env;
|
|||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax_pos::Span;
|
||||
use {ATTR_IF_THIS_CHANGED, ATTR_THEN_THIS_WOULD_NEED};
|
||||
|
||||
|
|
@ -97,7 +96,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
|||
}
|
||||
|
||||
type Sources = Vec<(Span, DefId, DepNode<DefId>)>;
|
||||
type Targets = Vec<(Span, InternedString, ast::NodeId, DepNode<DefId>)>;
|
||||
type Targets = Vec<(Span, ast::Name, ast::NodeId, DepNode<DefId>)>;
|
||||
|
||||
struct IfThisChanged<'a, 'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
|
@ -106,7 +105,7 @@ struct IfThisChanged<'a, 'tcx:'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||
fn argument(&self, attr: &ast::Attribute) -> Option<InternedString> {
|
||||
fn argument(&self, attr: &ast::Attribute) -> Option<ast::Name> {
|
||||
let mut value = None;
|
||||
for list_item in attr.meta_item_list().unwrap_or_default() {
|
||||
match list_item.word() {
|
||||
|
|
@ -127,8 +126,8 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
|||
let dep_node_interned = self.argument(attr);
|
||||
let dep_node = match dep_node_interned {
|
||||
None => DepNode::Hir(def_id),
|
||||
Some(ref n) => {
|
||||
match DepNode::from_label_string(&n[..], def_id) {
|
||||
Some(n) => {
|
||||
match DepNode::from_label_string(&n.as_str(), def_id) {
|
||||
Ok(n) => n,
|
||||
Err(()) => {
|
||||
self.tcx.sess.span_fatal(
|
||||
|
|
@ -142,8 +141,8 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
|||
} else if attr.check_name(ATTR_THEN_THIS_WOULD_NEED) {
|
||||
let dep_node_interned = self.argument(attr);
|
||||
let dep_node = match dep_node_interned {
|
||||
Some(ref n) => {
|
||||
match DepNode::from_label_string(&n[..], def_id) {
|
||||
Some(n) => {
|
||||
match DepNode::from_label_string(&n.as_str(), def_id) {
|
||||
Ok(n) => n,
|
||||
Err(()) => {
|
||||
self.tcx.sess.span_fatal(
|
||||
|
|
@ -159,7 +158,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
self.then_this_would_need.push((attr.span,
|
||||
dep_node_interned.clone().unwrap(),
|
||||
dep_node_interned.unwrap(),
|
||||
node_id,
|
||||
dep_node));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,8 +172,8 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
|
|||
|
||||
let crate_disambiguator = self.tcx.sess.local_crate_disambiguator();
|
||||
"crate_disambiguator".hash(&mut crate_state);
|
||||
crate_disambiguator.len().hash(&mut crate_state);
|
||||
crate_disambiguator.hash(&mut crate_state);
|
||||
crate_disambiguator.as_str().len().hash(&mut crate_state);
|
||||
crate_disambiguator.as_str().hash(&mut crate_state);
|
||||
|
||||
// add each item (in some deterministic order) to the overall
|
||||
// crate hash.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use syntax::abi::Abi;
|
|||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use syntax_pos::{Span, NO_EXPANSION, COMMAND_LINE_EXPN, BytePos};
|
||||
use syntax::tokenstream;
|
||||
use rustc::hir;
|
||||
|
|
@ -169,8 +170,8 @@ enum SawAbiComponent<'a> {
|
|||
|
||||
// FIXME (#14132): should we include (some function of)
|
||||
// ident.ctxt as well?
|
||||
SawIdent(token::InternedString),
|
||||
SawStructDef(token::InternedString),
|
||||
SawIdent(InternedString),
|
||||
SawStructDef(InternedString),
|
||||
|
||||
SawLifetime,
|
||||
SawLifetimeDef(usize),
|
||||
|
|
@ -232,11 +233,11 @@ enum SawAbiComponent<'a> {
|
|||
#[derive(Hash)]
|
||||
enum SawExprComponent<'a> {
|
||||
|
||||
SawExprLoop(Option<token::InternedString>),
|
||||
SawExprField(token::InternedString),
|
||||
SawExprLoop(Option<InternedString>),
|
||||
SawExprField(InternedString),
|
||||
SawExprTupField(usize),
|
||||
SawExprBreak(Option<token::InternedString>),
|
||||
SawExprAgain(Option<token::InternedString>),
|
||||
SawExprBreak(Option<InternedString>),
|
||||
SawExprAgain(Option<InternedString>),
|
||||
|
||||
SawExprBox,
|
||||
SawExprArray,
|
||||
|
|
@ -246,6 +247,8 @@ enum SawExprComponent<'a> {
|
|||
SawExprBinary(hir::BinOp_),
|
||||
SawExprUnary(hir::UnOp),
|
||||
SawExprLit(ast::LitKind),
|
||||
SawExprLitStr(InternedString, ast::StrStyle),
|
||||
SawExprLitFloat(InternedString, Option<ast::FloatTy>),
|
||||
SawExprCast,
|
||||
SawExprType,
|
||||
SawExprIf,
|
||||
|
|
@ -314,7 +317,7 @@ fn saw_expr<'a>(node: &'a Expr_,
|
|||
ExprUnary(op, _) => {
|
||||
(SawExprUnary(op), unop_can_panic_at_runtime(op))
|
||||
}
|
||||
ExprLit(ref lit) => (SawExprLit(lit.node.clone()), false),
|
||||
ExprLit(ref lit) => (saw_lit(lit), false),
|
||||
ExprCast(..) => (SawExprCast, false),
|
||||
ExprType(..) => (SawExprType, false),
|
||||
ExprIf(..) => (SawExprIf, false),
|
||||
|
|
@ -341,6 +344,15 @@ fn saw_expr<'a>(node: &'a Expr_,
|
|||
}
|
||||
}
|
||||
|
||||
fn saw_lit(lit: &ast::Lit) -> SawExprComponent<'static> {
|
||||
match lit.node {
|
||||
ast::LitKind::Str(s, style) => SawExprLitStr(s.as_str(), style),
|
||||
ast::LitKind::Float(s, ty) => SawExprLitFloat(s.as_str(), Some(ty)),
|
||||
ast::LitKind::FloatUnsuffixed(s) => SawExprLitFloat(s.as_str(), None),
|
||||
ref node @ _ => SawExprLit(node.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Hash)]
|
||||
enum SawItemComponent {
|
||||
SawItemExternCrate,
|
||||
|
|
@ -874,22 +886,16 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
|
|||
|
||||
// ignoring span information, it doesn't matter here
|
||||
self.hash_discriminant(&meta_item.node);
|
||||
meta_item.name.as_str().len().hash(self.st);
|
||||
meta_item.name.as_str().hash(self.st);
|
||||
|
||||
match meta_item.node {
|
||||
ast::MetaItemKind::Word(ref s) => {
|
||||
s.len().hash(self.st);
|
||||
s.hash(self.st);
|
||||
}
|
||||
ast::MetaItemKind::NameValue(ref s, ref lit) => {
|
||||
s.len().hash(self.st);
|
||||
s.hash(self.st);
|
||||
lit.node.hash(self.st);
|
||||
}
|
||||
ast::MetaItemKind::List(ref s, ref items) => {
|
||||
s.len().hash(self.st);
|
||||
s.hash(self.st);
|
||||
ast::MetaItemKind::Word => {}
|
||||
ast::MetaItemKind::NameValue(ref lit) => saw_lit(lit).hash(self.st),
|
||||
ast::MetaItemKind::List(ref items) => {
|
||||
// Sort subitems so the hash does not depend on their order
|
||||
let indices = self.indices_sorted_by(&items, |p| {
|
||||
(p.name(), fnv::hash(&p.literal().map(|i| &i.node)))
|
||||
(p.name().map(Symbol::as_str), fnv::hash(&p.literal().map(saw_lit)))
|
||||
});
|
||||
items.len().hash(self.st);
|
||||
for (index, &item_index) in indices.iter().enumerate() {
|
||||
|
|
@ -901,7 +907,7 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
|
|||
self.hash_meta_item(meta_item);
|
||||
}
|
||||
ast::NestedMetaItemKind::Literal(ref lit) => {
|
||||
lit.node.hash(self.st);
|
||||
saw_lit(lit).hash(self.st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -914,11 +920,11 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
|
|||
let indices = self.indices_sorted_by(attributes, |attr| attr.name());
|
||||
|
||||
for i in indices {
|
||||
let attr = &attributes[i].node;
|
||||
let attr = &attributes[i];
|
||||
if !attr.is_sugared_doc &&
|
||||
!IGNORED_ATTRIBUTES.contains(&&*attr.value.name()) {
|
||||
!IGNORED_ATTRIBUTES.contains(&&*attr.value.name().as_str()) {
|
||||
SawAttribute(attr.style).hash(self.st);
|
||||
self.hash_meta_item(&*attr.value);
|
||||
self.hash_meta_item(&attr.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ impl DefIdDirectory {
|
|||
assert_eq!(old_info.krate, krate);
|
||||
let old_name: &str = &old_info.name;
|
||||
let old_disambiguator: &str = &old_info.disambiguator;
|
||||
let new_name: &str = &tcx.crate_name(krate);
|
||||
let new_disambiguator: &str = &tcx.crate_disambiguator(krate);
|
||||
let new_name: &str = &tcx.crate_name(krate).as_str();
|
||||
let new_disambiguator: &str = &tcx.crate_disambiguator(krate).as_str();
|
||||
old_name == new_name && old_disambiguator == new_disambiguator
|
||||
}
|
||||
}
|
||||
|
|
@ -99,8 +99,8 @@ impl DefIdDirectory {
|
|||
let new_krates: HashMap<_, _> =
|
||||
once(LOCAL_CRATE)
|
||||
.chain(tcx.sess.cstore.crates())
|
||||
.map(|krate| (make_key(&tcx.crate_name(krate),
|
||||
&tcx.crate_disambiguator(krate)), krate))
|
||||
.map(|krate| (make_key(&tcx.crate_name(krate).as_str(),
|
||||
&tcx.crate_disambiguator(krate).as_str()), krate))
|
||||
.collect();
|
||||
|
||||
let ids = self.paths.iter()
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use syntax::ast::{self, Attribute, NestedMetaItem};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax_pos::Span;
|
||||
use rustc::ty::TyCtxt;
|
||||
use ich::Fingerprint;
|
||||
|
|
@ -88,12 +87,11 @@ pub struct DirtyCleanVisitor<'a, 'tcx:'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
|
||||
fn dep_node(&self, attr: &Attribute, def_id: DefId) -> DepNode<DefId> {
|
||||
for item in attr.meta_item_list().unwrap_or(&[]) {
|
||||
if item.check_name(LABEL) {
|
||||
let value = expect_associated_value(self.tcx, item);
|
||||
match DepNode::from_label_string(&value[..], def_id) {
|
||||
match DepNode::from_label_string(&value.as_str(), def_id) {
|
||||
Ok(def_id) => return def_id,
|
||||
Err(()) => {
|
||||
self.tcx.sess.span_fatal(
|
||||
|
|
@ -276,13 +274,7 @@ fn check_config(tcx: TyCtxt, attr: &ast::Attribute) -> bool {
|
|||
if item.check_name(CFG) {
|
||||
let value = expect_associated_value(tcx, item);
|
||||
debug!("check_config: searching for cfg {:?}", value);
|
||||
for cfg in &config[..] {
|
||||
if cfg.check_name(&value[..]) {
|
||||
debug!("check_config: matched {:?}", cfg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return config.contains(&(value, None));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +283,7 @@ fn check_config(tcx: TyCtxt, attr: &ast::Attribute) -> bool {
|
|||
&format!("no cfg attribute"));
|
||||
}
|
||||
|
||||
fn expect_associated_value(tcx: TyCtxt, item: &NestedMetaItem) -> InternedString {
|
||||
fn expect_associated_value(tcx: TyCtxt, item: &NestedMetaItem) -> ast::Name {
|
||||
if let Some(value) = item.value_str() {
|
||||
value
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ fn string_to_timestamp(s: &str) -> Result<SystemTime, ()> {
|
|||
}
|
||||
|
||||
fn crate_path_tcx(tcx: TyCtxt, cnum: CrateNum) -> PathBuf {
|
||||
crate_path(tcx.sess, &tcx.crate_name(cnum), &tcx.crate_disambiguator(cnum))
|
||||
crate_path(tcx.sess, &tcx.crate_name(cnum).as_str(), &tcx.crate_disambiguator(cnum).as_str())
|
||||
}
|
||||
|
||||
/// Finds the session directory containing the correct metadata hashes file for
|
||||
|
|
|
|||
|
|
@ -81,19 +81,12 @@ impl NonCamelCaseTypes {
|
|||
.concat()
|
||||
}
|
||||
|
||||
let s = name.as_str();
|
||||
|
||||
if !is_camel_case(name) {
|
||||
let c = to_camel_case(&s);
|
||||
let c = to_camel_case(&name.as_str());
|
||||
let m = if c.is_empty() {
|
||||
format!("{} `{}` should have a camel case name such as `CamelCase`",
|
||||
sort,
|
||||
s)
|
||||
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, name)
|
||||
} else {
|
||||
format!("{} `{}` should have a camel case name such as `{}`",
|
||||
sort,
|
||||
s,
|
||||
c)
|
||||
format!("{} `{}` should have a camel case name such as `{}`", sort, name, c)
|
||||
};
|
||||
cx.span_lint(NON_CAMEL_CASE_TYPES, span, &m[..]);
|
||||
}
|
||||
|
|
@ -241,8 +234,8 @@ impl LateLintPass for NonSnakeCase {
|
|||
.and_then(|at| at.value_str().map(|s| (at, s)));
|
||||
if let Some(ref name) = cx.tcx.sess.opts.crate_name {
|
||||
self.check_snake_case(cx, "crate", name, None);
|
||||
} else if let Some((attr, ref name)) = attr_crate_name {
|
||||
self.check_snake_case(cx, "crate", name, Some(attr.span));
|
||||
} else if let Some((attr, name)) = attr_crate_name {
|
||||
self.check_snake_case(cx, "crate", &name.as_str(), Some(attr.span));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,21 +319,19 @@ pub struct NonUpperCaseGlobals;
|
|||
|
||||
impl NonUpperCaseGlobals {
|
||||
fn check_upper_case(cx: &LateContext, sort: &str, name: ast::Name, span: Span) {
|
||||
let s = name.as_str();
|
||||
|
||||
if s.chars().any(|c| c.is_lowercase()) {
|
||||
let uc = NonSnakeCase::to_snake_case(&s).to_uppercase();
|
||||
if uc != &s[..] {
|
||||
if name.as_str().chars().any(|c| c.is_lowercase()) {
|
||||
let uc = NonSnakeCase::to_snake_case(&name.as_str()).to_uppercase();
|
||||
if name != &*uc {
|
||||
cx.span_lint(NON_UPPER_CASE_GLOBALS,
|
||||
span,
|
||||
&format!("{} `{}` should have an upper case name such as `{}`",
|
||||
sort,
|
||||
s,
|
||||
name,
|
||||
uc));
|
||||
} else {
|
||||
cx.span_lint(NON_UPPER_CASE_GLOBALS,
|
||||
span,
|
||||
&format!("{} `{}` should have an upper case name", sort, s));
|
||||
&format!("{} `{}` should have an upper case name", sort, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ use std::collections::HashSet;
|
|||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
|
|
@ -633,9 +634,9 @@ impl Deprecated {
|
|||
stability: &Option<&attr::Stability>,
|
||||
deprecation: &Option<stability::DeprecationEntry>) {
|
||||
// Deprecated attributes apply in-crate and cross-crate.
|
||||
if let Some(&attr::Stability{rustc_depr: Some(attr::RustcDeprecation{ref reason, ..}), ..})
|
||||
if let Some(&attr::Stability{rustc_depr: Some(attr::RustcDeprecation{reason, ..}), ..})
|
||||
= *stability {
|
||||
output(cx, DEPRECATED, span, Some(&reason))
|
||||
output(cx, DEPRECATED, span, Some(reason))
|
||||
} else if let Some(ref depr_entry) = *deprecation {
|
||||
if let Some(parent_depr) = cx.tcx.lookup_deprecation_entry(self.parent_def(cx)) {
|
||||
if parent_depr.same_origin(depr_entry) {
|
||||
|
|
@ -643,10 +644,10 @@ impl Deprecated {
|
|||
}
|
||||
}
|
||||
|
||||
output(cx, DEPRECATED, span, depr_entry.attr.note.as_ref().map(|x| &**x))
|
||||
output(cx, DEPRECATED, span, depr_entry.attr.note)
|
||||
}
|
||||
|
||||
fn output(cx: &LateContext, lint: &'static Lint, span: Span, note: Option<&str>) {
|
||||
fn output(cx: &LateContext, lint: &'static Lint, span: Span, note: Option<Symbol>) {
|
||||
let msg = if let Some(note) = note {
|
||||
format!("use of deprecated item: {}", note)
|
||||
} else {
|
||||
|
|
@ -772,9 +773,9 @@ impl LintPass for DeprecatedAttr {
|
|||
|
||||
impl EarlyLintPass for DeprecatedAttr {
|
||||
fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
|
||||
let name = &*attr.name();
|
||||
let name = attr.name();
|
||||
for &&(n, _, ref g) in &self.depr_attrs {
|
||||
if n == name {
|
||||
if name == n {
|
||||
if let &AttributeGate::Gated(Stability::Deprecated(link),
|
||||
ref name,
|
||||
ref reason,
|
||||
|
|
@ -1228,7 +1229,7 @@ impl LateLintPass for MutableTransmutes {
|
|||
ty::TyFnDef(.., ref bfty) if bfty.abi == RustIntrinsic => (),
|
||||
_ => return false,
|
||||
}
|
||||
cx.tcx.item_name(def_id).as_str() == "transmute"
|
||||
cx.tcx.item_name(def_id) == "transmute"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,9 +219,9 @@ impl LateLintPass for TypeLimits {
|
|||
ty::TyFloat(t) => {
|
||||
let (min, max) = float_ty_range(t);
|
||||
let lit_val: f64 = match lit.node {
|
||||
ast::LitKind::Float(ref v, _) |
|
||||
ast::LitKind::FloatUnsuffixed(ref v) => {
|
||||
match v.parse() {
|
||||
ast::LitKind::Float(v, _) |
|
||||
ast::LitKind::FloatUnsuffixed(v) => {
|
||||
match v.as_str().parse() {
|
||||
Ok(f) => f,
|
||||
Err(_) => return,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
|
|||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::feature_gate::{BUILTIN_ATTRIBUTES, AttributeType};
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::Span;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ impl UnusedMut {
|
|||
let name = path1.node;
|
||||
if let hir::BindByValue(hir::MutMutable) = mode {
|
||||
if !name.as_str().starts_with("_") {
|
||||
match mutables.entry(name.0 as usize) {
|
||||
match mutables.entry(name) {
|
||||
Vacant(entry) => {
|
||||
entry.insert(vec![id]);
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ impl LateLintPass for UnusedResults {
|
|||
// check for #[must_use="..."]
|
||||
if let Some(s) = attr.value_str() {
|
||||
msg.push_str(": ");
|
||||
msg.push_str(&s);
|
||||
msg.push_str(&s.as_str());
|
||||
}
|
||||
cx.span_lint(UNUSED_MUST_USE, sp, &msg);
|
||||
return true;
|
||||
|
|
@ -274,10 +274,10 @@ impl LateLintPass for UnusedAttributes {
|
|||
// Has a plugin registered this attribute as one which must be used at
|
||||
// the crate level?
|
||||
let plugin_crate = plugin_attributes.iter()
|
||||
.find(|&&(ref x, t)| &*attr.name() == x && AttributeType::CrateLevel == t)
|
||||
.find(|&&(ref x, t)| attr.name() == &**x && AttributeType::CrateLevel == t)
|
||||
.is_some();
|
||||
if known_crate || plugin_crate {
|
||||
let msg = match attr.node.style {
|
||||
let msg = match attr.style {
|
||||
ast::AttrStyle::Outer => {
|
||||
"crate-level attribute should be an inner attribute: add an exclamation \
|
||||
mark: #![foo]"
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use syntax::abi::Abi;
|
|||
use syntax::attr;
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax::feature_gate::{self, GateIssue};
|
||||
use syntax::parse::token::{InternedString, intern};
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use log;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ pub struct CrateLoader<'a> {
|
|||
cstore: &'a CStore,
|
||||
next_crate_num: CrateNum,
|
||||
foreign_item_map: FxHashMap<String, Vec<ast::NodeId>>,
|
||||
local_crate_name: String,
|
||||
local_crate_name: Symbol,
|
||||
}
|
||||
|
||||
fn dump_crates(cstore: &CStore) {
|
||||
|
|
@ -70,8 +70,8 @@ fn dump_crates(cstore: &CStore) {
|
|||
|
||||
#[derive(Debug)]
|
||||
struct ExternCrateInfo {
|
||||
ident: String,
|
||||
name: String,
|
||||
ident: Symbol,
|
||||
name: Symbol,
|
||||
id: ast::NodeId,
|
||||
dep_kind: DepKind,
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ fn register_native_lib(sess: &Session,
|
|||
cstore: &CStore,
|
||||
span: Option<Span>,
|
||||
lib: NativeLibrary) {
|
||||
if lib.name.is_empty() {
|
||||
if lib.name.as_str().is_empty() {
|
||||
match span {
|
||||
Some(span) => {
|
||||
struct_span_err!(sess, span, E0454,
|
||||
|
|
@ -147,7 +147,7 @@ impl<'a> CrateLoader<'a> {
|
|||
cstore: cstore,
|
||||
next_crate_num: cstore.next_crate_num(),
|
||||
foreign_item_map: FxHashMap(),
|
||||
local_crate_name: local_crate_name.to_owned(),
|
||||
local_crate_name: Symbol::intern(local_crate_name),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,12 +160,12 @@ impl<'a> CrateLoader<'a> {
|
|||
Some(name) => {
|
||||
validate_crate_name(Some(self.sess), &name.as_str(),
|
||||
Some(i.span));
|
||||
name.to_string()
|
||||
name
|
||||
}
|
||||
None => i.ident.to_string(),
|
||||
None => i.ident.name,
|
||||
};
|
||||
Some(ExternCrateInfo {
|
||||
ident: i.ident.to_string(),
|
||||
ident: i.ident.name,
|
||||
name: name,
|
||||
id: i.id,
|
||||
dep_kind: if attr::contains_name(&i.attrs, "no_link") {
|
||||
|
|
@ -179,7 +179,7 @@ impl<'a> CrateLoader<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn existing_match(&self, name: &str, hash: Option<&Svh>, kind: PathKind)
|
||||
fn existing_match(&self, name: Symbol, hash: Option<&Svh>, kind: PathKind)
|
||||
-> Option<CrateNum> {
|
||||
let mut ret = None;
|
||||
self.cstore.iter_crate_data(|cnum, data| {
|
||||
|
|
@ -201,7 +201,7 @@ impl<'a> CrateLoader<'a> {
|
|||
// `source` stores paths which are normalized which may be different
|
||||
// from the strings on the command line.
|
||||
let source = self.cstore.used_crate_source(cnum);
|
||||
if let Some(locs) = self.sess.opts.externs.get(name) {
|
||||
if let Some(locs) = self.sess.opts.externs.get(&*name.as_str()) {
|
||||
let found = locs.iter().any(|l| {
|
||||
let l = fs::canonicalize(l).ok();
|
||||
source.dylib.as_ref().map(|p| &p.0) == l.as_ref() ||
|
||||
|
|
@ -233,7 +233,7 @@ impl<'a> CrateLoader<'a> {
|
|||
root: &CrateRoot) {
|
||||
// Check for (potential) conflicts with the local crate
|
||||
if self.local_crate_name == root.name &&
|
||||
self.sess.local_crate_disambiguator() == &root.disambiguator[..] {
|
||||
self.sess.local_crate_disambiguator() == root.disambiguator {
|
||||
span_fatal!(self.sess, span, E0519,
|
||||
"the current crate is indistinguishable from one of its \
|
||||
dependencies: it has the same crate-name `{}` and was \
|
||||
|
|
@ -258,8 +258,8 @@ impl<'a> CrateLoader<'a> {
|
|||
|
||||
fn register_crate(&mut self,
|
||||
root: &Option<CratePaths>,
|
||||
ident: &str,
|
||||
name: &str,
|
||||
ident: Symbol,
|
||||
name: Symbol,
|
||||
span: Span,
|
||||
lib: Library,
|
||||
dep_kind: DepKind)
|
||||
|
|
@ -290,7 +290,7 @@ impl<'a> CrateLoader<'a> {
|
|||
let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind);
|
||||
|
||||
let cmeta = Rc::new(cstore::CrateMetadata {
|
||||
name: name.to_string(),
|
||||
name: name,
|
||||
extern_crate: Cell::new(None),
|
||||
key_map: metadata.load_key_map(crate_root.index),
|
||||
proc_macros: crate_root.macro_derive_registrar.map(|_| {
|
||||
|
|
@ -314,8 +314,8 @@ impl<'a> CrateLoader<'a> {
|
|||
|
||||
fn resolve_crate(&mut self,
|
||||
root: &Option<CratePaths>,
|
||||
ident: &str,
|
||||
name: &str,
|
||||
ident: Symbol,
|
||||
name: Symbol,
|
||||
hash: Option<&Svh>,
|
||||
span: Span,
|
||||
path_kind: PathKind,
|
||||
|
|
@ -459,13 +459,12 @@ impl<'a> CrateLoader<'a> {
|
|||
let deps = crate_root.crate_deps.decode(metadata);
|
||||
let map: FxHashMap<_, _> = deps.enumerate().map(|(crate_num, dep)| {
|
||||
debug!("resolving dep crate {} hash: `{}`", dep.name, dep.hash);
|
||||
let dep_name = &dep.name.as_str();
|
||||
let dep_kind = match dep_kind {
|
||||
DepKind::MacrosOnly => DepKind::MacrosOnly,
|
||||
_ => dep.kind,
|
||||
};
|
||||
let (local_cnum, ..) = self.resolve_crate(
|
||||
root, dep_name, dep_name, Some(&dep.hash), span, PathKind::Dependency, dep_kind,
|
||||
root, dep.name, dep.name, Some(&dep.hash), span, PathKind::Dependency, dep_kind,
|
||||
);
|
||||
(CrateNum::new(crate_num + 1), local_cnum)
|
||||
}).collect();
|
||||
|
|
@ -485,13 +484,11 @@ impl<'a> CrateLoader<'a> {
|
|||
let target_triple = &self.sess.opts.target_triple[..];
|
||||
let is_cross = target_triple != config::host_triple();
|
||||
let mut target_only = false;
|
||||
let ident = info.ident.clone();
|
||||
let name = info.name.clone();
|
||||
let mut locate_ctxt = locator::Context {
|
||||
sess: self.sess,
|
||||
span: span,
|
||||
ident: &ident[..],
|
||||
crate_name: &name[..],
|
||||
ident: info.ident,
|
||||
crate_name: info.name,
|
||||
hash: None,
|
||||
filesearch: self.sess.host_filesearch(PathKind::Crate),
|
||||
target: &self.sess.host,
|
||||
|
|
@ -585,11 +582,11 @@ impl<'a> CrateLoader<'a> {
|
|||
trait_name: &str,
|
||||
expand: fn(TokenStream) -> TokenStream,
|
||||
attributes: &[&'static str]) {
|
||||
let attrs = attributes.iter().map(|s| InternedString::new(s)).collect();
|
||||
let attrs = attributes.iter().cloned().map(Symbol::intern).collect();
|
||||
let derive = SyntaxExtension::CustomDerive(
|
||||
Box::new(CustomDerive::new(expand, attrs))
|
||||
);
|
||||
self.0.push((intern(trait_name), Rc::new(derive)));
|
||||
self.0.push((Symbol::intern(trait_name), Rc::new(derive)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -607,8 +604,8 @@ impl<'a> CrateLoader<'a> {
|
|||
pub fn find_plugin_registrar(&mut self, span: Span, name: &str)
|
||||
-> Option<(PathBuf, Svh, DefIndex)> {
|
||||
let ekrate = self.read_extension_crate(span, &ExternCrateInfo {
|
||||
name: name.to_string(),
|
||||
ident: name.to_string(),
|
||||
name: Symbol::intern(name),
|
||||
ident: Symbol::intern(name),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
dep_kind: DepKind::MacrosOnly,
|
||||
});
|
||||
|
|
@ -645,7 +642,7 @@ impl<'a> CrateLoader<'a> {
|
|||
let libs = self.cstore.get_used_libraries();
|
||||
for (foreign_lib, list) in self.foreign_item_map.iter() {
|
||||
let is_static = libs.borrow().iter().any(|lib| {
|
||||
*foreign_lib == lib.name && lib.kind == cstore::NativeStatic
|
||||
lib.name == &**foreign_lib && lib.kind == cstore::NativeStatic
|
||||
});
|
||||
if is_static {
|
||||
for id in list {
|
||||
|
|
@ -708,8 +705,8 @@ impl<'a> CrateLoader<'a> {
|
|||
// in terms of everyone has a compatible panic runtime format, that's
|
||||
// performed later as part of the `dependency_format` module.
|
||||
let name = match desired_strategy {
|
||||
PanicStrategy::Unwind => "panic_unwind",
|
||||
PanicStrategy::Abort => "panic_abort",
|
||||
PanicStrategy::Unwind => Symbol::intern("panic_unwind"),
|
||||
PanicStrategy::Abort => Symbol::intern("panic_abort"),
|
||||
};
|
||||
info!("panic runtime not found -- loading {}", name);
|
||||
|
||||
|
|
@ -791,9 +788,9 @@ impl<'a> CrateLoader<'a> {
|
|||
// * Staticlibs and Rust dylibs use system malloc
|
||||
// * Rust dylibs used as dependencies to rust use jemalloc
|
||||
let name = if need_lib_alloc && !self.sess.opts.cg.prefer_dynamic {
|
||||
&self.sess.target.target.options.lib_allocation_crate
|
||||
Symbol::intern(&self.sess.target.target.options.lib_allocation_crate)
|
||||
} else {
|
||||
&self.sess.target.target.options.exe_allocation_crate
|
||||
Symbol::intern(&self.sess.target.target.options.exe_allocation_crate)
|
||||
};
|
||||
let dep_kind = DepKind::Implicit;
|
||||
let (cnum, data) =
|
||||
|
|
@ -855,8 +852,8 @@ impl<'a> CrateLoader<'a> {
|
|||
impl<'a> CrateLoader<'a> {
|
||||
pub fn preprocess(&mut self, krate: &ast::Crate) {
|
||||
for attr in krate.attrs.iter().filter(|m| m.name() == "link_args") {
|
||||
if let Some(ref linkarg) = attr.value_str() {
|
||||
self.cstore.add_used_link_args(&linkarg);
|
||||
if let Some(linkarg) = attr.value_str() {
|
||||
self.cstore.add_used_link_args(&linkarg.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -869,7 +866,7 @@ impl<'a> CrateLoader<'a> {
|
|||
// First, add all of the custom #[link_args] attributes
|
||||
for m in i.attrs.iter().filter(|a| a.check_name("link_args")) {
|
||||
if let Some(linkarg) = m.value_str() {
|
||||
self.cstore.add_used_link_args(&linkarg);
|
||||
self.cstore.add_used_link_args(&linkarg.as_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -881,7 +878,7 @@ impl<'a> CrateLoader<'a> {
|
|||
};
|
||||
let kind = items.iter().find(|k| {
|
||||
k.check_name("kind")
|
||||
}).and_then(|a| a.value_str());
|
||||
}).and_then(|a| a.value_str()).map(Symbol::as_str);
|
||||
let kind = match kind.as_ref().map(|s| &s[..]) {
|
||||
Some("static") => cstore::NativeStatic,
|
||||
Some("dylib") => cstore::NativeUnknown,
|
||||
|
|
@ -903,7 +900,7 @@ impl<'a> CrateLoader<'a> {
|
|||
struct_span_err!(self.sess, m.span, E0459,
|
||||
"#[link(...)] specified without `name = \"foo\"`")
|
||||
.span_label(m.span, &format!("missing `name` argument")).emit();
|
||||
InternedString::new("foo")
|
||||
Symbol::intern("foo")
|
||||
}
|
||||
};
|
||||
let cfg = items.iter().find(|k| {
|
||||
|
|
@ -913,7 +910,7 @@ impl<'a> CrateLoader<'a> {
|
|||
list[0].meta_item().unwrap().clone()
|
||||
});
|
||||
let lib = NativeLibrary {
|
||||
name: n.to_string(),
|
||||
name: n,
|
||||
kind: kind,
|
||||
cfg: cfg,
|
||||
};
|
||||
|
|
@ -944,7 +941,7 @@ impl<'a> middle::cstore::CrateLoader for CrateLoader<'a> {
|
|||
|
||||
for &(ref name, kind) in &self.sess.opts.libs {
|
||||
let lib = NativeLibrary {
|
||||
name: name.clone(),
|
||||
name: Symbol::intern(name),
|
||||
kind: kind,
|
||||
cfg: None,
|
||||
};
|
||||
|
|
@ -962,7 +959,7 @@ impl<'a> middle::cstore::CrateLoader for CrateLoader<'a> {
|
|||
|
||||
let info = self.extract_crate_info(item).unwrap();
|
||||
let (cnum, ..) = self.resolve_crate(
|
||||
&None, &info.ident, &info.name, None, item.span, PathKind::Crate, info.dep_kind,
|
||||
&None, info.ident, info.name, None, item.span, PathKind::Crate, info.dep_kind,
|
||||
);
|
||||
|
||||
let def_id = definitions.opt_local_def_id(item.id).unwrap();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use std::path::PathBuf;
|
|||
use flate::Bytes;
|
||||
use syntax::{ast, attr};
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos;
|
||||
|
||||
pub use rustc::middle::cstore::{NativeLibrary, LinkagePreference};
|
||||
|
|
@ -58,7 +59,7 @@ pub struct ImportedFileMap {
|
|||
}
|
||||
|
||||
pub struct CrateMetadata {
|
||||
pub name: String,
|
||||
pub name: Symbol,
|
||||
|
||||
/// Information about the extern crate that caused this crate to
|
||||
/// be loaded. If this is `None`, then the crate was injected
|
||||
|
|
@ -213,7 +214,7 @@ impl CStore {
|
|||
}
|
||||
|
||||
pub fn add_used_library(&self, lib: NativeLibrary) {
|
||||
assert!(!lib.name.is_empty());
|
||||
assert!(!lib.name.as_str().is_empty());
|
||||
self.used_libraries.borrow_mut().push(lib);
|
||||
}
|
||||
|
||||
|
|
@ -249,14 +250,14 @@ impl CStore {
|
|||
}
|
||||
|
||||
impl CrateMetadata {
|
||||
pub fn name(&self) -> &str {
|
||||
&self.root.name
|
||||
pub fn name(&self) -> Symbol {
|
||||
self.root.name
|
||||
}
|
||||
pub fn hash(&self) -> Svh {
|
||||
self.root.hash
|
||||
}
|
||||
pub fn disambiguator(&self) -> &str {
|
||||
&self.root.disambiguator
|
||||
pub fn disambiguator(&self) -> Symbol {
|
||||
self.root.disambiguator
|
||||
}
|
||||
|
||||
pub fn is_staged_api(&self) -> bool {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ use rustc_back::PanicStrategy;
|
|||
use std::path::PathBuf;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::parse::{token, new_parser_from_source_str};
|
||||
use syntax::parse::new_parser_from_source_str;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::mk_sp;
|
||||
use rustc::hir::svh::Svh;
|
||||
use rustc_back::target::Target;
|
||||
|
|
@ -262,14 +263,14 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
self.get_crate_data(cnum).panic_strategy()
|
||||
}
|
||||
|
||||
fn crate_name(&self, cnum: CrateNum) -> token::InternedString
|
||||
fn crate_name(&self, cnum: CrateNum) -> Symbol
|
||||
{
|
||||
token::intern_and_get_ident(&self.get_crate_data(cnum).name[..])
|
||||
self.get_crate_data(cnum).name
|
||||
}
|
||||
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> token::InternedString
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol
|
||||
{
|
||||
token::intern_and_get_ident(&self.get_crate_data(cnum).name())
|
||||
self.get_crate_data(cnum).name()
|
||||
}
|
||||
|
||||
fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate>
|
||||
|
|
@ -282,9 +283,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
self.get_crate_hash(cnum)
|
||||
}
|
||||
|
||||
fn crate_disambiguator(&self, cnum: CrateNum) -> token::InternedString
|
||||
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol
|
||||
{
|
||||
token::intern_and_get_ident(&self.get_crate_data(cnum).disambiguator())
|
||||
self.get_crate_data(cnum).disambiguator()
|
||||
}
|
||||
|
||||
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
|
||||
|
|
|
|||
|
|
@ -934,7 +934,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
.decode(self)
|
||||
.map(|mut attr| {
|
||||
// Need new unique IDs: old thread-local IDs won't map to new threads.
|
||||
attr.node.id = attr::mk_attr_id();
|
||||
attr.id = attr::mk_attr_id();
|
||||
attr
|
||||
})
|
||||
.collect()
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use std::rc::Rc;
|
|||
use std::u32;
|
||||
use syntax::ast::{self, CRATE_NODE_ID};
|
||||
use syntax::attr;
|
||||
use syntax;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos;
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
|
|
@ -600,7 +600,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
if let PatKind::Binding(_, ref path1, _) = arg.pat.node {
|
||||
path1.node
|
||||
} else {
|
||||
syntax::parse::token::intern("")
|
||||
Symbol::intern("")
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
@ -1119,7 +1119,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
let deps = get_ordered_deps(self.cstore);
|
||||
self.lazy_seq(deps.iter().map(|&(_, ref dep)| {
|
||||
CrateDep {
|
||||
name: syntax::parse::token::intern(dep.name()),
|
||||
name: dep.name(),
|
||||
hash: dep.hash(),
|
||||
kind: dep.dep_kind.get(),
|
||||
}
|
||||
|
|
@ -1279,10 +1279,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
|
||||
let root = self.lazy(&CrateRoot {
|
||||
rustc_version: rustc_version(),
|
||||
name: link_meta.crate_name.clone(),
|
||||
name: link_meta.crate_name,
|
||||
triple: tcx.sess.opts.target_triple.clone(),
|
||||
hash: link_meta.crate_hash,
|
||||
disambiguator: tcx.sess.local_crate_disambiguator().to_string(),
|
||||
disambiguator: tcx.sess.local_crate_disambiguator(),
|
||||
panic_strategy: tcx.sess.panic_strategy(),
|
||||
plugin_registrar_fn: tcx.sess
|
||||
.plugin_registrar_fn
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ use rustc_llvm as llvm;
|
|||
use rustc_llvm::{False, ObjectFile, mk_section_iter};
|
||||
use rustc_llvm::archive_ro::ArchiveRO;
|
||||
use errors::DiagnosticBuilder;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
use rustc_back::target::Target;
|
||||
|
||||
|
|
@ -249,8 +250,8 @@ pub struct CrateMismatch {
|
|||
pub struct Context<'a> {
|
||||
pub sess: &'a Session,
|
||||
pub span: Span,
|
||||
pub ident: &'a str,
|
||||
pub crate_name: &'a str,
|
||||
pub ident: Symbol,
|
||||
pub crate_name: Symbol,
|
||||
pub hash: Option<&'a Svh>,
|
||||
// points to either self.sess.target.target or self.sess.host, must match triple
|
||||
pub target: &'a Target,
|
||||
|
|
@ -422,7 +423,7 @@ impl<'a> Context<'a> {
|
|||
// must be loaded via -L plus some filtering.
|
||||
if self.hash.is_none() {
|
||||
self.should_match_name = false;
|
||||
if let Some(s) = self.sess.opts.externs.get(self.crate_name) {
|
||||
if let Some(s) = self.sess.opts.externs.get(&self.crate_name.as_str()) {
|
||||
return self.find_commandline_library(s.iter());
|
||||
}
|
||||
self.should_match_name = true;
|
||||
|
|
@ -533,7 +534,7 @@ impl<'a> Context<'a> {
|
|||
if let Some((ref p, _)) = lib.rlib {
|
||||
err.note(&format!("path: {}", p.display()));
|
||||
}
|
||||
note_crate_name(&mut err, &lib.metadata.get_root().name);
|
||||
note_crate_name(&mut err, &lib.metadata.get_root().name.as_str());
|
||||
}
|
||||
err.emit();
|
||||
None
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use rustc_back::PanicStrategy;
|
|||
|
||||
use rustc_serialize as serialize;
|
||||
use syntax::{ast, attr};
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
|
@ -163,10 +164,10 @@ pub enum LazyState {
|
|||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct CrateRoot {
|
||||
pub rustc_version: String,
|
||||
pub name: String,
|
||||
pub name: Symbol,
|
||||
pub triple: String,
|
||||
pub hash: hir::svh::Svh,
|
||||
pub disambiguator: String,
|
||||
pub disambiguator: Symbol,
|
||||
pub panic_strategy: PanicStrategy,
|
||||
pub plugin_registrar_fn: Option<DefIndex>,
|
||||
pub macro_derive_registrar: Option<DefIndex>,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use rustc::util::nodemap::NodeMap;
|
|||
use rustc::hir;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use rustc::hir::map::blocks::FnLikeNode;
|
|||
use rustc::infer::InferCtxt;
|
||||
use rustc::ty::subst::Subst;
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use rustc::hir;
|
||||
use rustc_const_math::{ConstInt, ConstUsize};
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
|||
self.tcx.mk_nil()
|
||||
}
|
||||
|
||||
pub fn str_literal(&mut self, value: token::InternedString) -> Literal<'tcx> {
|
||||
pub fn str_literal(&mut self, value: InternedString) -> Literal<'tcx> {
|
||||
Literal::Value { value: ConstVal::Str(value) }
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
|||
self_ty: Ty<'tcx>,
|
||||
params: &[Ty<'tcx>])
|
||||
-> (Ty<'tcx>, Literal<'tcx>) {
|
||||
let method_name = token::intern(method_name);
|
||||
let method_name = Symbol::intern(method_name);
|
||||
let substs = self.tcx.mk_substs_trait(self_ty, params);
|
||||
for item in self.tcx.associated_items(trait_def_id) {
|
||||
if item.kind == ty::AssociatedKind::Method && item.name == method_name {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ use rustc::session::Session;
|
|||
use syntax::ast::*;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax_pos::Span;
|
||||
use errors;
|
||||
|
|
@ -39,7 +40,7 @@ impl<'a> AstValidator<'a> {
|
|||
if label.name == keywords::StaticLifetime.name() {
|
||||
self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name));
|
||||
}
|
||||
if label.name.as_str() == "'_" {
|
||||
if label.name == "'_" {
|
||||
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
|
||||
id,
|
||||
span,
|
||||
|
|
@ -89,7 +90,7 @@ impl<'a> AstValidator<'a> {
|
|||
|
||||
impl<'a> Visitor for AstValidator<'a> {
|
||||
fn visit_lifetime(&mut self, lt: &Lifetime) {
|
||||
if lt.name.as_str() == "'_" {
|
||||
if lt.name == "'_" {
|
||||
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
|
||||
lt.id,
|
||||
lt.span,
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
|||
hir_visit::walk_assoc_type_binding(self, type_binding)
|
||||
}
|
||||
fn visit_attribute(&mut self, attr: &'v ast::Attribute) {
|
||||
self.record("Attribute", Id::Attr(attr.node.id), attr);
|
||||
self.record("Attribute", Id::Attr(attr.id), attr);
|
||||
}
|
||||
fn visit_macro_def(&mut self, macro_def: &'v hir::MacroDef) {
|
||||
self.record("MacroDef", Id::Node(macro_def.id), macro_def);
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ pub fn load_plugins(sess: &Session,
|
|||
for plugin in plugins {
|
||||
// plugins must have a name and can't be key = value
|
||||
match plugin.name() {
|
||||
Some(ref name) if !plugin.is_value_str() => {
|
||||
Some(name) if !plugin.is_value_str() => {
|
||||
let args = plugin.meta_item_list().map(ToOwned::to_owned);
|
||||
loader.load_plugin(plugin.span, name, args.unwrap_or_default());
|
||||
loader.load_plugin(plugin.span, &name.as_str(), args.unwrap_or_default());
|
||||
},
|
||||
_ => call_malformed_plugin_attribute(sess, attr.span),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use rustc::mir::transform::MirMapPass;
|
|||
|
||||
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT, IdentTT};
|
||||
use syntax::ext::base::MacroExpanderFn;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::ast;
|
||||
use syntax::feature_gate::AttributeType;
|
||||
use syntax_pos::Span;
|
||||
|
|
@ -101,7 +101,7 @@ impl<'a> Registry<'a> {
|
|||
///
|
||||
/// This is the most general hook into `libsyntax`'s expansion behavior.
|
||||
pub fn register_syntax_extension(&mut self, name: ast::Name, extension: SyntaxExtension) {
|
||||
if name.as_str() == "macro_rules" {
|
||||
if name == "macro_rules" {
|
||||
panic!("user-defined macros may not be named `macro_rules`");
|
||||
}
|
||||
self.syntax_exts.push((name, match extension {
|
||||
|
|
@ -121,7 +121,7 @@ impl<'a> Registry<'a> {
|
|||
/// It builds for you a `NormalTT` that calls `expander`,
|
||||
/// and also takes care of interning the macro's name.
|
||||
pub fn register_macro(&mut self, name: &str, expander: MacroExpanderFn) {
|
||||
self.register_syntax_extension(token::intern(name),
|
||||
self.register_syntax_extension(Symbol::intern(name),
|
||||
NormalTT(Box::new(expander), None, false));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ use std::rc::Rc;
|
|||
|
||||
use syntax::ast::Name;
|
||||
use syntax::attr;
|
||||
use syntax::parse::token;
|
||||
|
||||
use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind};
|
||||
use syntax::ast::{Mutability, StmtKind, TraitItem, TraitItemKind};
|
||||
|
|
@ -41,7 +40,7 @@ use syntax::ext::base::Determinacy::Undetermined;
|
|||
use syntax::ext::expand::mark_tts;
|
||||
use syntax::ext::hygiene::Mark;
|
||||
use syntax::ext::tt::macro_rules;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::visit::{self, Visitor};
|
||||
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
|
@ -139,7 +138,7 @@ impl<'b> Resolver<'b> {
|
|||
match view_path.node {
|
||||
ViewPathSimple(binding, ref full_path) => {
|
||||
let mut source = full_path.segments.last().unwrap().identifier;
|
||||
let source_name = source.name.as_str();
|
||||
let source_name = source.name;
|
||||
if source_name == "mod" || source_name == "self" {
|
||||
resolve_error(self,
|
||||
view_path.span,
|
||||
|
|
@ -607,7 +606,7 @@ impl<'b> Resolver<'b> {
|
|||
if attr.check_name("macro_escape") {
|
||||
let msg = "macro_escape is a deprecated synonym for macro_use";
|
||||
let mut err = self.session.struct_span_warn(attr.span, msg);
|
||||
if let ast::AttrStyle::Inner = attr.node.style {
|
||||
if let ast::AttrStyle::Inner = attr.style {
|
||||
err.help("consider an outer attribute, #[macro_use] mod ...").emit();
|
||||
} else {
|
||||
err.emit();
|
||||
|
|
@ -632,7 +631,7 @@ impl<'b> Resolver<'b> {
|
|||
match attr.meta_item_list() {
|
||||
Some(names) => for attr in names {
|
||||
if let Some(word) = attr.word() {
|
||||
imports.imports.push((token::intern(&word.name()), attr.span()));
|
||||
imports.imports.push((word.name(), attr.span()));
|
||||
} else {
|
||||
span_err!(self.session, attr.span(), E0466, "bad macro import");
|
||||
}
|
||||
|
|
@ -646,7 +645,7 @@ impl<'b> Resolver<'b> {
|
|||
if let Some(names) = attr.meta_item_list() {
|
||||
for attr in names {
|
||||
if let Some(word) = attr.word() {
|
||||
imports.reexports.push((token::intern(&word.name()), attr.span()));
|
||||
imports.reexports.push((word.name(), attr.span()));
|
||||
} else {
|
||||
bad_macro_reexport(self, attr.span());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ use syntax::ext::hygiene::{Mark, SyntaxContext};
|
|||
use syntax::ast::{self, FloatTy};
|
||||
use syntax::ast::{CRATE_NODE_ID, Name, NodeId, Ident, SpannedIdent, IntTy, UintTy};
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax::util::lev_distance::find_best_match_for_name;
|
||||
|
||||
use syntax::visit::{self, FnKind, Visitor};
|
||||
|
|
@ -90,7 +90,7 @@ mod resolve_imports;
|
|||
|
||||
enum SuggestionType {
|
||||
Macro(String),
|
||||
Function(token::InternedString),
|
||||
Function(Symbol),
|
||||
NotFound,
|
||||
}
|
||||
|
||||
|
|
@ -1039,7 +1039,7 @@ impl PrimitiveTypeTable {
|
|||
}
|
||||
|
||||
fn intern(&mut self, string: &str, primitive_type: PrimTy) {
|
||||
self.primitive_types.insert(token::intern(string), primitive_type);
|
||||
self.primitive_types.insert(Symbol::intern(string), primitive_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1460,7 +1460,6 @@ impl<'a> Resolver<'a> {
|
|||
let name = module_path[index].name;
|
||||
match self.resolve_name_in_module(search_module, name, TypeNS, false, span) {
|
||||
Failed(_) => {
|
||||
let segment_name = name.as_str();
|
||||
let module_name = module_to_string(search_module);
|
||||
let msg = if "???" == &module_name {
|
||||
let current_module = self.current_module;
|
||||
|
|
@ -1478,10 +1477,10 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
format!("Did you mean `{}{}`?", prefix, path_str)
|
||||
}
|
||||
None => format!("Maybe a missing `extern crate {};`?", segment_name),
|
||||
None => format!("Maybe a missing `extern crate {};`?", name),
|
||||
}
|
||||
} else {
|
||||
format!("Could not find `{}` in `{}`", segment_name, module_name)
|
||||
format!("Could not find `{}` in `{}`", name, module_name)
|
||||
};
|
||||
|
||||
return Failed(span.map(|span| (span, msg)));
|
||||
|
|
@ -1649,7 +1648,7 @@ impl<'a> Resolver<'a> {
|
|||
/// grammar: (SELF MOD_SEP ) ? (SUPER MOD_SEP) *
|
||||
fn resolve_module_prefix(&mut self, module_path: &[Ident], span: Option<Span>)
|
||||
-> ResolveResult<ModulePrefixResult<'a>> {
|
||||
if &*module_path[0].name.as_str() == "$crate" {
|
||||
if module_path[0].name == "$crate" {
|
||||
return Success(PrefixFound(self.resolve_crate_var(module_path[0].ctxt), 1));
|
||||
}
|
||||
|
||||
|
|
@ -1665,7 +1664,7 @@ impl<'a> Resolver<'a> {
|
|||
self.module_map[&self.current_module.normal_ancestor_id.unwrap()];
|
||||
|
||||
// Now loop through all the `super`s we find.
|
||||
while i < module_path.len() && "super" == module_path[i].name.as_str() {
|
||||
while i < module_path.len() && module_path[i].name == "super" {
|
||||
debug!("(resolving module prefix) resolving `super` at {}",
|
||||
module_to_string(&containing_module));
|
||||
if let Some(parent) = containing_module.parent {
|
||||
|
|
@ -2633,7 +2632,7 @@ impl<'a> Resolver<'a> {
|
|||
let qualified_binding = self.resolve_module_relative_path(span, segments, namespace);
|
||||
match (qualified_binding, unqualified_def) {
|
||||
(Ok(binding), Some(ref ud)) if binding.def() == ud.def &&
|
||||
segments[0].identifier.name.as_str() != "$crate" => {
|
||||
segments[0].identifier.name != "$crate" => {
|
||||
self.session
|
||||
.add_lint(lint::builtin::UNUSED_QUALIFICATIONS,
|
||||
id,
|
||||
|
|
@ -2879,7 +2878,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
fn find_best_match(&mut self, name: &str) -> SuggestionType {
|
||||
if let Some(macro_name) = self.macro_names.iter().find(|n| n.as_str() == name) {
|
||||
if let Some(macro_name) = self.macro_names.iter().find(|&n| n == &name) {
|
||||
return SuggestionType::Macro(format!("{}!", macro_name));
|
||||
}
|
||||
|
||||
|
|
@ -2889,7 +2888,7 @@ impl<'a> Resolver<'a> {
|
|||
.flat_map(|rib| rib.bindings.keys().map(|ident| &ident.name));
|
||||
|
||||
if let Some(found) = find_best_match_for_name(names, name, None) {
|
||||
if name != found {
|
||||
if found != name {
|
||||
return SuggestionType::Function(found);
|
||||
}
|
||||
} SuggestionType::NotFound
|
||||
|
|
@ -2998,8 +2997,7 @@ impl<'a> Resolver<'a> {
|
|||
false // Stop advancing
|
||||
});
|
||||
|
||||
if method_scope &&
|
||||
&path_name[..] == keywords::SelfValue.name().as_str() {
|
||||
if method_scope && keywords::SelfValue.name() == &*path_name {
|
||||
resolve_error(self,
|
||||
expr.span,
|
||||
ResolutionError::SelfNotAvailableInStaticMethod);
|
||||
|
|
@ -3604,7 +3602,7 @@ fn module_to_string(module: Module) -> String {
|
|||
}
|
||||
} else {
|
||||
// danger, shouldn't be ident?
|
||||
names.push(token::str_to_ident("<opaque>"));
|
||||
names.push(Ident::from_str("<opaque>"));
|
||||
collect_mod(names, module.parent.unwrap());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ use syntax::ext::expand::Expansion;
|
|||
use syntax::ext::hygiene::Mark;
|
||||
use syntax::ext::tt::macro_rules;
|
||||
use syntax::fold::Folder;
|
||||
use syntax::parse::token::intern;
|
||||
use syntax::ptr::P;
|
||||
use syntax::util::lev_distance::find_best_match_for_name;
|
||||
use syntax::visit::Visitor;
|
||||
|
|
@ -116,7 +115,7 @@ impl<'a> base::Resolver for Resolver<'a> {
|
|||
impl<'a, 'b> Folder for EliminateCrateVar<'a, 'b> {
|
||||
fn fold_path(&mut self, mut path: ast::Path) -> ast::Path {
|
||||
let ident = path.segments[0].identifier;
|
||||
if &ident.name.as_str() == "$crate" {
|
||||
if ident.name == "$crate" {
|
||||
path.global = true;
|
||||
let module = self.0.resolve_crate_var(ident.ctxt);
|
||||
if module.is_local() {
|
||||
|
|
@ -152,7 +151,7 @@ impl<'a> base::Resolver for Resolver<'a> {
|
|||
}
|
||||
|
||||
fn add_macro(&mut self, scope: Mark, mut def: ast::MacroDef, export: bool) {
|
||||
if &def.ident.name.as_str() == "macro_rules" {
|
||||
if def.ident.name == "macro_rules" {
|
||||
self.session.span_err(def.span, "user-defined macros may not be named `macro_rules`");
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +206,7 @@ impl<'a> base::Resolver for Resolver<'a> {
|
|||
|
||||
fn find_attr_invoc(&mut self, attrs: &mut Vec<ast::Attribute>) -> Option<ast::Attribute> {
|
||||
for i in 0..attrs.len() {
|
||||
let name = intern(&attrs[i].name());
|
||||
match self.builtin_macros.get(&name).cloned() {
|
||||
match self.builtin_macros.get(&attrs[i].name()).cloned() {
|
||||
Some(binding) => match *self.get_macro(binding) {
|
||||
MultiModifier(..) | MultiDecorator(..) | SyntaxExtension::AttrProcMacro(..) => {
|
||||
return Some(attrs.remove(i))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ use std::collections::hash_map::DefaultHasher;
|
|||
use std::hash::*;
|
||||
|
||||
use syntax::ast::{self, NodeId, PatKind, Attribute, CRATE_NODE_ID};
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax::print::pprust::{path_to_string, ty_to_string, bounds_to_string, generics_to_string};
|
||||
use syntax::ptr::P;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use syntax::ast::{self, NodeId, PatKind, Attribute, CRATE_NODE_ID};
|
||||
use syntax::parse::lexer::comments::strip_doc_comment_decoration;
|
||||
use syntax::parse::token::{self, keywords, InternedString};
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax::print::pprust::{ty_to_string, arg_to_string};
|
||||
use syntax::codemap::MacroAttribute;
|
||||
|
|
@ -119,7 +120,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
};
|
||||
result.push(CrateData {
|
||||
name: (&self.tcx.sess.cstore.crate_name(n)[..]).to_owned(),
|
||||
name: self.tcx.sess.cstore.crate_name(n).to_string(),
|
||||
number: n.as_u32(),
|
||||
span: span,
|
||||
});
|
||||
|
|
@ -728,16 +729,16 @@ impl Visitor for PathCollector {
|
|||
}
|
||||
|
||||
fn docs_for_attrs(attrs: &[Attribute]) -> String {
|
||||
let doc = InternedString::new("doc");
|
||||
let doc = Symbol::intern("doc");
|
||||
let mut result = String::new();
|
||||
|
||||
for attr in attrs {
|
||||
if attr.name() == doc {
|
||||
if let Some(ref val) = attr.value_str() {
|
||||
if attr.node.is_sugared_doc {
|
||||
result.push_str(&strip_doc_comment_decoration(val));
|
||||
if let Some(val) = attr.value_str() {
|
||||
if attr.is_sugared_doc {
|
||||
result.push_str(&strip_doc_comment_decoration(&val.as_str()));
|
||||
} else {
|
||||
result.push_str(val);
|
||||
result.push_str(&val.as_str());
|
||||
}
|
||||
result.push('\n');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ use std::path::Path;
|
|||
|
||||
use syntax::ast;
|
||||
use syntax::parse::lexer::{self, Reader, StringReader};
|
||||
use syntax::parse::token::{self, keywords, Token};
|
||||
use syntax::parse::token::{self, Token};
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
AsmDialect::Intel => llvm::AsmDialect::Intel,
|
||||
};
|
||||
|
||||
let asm = CString::new(ia.asm.as_bytes()).unwrap();
|
||||
let asm = CString::new(ia.asm.as_str().as_bytes()).unwrap();
|
||||
let constraint_cstr = CString::new(all_constraints).unwrap();
|
||||
let r = InlineAsmCall(bcx,
|
||||
asm.as_ptr(),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
use rustc::ty::TyCtxt;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
|
||||
use {ModuleSource, ModuleTranslation};
|
||||
|
||||
|
|
@ -77,7 +76,7 @@ impl<'a, 'tcx> AssertModuleSource<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let mname = self.field(attr, MODULE);
|
||||
let mtrans = self.modules.iter().find(|mtrans| &mtrans.name[..] == &mname[..]);
|
||||
let mtrans = self.modules.iter().find(|mtrans| *mtrans.name == *mname.as_str());
|
||||
let mtrans = match mtrans {
|
||||
Some(m) => m,
|
||||
None => {
|
||||
|
|
@ -113,7 +112,7 @@ impl<'a, 'tcx> AssertModuleSource<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn field(&self, attr: &ast::Attribute, name: &str) -> InternedString {
|
||||
fn field(&self, attr: &ast::Attribute, name: &str) -> ast::Name {
|
||||
for item in attr.meta_item_list().unwrap_or(&[]) {
|
||||
if item.check_name(name) {
|
||||
if let Some(value) = item.value_str() {
|
||||
|
|
@ -137,7 +136,7 @@ impl<'a, 'tcx> AssertModuleSource<'a, 'tcx> {
|
|||
let config = &self.tcx.sess.parse_sess.config;
|
||||
let value = self.field(attr, CFG);
|
||||
debug!("check_config(config={:?}, value={:?})", config, value);
|
||||
if config.iter().any(|c| c.check_name(&value[..])) {
|
||||
if config.iter().any(|&(name, _)| name == value) {
|
||||
debug!("check_config: matched");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ use std::str;
|
|||
use flate;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
|
||||
// RLIB LLVM-BYTECODE OBJECT LAYOUT
|
||||
|
|
@ -93,8 +94,8 @@ pub fn find_crate_name(sess: Option<&Session>,
|
|||
|
||||
if let Some(sess) = sess {
|
||||
if let Some(ref s) = sess.opts.crate_name {
|
||||
if let Some((attr, ref name)) = attr_crate_name {
|
||||
if *s != &name[..] {
|
||||
if let Some((attr, name)) = attr_crate_name {
|
||||
if name != &**s {
|
||||
let msg = format!("--crate-name and #[crate_name] are \
|
||||
required to match, but `{}` != `{}`",
|
||||
s, name);
|
||||
|
|
@ -130,7 +131,7 @@ pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap,
|
|||
name: &str)
|
||||
-> LinkMeta {
|
||||
let r = LinkMeta {
|
||||
crate_name: name.to_owned(),
|
||||
crate_name: Symbol::intern(name),
|
||||
crate_hash: Svh::new(incremental_hashes_map[&DepNode::Krate].to_smaller_hash()),
|
||||
};
|
||||
info!("{:?}", r);
|
||||
|
|
@ -429,7 +430,7 @@ fn link_rlib<'a>(sess: &'a Session,
|
|||
NativeLibraryKind::NativeFramework |
|
||||
NativeLibraryKind::NativeUnknown => continue,
|
||||
}
|
||||
ab.add_native_library(&lib.name);
|
||||
ab.add_native_library(&lib.name.as_str());
|
||||
}
|
||||
|
||||
// After adding all files to the archive, we need to update the
|
||||
|
|
@ -615,7 +616,7 @@ fn link_staticlib(sess: &Session, objects: &[PathBuf], out_filename: &Path,
|
|||
let skip_object_files = native_libs.iter().any(|lib| {
|
||||
lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib)
|
||||
});
|
||||
ab.add_rlib(path, &name, sess.lto(), skip_object_files).unwrap();
|
||||
ab.add_rlib(path, &name.as_str(), sess.lto(), skip_object_files).unwrap();
|
||||
|
||||
all_native_libs.extend(sess.cstore.native_libraries(cnum));
|
||||
});
|
||||
|
|
@ -934,15 +935,15 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
|
|||
// don't otherwise explicitly reference them. This can occur for
|
||||
// libraries which are just providing bindings, libraries with generic
|
||||
// functions, etc.
|
||||
cmd.link_whole_staticlib(&l.name, &search_path);
|
||||
cmd.link_whole_staticlib(&l.name.as_str(), &search_path);
|
||||
}
|
||||
|
||||
cmd.hint_dynamic();
|
||||
|
||||
for lib in others {
|
||||
match lib.kind {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name),
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name.as_str()),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name.as_str()),
|
||||
NativeLibraryKind::NativeStatic => bug!(),
|
||||
}
|
||||
}
|
||||
|
|
@ -1185,8 +1186,8 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session) {
|
|||
continue
|
||||
}
|
||||
match lib.kind {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name),
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name.as_str()),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name.as_str()),
|
||||
|
||||
// ignore statically included native libraries here as we've
|
||||
// already included them when we included the rust library
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ use rustc::hir::map::definitions::{DefPath, DefPathData};
|
|||
use rustc::util::common::record_time;
|
||||
|
||||
use syntax::attr;
|
||||
use syntax::parse::token::{self, InternedString};
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
|
||||
fn get_symbol_hash<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ impl ItemPathBuffer for SymbolPathBuffer {
|
|||
}
|
||||
|
||||
fn push(&mut self, text: &str) {
|
||||
self.names.push(token::intern(text).as_str());
|
||||
self.names.push(Symbol::intern(text).as_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ pub fn exported_name_from_type_and_prefix<'a, 'tcx>(scx: &SharedCrateContext<'a,
|
|||
krate: LOCAL_CRATE,
|
||||
};
|
||||
let hash = get_symbol_hash(scx, &empty_def_path, t, None);
|
||||
let path = [token::intern_and_get_ident(prefix)];
|
||||
let path = [Symbol::intern(prefix).as_str()];
|
||||
mangle(path.iter().cloned(), &hash)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1128,11 +1128,11 @@ pub fn set_link_section(ccx: &CrateContext,
|
|||
llval: ValueRef,
|
||||
attrs: &[ast::Attribute]) {
|
||||
if let Some(sect) = attr::first_attr_value_str_by_name(attrs, "link_section") {
|
||||
if contains_null(§) {
|
||||
if contains_null(§.as_str()) {
|
||||
ccx.sess().fatal(&format!("Illegal null byte in link_section value: `{}`", §));
|
||||
}
|
||||
unsafe {
|
||||
let buf = CString::new(sect.as_bytes()).unwrap();
|
||||
let buf = CString::new(sect.as_str().as_bytes()).unwrap();
|
||||
llvm::LLVMSetSection(llval, buf.as_ptr());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
|||
-> bool {
|
||||
(bare_fn_ty.abi == Abi::RustIntrinsic ||
|
||||
bare_fn_ty.abi == Abi::PlatformIntrinsic) &&
|
||||
tcx.item_name(def_id).as_str() == "drop_in_place"
|
||||
tcx.item_name(def_id) == "drop_in_place"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ use std::ffi::CString;
|
|||
use std::cell::{Cell, RefCell, Ref};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
|
||||
pub use context::{CrateContext, SharedCrateContext};
|
||||
|
|
@ -225,7 +224,7 @@ impl<'a, 'tcx> VariantInfo<'tcx> {
|
|||
VariantInfo {
|
||||
discr: Disr(0),
|
||||
fields: v.iter().enumerate().map(|(i, &t)| {
|
||||
Field(token::intern(&i.to_string()), t)
|
||||
Field(Symbol::intern(&i.to_string()), t)
|
||||
}).collect()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef {
|
|||
// extern "C" fn() from being non-null, so we can't just declare a
|
||||
// static and call it a day. Some linkages (like weak) will make it such
|
||||
// that the static actually has a null value.
|
||||
let linkage = match base::llvm_linkage_by_name(&name) {
|
||||
let linkage = match base::llvm_linkage_by_name(&name.as_str()) {
|
||||
Some(linkage) => linkage,
|
||||
None => {
|
||||
ccx.sess().span_fatal(span, "invalid linkage specified");
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ use std::ptr;
|
|||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::symbol::InternedString;
|
||||
use abi::FnType;
|
||||
|
||||
pub struct Stats {
|
||||
|
|
|
|||
|
|
@ -44,10 +44,8 @@ use std::ffi::CString;
|
|||
use std::fmt::Write;
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use syntax::util::interner::Interner;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::{Interner, InternedString};
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
|
||||
|
|
@ -117,9 +115,8 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
unique_type_id: UniqueTypeId,
|
||||
metadata: DIType) {
|
||||
if self.unique_id_to_metadata.insert(unique_type_id, metadata).is_some() {
|
||||
let unique_type_id_str = self.get_unique_type_id_as_string(unique_type_id);
|
||||
bug!("Type metadata for unique id '{}' is already in the TypeMap!",
|
||||
&unique_type_id_str[..]);
|
||||
self.get_unique_type_id_as_string(unique_type_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +130,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
|
||||
// Get the string representation of a UniqueTypeId. This method will fail if
|
||||
// the id is unknown.
|
||||
fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> Rc<str> {
|
||||
fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> &str {
|
||||
let UniqueTypeId(interner_key) = unique_type_id;
|
||||
self.unique_id_interner.get(interner_key)
|
||||
}
|
||||
|
|
@ -182,7 +179,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
-> UniqueTypeId {
|
||||
let enum_type_id = self.get_unique_type_id_of_type(cx, enum_type);
|
||||
let enum_variant_type_id = format!("{}::{}",
|
||||
&self.get_unique_type_id_as_string(enum_type_id),
|
||||
self.get_unique_type_id_as_string(enum_type_id),
|
||||
variant_name);
|
||||
let interner_key = self.unique_id_interner.intern(&enum_variant_type_id);
|
||||
UniqueTypeId(interner_key)
|
||||
|
|
@ -623,14 +620,12 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let metadata_for_uid = match type_map.find_metadata_for_unique_id(unique_type_id) {
|
||||
Some(metadata) => metadata,
|
||||
None => {
|
||||
let unique_type_id_str =
|
||||
type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
span_bug!(usage_site_span,
|
||||
"Expected type metadata for unique \
|
||||
type id '{}' to already be in \
|
||||
the debuginfo::TypeMap but it \
|
||||
was not. (Ty = {})",
|
||||
&unique_type_id_str[..],
|
||||
type_map.get_unique_type_id_as_string(unique_type_id),
|
||||
t);
|
||||
}
|
||||
};
|
||||
|
|
@ -638,14 +633,12 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
match type_map.find_metadata_for_type(t) {
|
||||
Some(metadata) => {
|
||||
if metadata != metadata_for_uid {
|
||||
let unique_type_id_str =
|
||||
type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
span_bug!(usage_site_span,
|
||||
"Mismatch between Ty and \
|
||||
UniqueTypeId maps in \
|
||||
debuginfo::TypeMap. \
|
||||
UniqueTypeId={}, Ty={}",
|
||||
&unique_type_id_str[..],
|
||||
type_map.get_unique_type_id_as_string(unique_type_id),
|
||||
t);
|
||||
}
|
||||
}
|
||||
|
|
@ -809,7 +802,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
|
|||
};
|
||||
|
||||
fn fallback_path(scc: &SharedCrateContext) -> CString {
|
||||
CString::new(scc.link_meta().crate_name.clone()).unwrap()
|
||||
CString::new(scc.link_meta().crate_name.to_string()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1526,13 +1519,10 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let enum_llvm_type = type_of::type_of(cx, enum_type);
|
||||
let (enum_type_size, enum_type_align) = size_and_align_of(cx, enum_llvm_type);
|
||||
|
||||
let unique_type_id_str = debug_context(cx)
|
||||
.type_map
|
||||
.borrow()
|
||||
.get_unique_type_id_as_string(unique_type_id);
|
||||
|
||||
let enum_name = CString::new(enum_name).unwrap();
|
||||
let unique_type_id_str = CString::new(unique_type_id_str.as_bytes()).unwrap();
|
||||
let unique_type_id_str = CString::new(
|
||||
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id).as_bytes()
|
||||
).unwrap();
|
||||
let enum_metadata = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
|
|
@ -1566,7 +1556,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
fn get_enum_discriminant_name(cx: &CrateContext,
|
||||
def_id: DefId)
|
||||
-> token::InternedString {
|
||||
-> InternedString {
|
||||
cx.tcx().item_name(def_id).as_str()
|
||||
}
|
||||
}
|
||||
|
|
@ -1669,11 +1659,10 @@ fn create_struct_stub(cx: &CrateContext,
|
|||
-> DICompositeType {
|
||||
let (struct_size, struct_align) = size_and_align_of(cx, struct_llvm_type);
|
||||
|
||||
let unique_type_id_str = debug_context(cx).type_map
|
||||
.borrow()
|
||||
.get_unique_type_id_as_string(unique_type_id);
|
||||
let name = CString::new(struct_type_name).unwrap();
|
||||
let unique_type_id = CString::new(unique_type_id_str.as_bytes()).unwrap();
|
||||
let unique_type_id = CString::new(
|
||||
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id).as_bytes()
|
||||
).unwrap();
|
||||
let metadata_stub = unsafe {
|
||||
// LLVMRustDIBuilderCreateStructType() wants an empty array. A null
|
||||
// pointer will lead to hard to trace and debug LLVM assertions
|
||||
|
|
@ -1707,11 +1696,10 @@ fn create_union_stub(cx: &CrateContext,
|
|||
-> DICompositeType {
|
||||
let (union_size, union_align) = size_and_align_of(cx, union_llvm_type);
|
||||
|
||||
let unique_type_id_str = debug_context(cx).type_map
|
||||
.borrow()
|
||||
.get_unique_type_id_as_string(unique_type_id);
|
||||
let name = CString::new(union_type_name).unwrap();
|
||||
let unique_type_id = CString::new(unique_type_id_str.as_bytes()).unwrap();
|
||||
let unique_type_id = CString::new(
|
||||
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id).as_bytes()
|
||||
).unwrap();
|
||||
let metadata_stub = unsafe {
|
||||
// LLVMRustDIBuilderCreateUnionType() wants an empty array. A null
|
||||
// pointer will lead to hard to trace and debug LLVM assertions
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub fn mangled_name_of_item(ccx: &CrateContext, def_id: DefId, extra: &str) -> S
|
|||
}
|
||||
|
||||
let name = match def_key.disambiguated_data.data {
|
||||
DefPathData::CrateRoot => ccx.tcx().crate_name(def_id.krate),
|
||||
DefPathData::CrateRoot => ccx.tcx().crate_name(def_id.krate).as_str(),
|
||||
data => data.as_interned_str()
|
||||
};
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ pub fn item_namespace(ccx: &CrateContext, def_id: DefId) -> DIScope {
|
|||
});
|
||||
|
||||
let namespace_name = match def_key.disambiguated_data.data {
|
||||
DefPathData::CrateRoot => ccx.tcx().crate_name(def_id.krate),
|
||||
DefPathData::CrateRoot => ccx.tcx().crate_name(def_id.krate).as_str(),
|
||||
data => data.as_interned_str()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
qualified: bool,
|
||||
output: &mut String) {
|
||||
if qualified {
|
||||
output.push_str(&cx.tcx().crate_name(def_id.krate));
|
||||
output.push_str(&cx.tcx().crate_name(def_id.krate).as_str());
|
||||
for path_element in cx.tcx().def_path(def_id).data {
|
||||
output.push_str("::");
|
||||
output.push_str(&path_element.data.as_interned_str());
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use rustc::ty::{self, Ty};
|
|||
use Disr;
|
||||
use rustc::hir;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use rustc::session::Session;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
|
@ -107,7 +107,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
let sig = tcx.erase_late_bound_regions_and_normalize(&fty.sig);
|
||||
let arg_tys = sig.inputs;
|
||||
let ret_ty = sig.output;
|
||||
let name = tcx.item_name(def_id).as_str();
|
||||
let name = &*tcx.item_name(def_id).as_str();
|
||||
|
||||
let span = match call_debug_location {
|
||||
DebugLoc::ScopeAt(_, span) => span,
|
||||
|
|
@ -123,15 +123,15 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
Call(bcx, llfn, &[], call_debug_location);
|
||||
Unreachable(bcx);
|
||||
return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to()));
|
||||
} else if &name[..] == "unreachable" {
|
||||
} else if name == "unreachable" {
|
||||
Unreachable(bcx);
|
||||
return Result::new(bcx, C_nil(ccx));
|
||||
}
|
||||
|
||||
let llret_ty = type_of::type_of(ccx, ret_ty);
|
||||
|
||||
let simple = get_simple_intrinsic(ccx, &name);
|
||||
let llval = match (simple, &name[..]) {
|
||||
let simple = get_simple_intrinsic(ccx, name);
|
||||
let llval = match (simple, name) {
|
||||
(Some(llfn), _) => {
|
||||
Call(bcx, llfn, &llargs, call_debug_location)
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
(_, "type_name") => {
|
||||
let tp_ty = substs.type_at(0);
|
||||
let ty_name = token::intern_and_get_ident(&tp_ty.to_string());
|
||||
let ty_name = Symbol::intern(&tp_ty.to_string()).as_str();
|
||||
C_str_slice(ccx, ty_name)
|
||||
}
|
||||
(_, "type_id") => {
|
||||
|
|
@ -340,7 +340,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
let sty = &arg_tys[0].sty;
|
||||
match int_type_width_signed(sty, ccx) {
|
||||
Some((width, signed)) =>
|
||||
match &*name {
|
||||
match name {
|
||||
"ctlz" => count_zeros_intrinsic(bcx, &format!("llvm.ctlz.i{}", width),
|
||||
llargs[0], call_debug_location),
|
||||
"cttz" => count_zeros_intrinsic(bcx, &format!("llvm.cttz.i{}", width),
|
||||
|
|
@ -394,7 +394,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
let sty = &arg_tys[0].sty;
|
||||
match float_type_width(sty) {
|
||||
Some(_width) =>
|
||||
match &*name {
|
||||
match name {
|
||||
"fadd_fast" => FAddFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
"fsub_fast" => FSubFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
"fmul_fast" => FMulFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use glue;
|
|||
use type_::Type;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use super::{MirContext, LocalRef};
|
||||
use super::analyze::CleanupKind;
|
||||
|
|
@ -324,7 +324,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
|
||||
// Get the location information.
|
||||
let loc = bcx.sess().codemap().lookup_char_pos(span.lo);
|
||||
let filename = token::intern_and_get_ident(&loc.file.name);
|
||||
let filename = Symbol::intern(&loc.file.name).as_str();
|
||||
let filename = C_str_slice(bcx.ccx(), filename);
|
||||
let line = C_u32(bcx.ccx(), loc.line as u32);
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
const_err)
|
||||
}
|
||||
mir::AssertMessage::Math(ref err) => {
|
||||
let msg_str = token::intern_and_get_ident(err.description());
|
||||
let msg_str = Symbol::intern(err.description()).as_str();
|
||||
let msg_str = C_str_slice(bcx.ccx(), msg_str);
|
||||
let msg_file_line = C_struct(bcx.ccx(),
|
||||
&[msg_str, filename, line],
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use machine;
|
|||
use type_of;
|
||||
|
||||
use syntax_pos::{DUMMY_SP, NO_EXPANSION, COMMAND_LINE_EXPN, BytePos};
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::symbol::keywords;
|
||||
|
||||
use std::cell::Ref;
|
||||
use std::iter;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ use std::sync::Arc;
|
|||
use std::collections::hash_map::DefaultHasher;
|
||||
use symbol_map::SymbolMap;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::parse::token::{self, InternedString};
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use trans_item::TransItem;
|
||||
use util::nodemap::{FxHashMap, FxHashSet};
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
|||
// If the partitioning should produce a fixed count of codegen units, merge
|
||||
// until that count is reached.
|
||||
if let PartitioningStrategy::FixedUnitCount(count) = strategy {
|
||||
merge_codegen_units(&mut initial_partitioning, count, &tcx.crate_name[..]);
|
||||
merge_codegen_units(&mut initial_partitioning, count, &tcx.crate_name.as_str());
|
||||
|
||||
debug_dump(scx, "POST MERGING:", initial_partitioning.codegen_units.iter());
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
|||
|
||||
let codegen_unit_name = match characteristic_def_id {
|
||||
Some(def_id) => compute_codegen_unit_name(tcx, def_id, is_volatile),
|
||||
None => InternedString::new(FALLBACK_CODEGEN_UNIT),
|
||||
None => Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str(),
|
||||
};
|
||||
|
||||
let make_codegen_unit = || {
|
||||
|
|
@ -365,7 +365,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
|||
// always ensure we have at least one CGU; otherwise, if we have a
|
||||
// crate with just types (for example), we could wind up with no CGU
|
||||
if codegen_units.is_empty() {
|
||||
let codegen_unit_name = InternedString::new(FALLBACK_CODEGEN_UNIT);
|
||||
let codegen_unit_name = Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str();
|
||||
codegen_units.entry(codegen_unit_name.clone())
|
||||
.or_insert_with(|| CodegenUnit::empty(codegen_unit_name.clone()));
|
||||
}
|
||||
|
|
@ -523,7 +523,7 @@ fn compute_codegen_unit_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
let mut mod_path = String::with_capacity(64);
|
||||
|
||||
let def_path = tcx.def_path(def_id);
|
||||
mod_path.push_str(&tcx.crate_name(def_path.krate));
|
||||
mod_path.push_str(&tcx.crate_name(def_path.krate).as_str());
|
||||
|
||||
for part in tcx.def_path(def_id)
|
||||
.data
|
||||
|
|
@ -542,14 +542,11 @@ fn compute_codegen_unit_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
mod_path.push_str(".volatile");
|
||||
}
|
||||
|
||||
return token::intern_and_get_ident(&mod_path[..]);
|
||||
return Symbol::intern(&mod_path[..]).as_str();
|
||||
}
|
||||
|
||||
fn numbered_codegen_unit_name(crate_name: &str, index: usize) -> InternedString {
|
||||
token::intern_and_get_ident(&format!("{}{}{}",
|
||||
crate_name,
|
||||
NUMBERED_CODEGEN_UNIT_MARKER,
|
||||
index)[..])
|
||||
Symbol::intern(&format!("{}{}{}", crate_name, NUMBERED_CODEGEN_UNIT_MARKER, index)).as_str()
|
||||
}
|
||||
|
||||
fn debug_dump<'a, 'b, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
|||
|
||||
let attributes = tcx.get_attrs(def_id);
|
||||
if let Some(name) = attr::first_attr_value_str_by_name(&attributes, "linkage") {
|
||||
if let Some(linkage) = base::llvm_linkage_by_name(&name) {
|
||||
if let Some(linkage) = base::llvm_linkage_by_name(&name.as_str()) {
|
||||
Some(linkage)
|
||||
} else {
|
||||
let span = tcx.map.span_if_local(def_id);
|
||||
|
|
@ -531,7 +531,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
|||
|
||||
// some_crate::
|
||||
if !(self.omit_local_crate_name && def_id.is_local()) {
|
||||
output.push_str(&self.tcx.crate_name(def_path.krate));
|
||||
output.push_str(&self.tcx.crate_name(def_path.krate).as_str());
|
||||
output.push_str("::");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ use util::nodemap::{NodeMap, FxHashSet};
|
|||
use std::cell::RefCell;
|
||||
use syntax::{abi, ast};
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax_pos::{Span, Pos};
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
|
|
@ -645,7 +645,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
};
|
||||
|
||||
let output_binding = ConvertedBinding {
|
||||
item_name: token::intern(FN_OUTPUT_NAME),
|
||||
item_name: Symbol::intern(FN_OUTPUT_NAME),
|
||||
ty: output,
|
||||
span: output_span
|
||||
};
|
||||
|
|
@ -1252,7 +1252,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
if bounds.len() > 1 {
|
||||
let spans = bounds.iter().map(|b| {
|
||||
self.tcx().associated_items(b.def_id()).find(|item| {
|
||||
item.kind == ty::AssociatedKind::Type && item.name.as_str() == assoc_name
|
||||
item.kind == ty::AssociatedKind::Type && item.name == assoc_name
|
||||
})
|
||||
.and_then(|item| self.tcx().map.as_local_node_id(item.def_id))
|
||||
.and_then(|node_id| self.tcx().map.opt_span(node_id))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use rustc::ty::{LvaluePreference, NoPreference, PreferMutLvalue};
|
|||
use rustc::hir;
|
||||
|
||||
use syntax_pos::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
enum AutoderefKind {
|
||||
|
|
@ -120,7 +120,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
|
|||
let normalized = traits::normalize_projection_type(&mut selcx,
|
||||
ty::ProjectionTy {
|
||||
trait_ref: trait_ref,
|
||||
item_name: token::intern("Target"),
|
||||
item_name: Symbol::intern("Target"),
|
||||
},
|
||||
cause,
|
||||
0);
|
||||
|
|
@ -198,7 +198,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
(PreferMutLvalue, Some(trait_did)) => {
|
||||
self.lookup_method_in_trait(span,
|
||||
base_expr,
|
||||
token::intern("deref_mut"),
|
||||
Symbol::intern("deref_mut"),
|
||||
trait_did,
|
||||
base_ty,
|
||||
None)
|
||||
|
|
@ -211,7 +211,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
(None, Some(trait_did)) => {
|
||||
self.lookup_method_in_trait(span,
|
||||
base_expr,
|
||||
token::intern("deref"),
|
||||
Symbol::intern("deref"),
|
||||
trait_did,
|
||||
base_ty,
|
||||
None)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use hir::def_id::{DefId, LOCAL_CRATE};
|
|||
use hir::print;
|
||||
use rustc::{infer, traits};
|
||||
use rustc::ty::{self, LvaluePreference, Ty};
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::Span;
|
||||
|
||||
|
|
@ -160,9 +160,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
-> Option<ty::MethodCallee<'tcx>> {
|
||||
// Try the options that are least restrictive on the caller first.
|
||||
for &(opt_trait_def_id, method_name) in
|
||||
&[(self.tcx.lang_items.fn_trait(), token::intern("call")),
|
||||
(self.tcx.lang_items.fn_mut_trait(), token::intern("call_mut")),
|
||||
(self.tcx.lang_items.fn_once_trait(), token::intern("call_once"))] {
|
||||
&[(self.tcx.lang_items.fn_trait(), Symbol::intern("call")),
|
||||
(self.tcx.lang_items.fn_mut_trait(), Symbol::intern("call_mut")),
|
||||
(self.tcx.lang_items.fn_once_trait(), Symbol::intern("call_once"))] {
|
||||
let trait_def_id = match opt_trait_def_id {
|
||||
Some(def_id) => def_id,
|
||||
None => continue,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use {CrateCtxt, require_same_types};
|
|||
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::hir;
|
||||
|
|
@ -75,7 +75,7 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
/// and in libcore/intrinsics.rs
|
||||
pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
|
||||
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
|
||||
let name = token::intern(&format!("P{}", n));
|
||||
let name = Symbol::intern(&format!("P{}", n));
|
||||
ccx.tcx.mk_param(n, name)
|
||||
}
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
|
|||
pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
|
||||
it: &hir::ForeignItem) {
|
||||
let param = |n| {
|
||||
let name = token::intern(&format!("P{}", n));
|
||||
let name = Symbol::intern(&format!("P{}", n));
|
||||
ccx.tcx.mk_param(n, name)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let def = pick.item.def();
|
||||
if let probe::InherentImplPick = pick.kind {
|
||||
if !pick.item.vis.is_accessible_from(self.body_id, &self.tcx.map) {
|
||||
let msg = format!("{} `{}` is private", def.kind_name(), &method_name.as_str());
|
||||
let msg = format!("{} `{}` is private", def.kind_name(), method_name);
|
||||
self.tcx.sess.span_err(span, &msg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ use syntax::ast;
|
|||
use syntax::attr;
|
||||
use syntax::codemap::{self, original_sp, Spanned};
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax::parse::token::{self, InternedString, keywords};
|
||||
use syntax::ptr::P;
|
||||
use syntax::symbol::{Symbol, InternedString, keywords};
|
||||
use syntax::util::lev_distance::find_best_match_for_name;
|
||||
use syntax_pos::{self, BytePos, Span};
|
||||
|
||||
|
|
@ -931,7 +931,8 @@ fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
if let Some(ref attr) = item.attrs.iter().find(|a| {
|
||||
a.check_name("rustc_on_unimplemented")
|
||||
}) {
|
||||
if let Some(ref istring) = attr.value_str() {
|
||||
if let Some(istring) = attr.value_str() {
|
||||
let istring = istring.as_str();
|
||||
let parser = Parser::new(&istring);
|
||||
let types = &generics.types;
|
||||
for token in parser {
|
||||
|
|
@ -942,7 +943,7 @@ fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
Position::ArgumentNamed(s) if s == "Self" => (),
|
||||
// So is `{A}` if A is a type parameter
|
||||
Position::ArgumentNamed(s) => match types.iter().find(|t| {
|
||||
t.name.as_str() == s
|
||||
t.name == s
|
||||
}) {
|
||||
Some(_) => (),
|
||||
None => {
|
||||
|
|
@ -2369,7 +2370,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
(PreferMutLvalue, Some(trait_did)) => {
|
||||
self.lookup_method_in_trait_adjusted(expr.span,
|
||||
Some(&base_expr),
|
||||
token::intern("index_mut"),
|
||||
Symbol::intern("index_mut"),
|
||||
trait_did,
|
||||
autoderefs,
|
||||
unsize,
|
||||
|
|
@ -2384,7 +2385,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
(None, Some(trait_did)) => {
|
||||
self.lookup_method_in_trait_adjusted(expr.span,
|
||||
Some(&base_expr),
|
||||
token::intern("index"),
|
||||
Symbol::intern("index"),
|
||||
trait_did,
|
||||
autoderefs,
|
||||
unsize,
|
||||
|
|
@ -3027,7 +3028,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
fn suggest_field_name(variant: ty::VariantDef<'tcx>,
|
||||
field: &Spanned<ast::Name>,
|
||||
skip : Vec<InternedString>)
|
||||
-> Option<InternedString> {
|
||||
-> Option<Symbol> {
|
||||
let name = field.node.as_str();
|
||||
let names = variant.fields.iter().filter_map(|field| {
|
||||
// ignore already set fields and private fields from non-local crates
|
||||
|
|
@ -3126,7 +3127,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::TyAdt(adt, ..) if adt.is_enum() => {
|
||||
struct_span_err!(self.tcx.sess, field.name.span, E0559,
|
||||
"{} `{}::{}` has no field named `{}`",
|
||||
kind_name, actual, variant.name.as_str(), field.name.node)
|
||||
kind_name, actual, variant.name, field.name.node)
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(self.tcx.sess, field.name.span, E0560,
|
||||
|
|
@ -3146,7 +3147,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
match ty.sty {
|
||||
ty::TyAdt(adt, ..) if adt.is_enum() => {
|
||||
err.span_label(field.name.span, &format!("`{}::{}` does not have this field",
|
||||
ty, variant.name.as_str()));
|
||||
ty, variant.name));
|
||||
}
|
||||
_ => {
|
||||
err.span_label(field.name.span, &format!("`{}` does not have this field", ty));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use super::FnCtxt;
|
|||
use hir::def_id::DefId;
|
||||
use rustc::ty::{Ty, TypeFoldable, PreferMutLvalue};
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::Symbol;
|
||||
use rustc::hir;
|
||||
|
||||
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
|
@ -182,7 +182,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let rhs_ty_var = self.next_ty_var();
|
||||
|
||||
let return_ty = match self.lookup_op_method(expr, lhs_ty, vec![rhs_ty_var],
|
||||
token::intern(name), trait_def_id,
|
||||
Symbol::intern(name), trait_def_id,
|
||||
lhs_expr) {
|
||||
Ok(return_ty) => return_ty,
|
||||
Err(()) => {
|
||||
|
|
@ -248,9 +248,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
-> Ty<'tcx>
|
||||
{
|
||||
assert!(op.is_by_value());
|
||||
match self.lookup_op_method(ex, operand_ty, vec![],
|
||||
token::intern(mname), trait_did,
|
||||
operand_expr) {
|
||||
let mname = Symbol::intern(mname);
|
||||
match self.lookup_op_method(ex, operand_ty, vec![], mname, trait_did, operand_expr) {
|
||||
Ok(t) => t,
|
||||
Err(()) => {
|
||||
self.type_error_message(ex.span, |actual| {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ use rustc_const_math::ConstInt;
|
|||
use std::cell::RefCell;
|
||||
|
||||
use syntax::{abi, ast, attr};
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::hir::{self, map as hir_map, print as pprust};
|
||||
|
|
@ -585,7 +585,7 @@ fn convert_closure<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
let upvar_decls : Vec<_> = tcx.with_freevars(node_id, |fv| {
|
||||
fv.iter().enumerate().map(|(i, _)| ty::TypeParameterDef {
|
||||
index: (base_generics.count() as u32) + (i as u32),
|
||||
name: token::intern("<upvar>"),
|
||||
name: Symbol::intern("<upvar>"),
|
||||
def_id: def_id,
|
||||
default_def_id: base_def_id,
|
||||
default: None,
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ use syntax::abi::Abi;
|
|||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::ptr::P;
|
||||
use syntax::print::pprust as syntax_pprust;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::{self, DUMMY_SP, Pos};
|
||||
|
||||
use rustc_trans::back::link;
|
||||
|
|
@ -242,7 +242,7 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
}
|
||||
});
|
||||
ExternalCrate {
|
||||
name: (&cx.sess().cstore.crate_name(self.0)[..]).to_owned(),
|
||||
name: cx.sess().cstore.crate_name(self.0).to_string(),
|
||||
attrs: cx.sess().cstore.item_attrs(root).clean(cx),
|
||||
primitives: primitives,
|
||||
}
|
||||
|
|
@ -2577,7 +2577,7 @@ impl Clean<Vec<Item>> for doctree::Import {
|
|||
// #[doc(no_inline)] attribute is present.
|
||||
// Don't inline doc(hidden) imports so they can be stripped at a later stage.
|
||||
let denied = self.vis != hir::Public || self.attrs.iter().any(|a| {
|
||||
&a.name()[..] == "doc" && match a.meta_item_list() {
|
||||
a.name() == "doc" && match a.meta_item_list() {
|
||||
Some(l) => attr::list_contains_name(l, "no_inline") ||
|
||||
attr::list_contains_name(l, "hidden"),
|
||||
None => false,
|
||||
|
|
|
|||
|
|
@ -14,71 +14,43 @@ pub use self::TyParamBound::*;
|
|||
pub use self::UnsafeSource::*;
|
||||
pub use self::ViewPath_::*;
|
||||
pub use self::PathParameters::*;
|
||||
pub use symbol::Symbol as Name;
|
||||
pub use util::ThinVec;
|
||||
|
||||
use syntax_pos::{mk_sp, Span, DUMMY_SP, ExpnId};
|
||||
use codemap::{respan, Spanned};
|
||||
use abi::Abi;
|
||||
use ext::hygiene::SyntaxContext;
|
||||
use parse::token::{self, keywords, InternedString};
|
||||
use print::pprust;
|
||||
use ptr::P;
|
||||
use symbol::{Symbol, keywords};
|
||||
use tokenstream::{TokenTree};
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use std::u32;
|
||||
|
||||
use serialize::{self, Encodable, Decodable, Encoder, Decoder};
|
||||
|
||||
/// A name is a part of an identifier, representing a string or gensym. It's
|
||||
/// the result of interning.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Name(pub u32);
|
||||
|
||||
/// An identifier contains a Name (index into the interner
|
||||
/// table) and a SyntaxContext to track renaming and
|
||||
/// macro expansion per Flatt et al., "Macros That Work Together"
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct Ident {
|
||||
pub name: Name,
|
||||
pub name: Symbol,
|
||||
pub ctxt: SyntaxContext
|
||||
}
|
||||
|
||||
impl Name {
|
||||
pub fn as_str(self) -> token::InternedString {
|
||||
token::InternedString::new_from_name(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Name {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}({})", self, self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Name {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(&self.as_str(), f)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Name {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_str(&self.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Name {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<Name, D::Error> {
|
||||
Ok(token::intern(&d.read_str()?))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ident {
|
||||
pub const fn with_empty_ctxt(name: Name) -> Ident {
|
||||
Ident { name: name, ctxt: SyntaxContext::empty() }
|
||||
}
|
||||
|
||||
/// Maps a string to an identifier with an empty syntax context.
|
||||
pub fn from_str(s: &str) -> Ident {
|
||||
Ident::with_empty_ctxt(Symbol::intern(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Ident {
|
||||
|
|
@ -401,7 +373,7 @@ impl Generics {
|
|||
}
|
||||
pub fn span_for_name(&self, name: &str) -> Option<Span> {
|
||||
for t in &self.ty_params {
|
||||
if t.ident.name.as_str() == name {
|
||||
if t.ident.name == name {
|
||||
return Some(t.span);
|
||||
}
|
||||
}
|
||||
|
|
@ -479,7 +451,7 @@ pub struct WhereEqPredicate {
|
|||
|
||||
/// The set of MetaItems that define the compilation environment of the crate,
|
||||
/// used to drive conditional compilation
|
||||
pub type CrateConfig = Vec<P<MetaItem>>;
|
||||
pub type CrateConfig = HashSet<(Name, Option<Symbol>)>;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct Crate {
|
||||
|
|
@ -498,7 +470,7 @@ pub type NestedMetaItem = Spanned<NestedMetaItemKind>;
|
|||
#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialEq)]
|
||||
pub enum NestedMetaItemKind {
|
||||
/// A full MetaItem, for recursive meta items.
|
||||
MetaItem(P<MetaItem>),
|
||||
MetaItem(MetaItem),
|
||||
/// A literal.
|
||||
///
|
||||
/// E.g. "foo", 64, true
|
||||
|
|
@ -508,53 +480,30 @@ pub enum NestedMetaItemKind {
|
|||
/// A spanned compile-time attribute item.
|
||||
///
|
||||
/// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
|
||||
pub type MetaItem = Spanned<MetaItemKind>;
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct MetaItem {
|
||||
pub name: Name,
|
||||
pub node: MetaItemKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
/// A compile-time attribute item.
|
||||
///
|
||||
/// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
|
||||
#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum MetaItemKind {
|
||||
/// Word meta item.
|
||||
///
|
||||
/// E.g. `test` as in `#[test]`
|
||||
Word(InternedString),
|
||||
Word,
|
||||
/// List meta item.
|
||||
///
|
||||
/// E.g. `derive(..)` as in `#[derive(..)]`
|
||||
List(InternedString, Vec<NestedMetaItem>),
|
||||
List(Vec<NestedMetaItem>),
|
||||
/// Name value meta item.
|
||||
///
|
||||
/// E.g. `feature = "foo"` as in `#[feature = "foo"]`
|
||||
NameValue(InternedString, Lit),
|
||||
}
|
||||
|
||||
// can't be derived because the MetaItemKind::List requires an unordered comparison
|
||||
impl PartialEq for MetaItemKind {
|
||||
fn eq(&self, other: &MetaItemKind) -> bool {
|
||||
use self::MetaItemKind::*;
|
||||
match *self {
|
||||
Word(ref ns) => match *other {
|
||||
Word(ref no) => (*ns) == (*no),
|
||||
_ => false
|
||||
},
|
||||
List(ref ns, ref miss) => match *other {
|
||||
List(ref no, ref miso) => {
|
||||
ns == no &&
|
||||
miss.iter().all(|mi| {
|
||||
miso.iter().any(|x| x.node == mi.node)
|
||||
})
|
||||
}
|
||||
_ => false
|
||||
},
|
||||
NameValue(ref ns, ref vs) => match *other {
|
||||
NameValue(ref no, ref vo) => {
|
||||
(*ns) == (*no) && vs.node == vo.node
|
||||
}
|
||||
_ => false
|
||||
},
|
||||
}
|
||||
}
|
||||
NameValue(Lit)
|
||||
}
|
||||
|
||||
/// A Block (`{ .. }`).
|
||||
|
|
@ -1149,7 +1098,7 @@ pub enum LitIntType {
|
|||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum LitKind {
|
||||
/// A string literal (`"foo"`)
|
||||
Str(InternedString, StrStyle),
|
||||
Str(Symbol, StrStyle),
|
||||
/// A byte string (`b"foo"`)
|
||||
ByteStr(Rc<Vec<u8>>),
|
||||
/// A byte char (`b'f'`)
|
||||
|
|
@ -1159,9 +1108,9 @@ pub enum LitKind {
|
|||
/// An integer literal (`1`)
|
||||
Int(u64, LitIntType),
|
||||
/// A float literal (`1f64` or `1E10f64`)
|
||||
Float(InternedString, FloatTy),
|
||||
Float(Symbol, FloatTy),
|
||||
/// A float literal without a suffix (`1.0 or 1.0E10`)
|
||||
FloatUnsuffixed(InternedString),
|
||||
FloatUnsuffixed(Symbol),
|
||||
/// A boolean literal
|
||||
Bool(bool),
|
||||
}
|
||||
|
|
@ -1493,7 +1442,7 @@ pub enum AsmDialect {
|
|||
/// E.g. `"={eax}"(result)` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")``
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct InlineAsmOutput {
|
||||
pub constraint: InternedString,
|
||||
pub constraint: Symbol,
|
||||
pub expr: P<Expr>,
|
||||
pub is_rw: bool,
|
||||
pub is_indirect: bool,
|
||||
|
|
@ -1504,11 +1453,11 @@ pub struct InlineAsmOutput {
|
|||
/// E.g. `asm!("NOP");`
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct InlineAsm {
|
||||
pub asm: InternedString,
|
||||
pub asm: Symbol,
|
||||
pub asm_str_style: StrStyle,
|
||||
pub outputs: Vec<InlineAsmOutput>,
|
||||
pub inputs: Vec<(InternedString, P<Expr>)>,
|
||||
pub clobbers: Vec<InternedString>,
|
||||
pub inputs: Vec<(Symbol, P<Expr>)>,
|
||||
pub clobbers: Vec<Symbol>,
|
||||
pub volatile: bool,
|
||||
pub alignstack: bool,
|
||||
pub dialect: AsmDialect,
|
||||
|
|
@ -1755,8 +1704,6 @@ impl ViewPath_ {
|
|||
}
|
||||
}
|
||||
|
||||
/// Meta-data associated with an item
|
||||
pub type Attribute = Spanned<Attribute_>;
|
||||
|
||||
/// Distinguishes between Attributes that decorate items and Attributes that
|
||||
/// are contained as statements within items. These two cases need to be
|
||||
|
|
@ -1770,13 +1717,15 @@ pub enum AttrStyle {
|
|||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||
pub struct AttrId(pub usize);
|
||||
|
||||
/// Meta-data associated with an item
|
||||
/// Doc-comments are promoted to attributes that have is_sugared_doc = true
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct Attribute_ {
|
||||
pub struct Attribute {
|
||||
pub id: AttrId,
|
||||
pub style: AttrStyle,
|
||||
pub value: P<MetaItem>,
|
||||
pub value: MetaItem,
|
||||
pub is_sugared_doc: bool,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
/// TraitRef's appear in impls.
|
||||
|
|
|
|||
|
|
@ -15,17 +15,17 @@ pub use self::ReprAttr::*;
|
|||
pub use self::IntType::*;
|
||||
|
||||
use ast;
|
||||
use ast::{AttrId, Attribute, Attribute_};
|
||||
use ast::{AttrId, Attribute, Name};
|
||||
use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
|
||||
use ast::{Lit, Expr, Item, Local, Stmt, StmtKind};
|
||||
use codemap::{respan, spanned, dummy_spanned};
|
||||
use codemap::{spanned, dummy_spanned, mk_sp};
|
||||
use syntax_pos::{Span, BytePos, DUMMY_SP};
|
||||
use errors::Handler;
|
||||
use feature_gate::{Features, GatedCfg};
|
||||
use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
|
||||
use parse::token::InternedString;
|
||||
use parse::{ParseSess, token};
|
||||
use parse::ParseSess;
|
||||
use ptr::P;
|
||||
use symbol::Symbol;
|
||||
use util::ThinVec;
|
||||
|
||||
use std::cell::{RefCell, Cell};
|
||||
|
|
@ -37,8 +37,8 @@ thread_local! {
|
|||
}
|
||||
|
||||
enum AttrError {
|
||||
MultipleItem(InternedString),
|
||||
UnknownMetaItem(InternedString),
|
||||
MultipleItem(Name),
|
||||
UnknownMetaItem(Name),
|
||||
MissingSince,
|
||||
MissingFeature,
|
||||
MultipleStabilityLevels,
|
||||
|
|
@ -61,7 +61,7 @@ fn handle_errors(diag: &Handler, span: Span, error: AttrError) {
|
|||
|
||||
pub fn mark_used(attr: &Attribute) {
|
||||
debug!("Marking {:?} as used.", attr);
|
||||
let AttrId(id) = attr.node.id;
|
||||
let AttrId(id) = attr.id;
|
||||
USED_ATTRS.with(|slot| {
|
||||
let idx = (id / 64) as usize;
|
||||
let shift = id % 64;
|
||||
|
|
@ -73,7 +73,7 @@ pub fn mark_used(attr: &Attribute) {
|
|||
}
|
||||
|
||||
pub fn is_used(attr: &Attribute) -> bool {
|
||||
let AttrId(id) = attr.node.id;
|
||||
let AttrId(id) = attr.id;
|
||||
USED_ATTRS.with(|slot| {
|
||||
let idx = (id / 64) as usize;
|
||||
let shift = id % 64;
|
||||
|
|
@ -84,7 +84,7 @@ pub fn is_used(attr: &Attribute) -> bool {
|
|||
|
||||
pub fn mark_known(attr: &Attribute) {
|
||||
debug!("Marking {:?} as known.", attr);
|
||||
let AttrId(id) = attr.node.id;
|
||||
let AttrId(id) = attr.id;
|
||||
KNOWN_ATTRS.with(|slot| {
|
||||
let idx = (id / 64) as usize;
|
||||
let shift = id % 64;
|
||||
|
|
@ -96,7 +96,7 @@ pub fn mark_known(attr: &Attribute) {
|
|||
}
|
||||
|
||||
pub fn is_known(attr: &Attribute) -> bool {
|
||||
let AttrId(id) = attr.node.id;
|
||||
let AttrId(id) = attr.id;
|
||||
KNOWN_ATTRS.with(|slot| {
|
||||
let idx = (id / 64) as usize;
|
||||
let shift = id % 64;
|
||||
|
|
@ -107,7 +107,7 @@ pub fn is_known(attr: &Attribute) -> bool {
|
|||
|
||||
impl NestedMetaItem {
|
||||
/// Returns the MetaItem if self is a NestedMetaItemKind::MetaItem.
|
||||
pub fn meta_item(&self) -> Option<&P<MetaItem>> {
|
||||
pub fn meta_item(&self) -> Option<&MetaItem> {
|
||||
match self.node {
|
||||
NestedMetaItemKind::MetaItem(ref item) => Some(&item),
|
||||
_ => None
|
||||
|
|
@ -134,18 +134,18 @@ impl NestedMetaItem {
|
|||
|
||||
/// Returns the name of the meta item, e.g. `foo` in `#[foo]`,
|
||||
/// `#[foo="bar"]` and `#[foo(bar)]`, if self is a MetaItem
|
||||
pub fn name(&self) -> Option<InternedString> {
|
||||
pub fn name(&self) -> Option<Name> {
|
||||
self.meta_item().and_then(|meta_item| Some(meta_item.name()))
|
||||
}
|
||||
|
||||
/// Gets the string value if self is a MetaItem and the MetaItem is a
|
||||
/// MetaItemKind::NameValue variant containing a string, otherwise None.
|
||||
pub fn value_str(&self) -> Option<InternedString> {
|
||||
pub fn value_str(&self) -> Option<Symbol> {
|
||||
self.meta_item().and_then(|meta_item| meta_item.value_str())
|
||||
}
|
||||
|
||||
/// Returns a MetaItem if self is a MetaItem with Kind Word.
|
||||
pub fn word(&self) -> Option<&P<MetaItem>> {
|
||||
pub fn word(&self) -> Option<&MetaItem> {
|
||||
self.meta_item().and_then(|meta_item| if meta_item.is_word() {
|
||||
Some(meta_item)
|
||||
} else {
|
||||
|
|
@ -186,16 +186,16 @@ impl NestedMetaItem {
|
|||
|
||||
impl Attribute {
|
||||
pub fn check_name(&self, name: &str) -> bool {
|
||||
let matches = name == &self.name()[..];
|
||||
let matches = self.name() == name;
|
||||
if matches {
|
||||
mark_used(self);
|
||||
}
|
||||
matches
|
||||
}
|
||||
|
||||
pub fn name(&self) -> InternedString { self.meta().name() }
|
||||
pub fn name(&self) -> Name { self.meta().name() }
|
||||
|
||||
pub fn value_str(&self) -> Option<InternedString> {
|
||||
pub fn value_str(&self) -> Option<Symbol> {
|
||||
self.meta().value_str()
|
||||
}
|
||||
|
||||
|
|
@ -218,17 +218,13 @@ impl Attribute {
|
|||
}
|
||||
|
||||
impl MetaItem {
|
||||
pub fn name(&self) -> InternedString {
|
||||
match self.node {
|
||||
MetaItemKind::Word(ref n) => (*n).clone(),
|
||||
MetaItemKind::NameValue(ref n, _) => (*n).clone(),
|
||||
MetaItemKind::List(ref n, _) => (*n).clone(),
|
||||
}
|
||||
pub fn name(&self) -> Name {
|
||||
self.name
|
||||
}
|
||||
|
||||
pub fn value_str(&self) -> Option<InternedString> {
|
||||
pub fn value_str(&self) -> Option<Symbol> {
|
||||
match self.node {
|
||||
MetaItemKind::NameValue(_, ref v) => {
|
||||
MetaItemKind::NameValue(ref v) => {
|
||||
match v.node {
|
||||
ast::LitKind::Str(ref s, _) => Some((*s).clone()),
|
||||
_ => None,
|
||||
|
|
@ -240,14 +236,14 @@ impl MetaItem {
|
|||
|
||||
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
|
||||
match self.node {
|
||||
MetaItemKind::List(_, ref l) => Some(&l[..]),
|
||||
MetaItemKind::List(ref l) => Some(&l[..]),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_word(&self) -> bool {
|
||||
match self.node {
|
||||
MetaItemKind::Word(_) => true,
|
||||
MetaItemKind::Word => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
@ -255,7 +251,7 @@ impl MetaItem {
|
|||
pub fn span(&self) -> Span { self.span }
|
||||
|
||||
pub fn check_name(&self, name: &str) -> bool {
|
||||
name == &self.name()[..]
|
||||
self.name() == name
|
||||
}
|
||||
|
||||
pub fn is_value_str(&self) -> bool {
|
||||
|
|
@ -270,7 +266,7 @@ impl MetaItem {
|
|||
impl Attribute {
|
||||
/// Extract the MetaItem from inside this Attribute.
|
||||
pub fn meta(&self) -> &MetaItem {
|
||||
&self.node.value
|
||||
&self.value
|
||||
}
|
||||
|
||||
/// Convert self to a normal #[doc="foo"] comment, if it is a
|
||||
|
|
@ -279,16 +275,15 @@ impl Attribute {
|
|||
pub fn with_desugared_doc<T, F>(&self, f: F) -> T where
|
||||
F: FnOnce(&Attribute) -> T,
|
||||
{
|
||||
if self.node.is_sugared_doc {
|
||||
if self.is_sugared_doc {
|
||||
let comment = self.value_str().unwrap();
|
||||
let meta = mk_name_value_item_str(
|
||||
InternedString::new("doc"),
|
||||
token::intern_and_get_ident(&strip_doc_comment_decoration(
|
||||
&comment)));
|
||||
if self.node.style == ast::AttrStyle::Outer {
|
||||
f(&mk_attr_outer(self.node.id, meta))
|
||||
Symbol::intern("doc"),
|
||||
Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())));
|
||||
if self.style == ast::AttrStyle::Outer {
|
||||
f(&mk_attr_outer(self.id, meta))
|
||||
} else {
|
||||
f(&mk_attr_inner(self.node.id, meta))
|
||||
f(&mk_attr_inner(self.id, meta))
|
||||
}
|
||||
} else {
|
||||
f(self)
|
||||
|
|
@ -298,41 +293,37 @@ impl Attribute {
|
|||
|
||||
/* Constructors */
|
||||
|
||||
pub fn mk_name_value_item_str(name: InternedString, value: InternedString)
|
||||
-> P<MetaItem> {
|
||||
pub fn mk_name_value_item_str(name: Name, value: Symbol) -> MetaItem {
|
||||
let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::StrStyle::Cooked));
|
||||
mk_spanned_name_value_item(DUMMY_SP, name, value_lit)
|
||||
}
|
||||
|
||||
pub fn mk_name_value_item(name: InternedString, value: ast::Lit)
|
||||
-> P<MetaItem> {
|
||||
pub fn mk_name_value_item(name: Name, value: ast::Lit) -> MetaItem {
|
||||
mk_spanned_name_value_item(DUMMY_SP, name, value)
|
||||
}
|
||||
|
||||
pub fn mk_list_item(name: InternedString, items: Vec<NestedMetaItem>) -> P<MetaItem> {
|
||||
pub fn mk_list_item(name: Name, items: Vec<NestedMetaItem>) -> MetaItem {
|
||||
mk_spanned_list_item(DUMMY_SP, name, items)
|
||||
}
|
||||
|
||||
pub fn mk_list_word_item(name: InternedString) -> ast::NestedMetaItem {
|
||||
pub fn mk_list_word_item(name: Name) -> ast::NestedMetaItem {
|
||||
dummy_spanned(NestedMetaItemKind::MetaItem(mk_spanned_word_item(DUMMY_SP, name)))
|
||||
}
|
||||
|
||||
pub fn mk_word_item(name: InternedString) -> P<MetaItem> {
|
||||
pub fn mk_word_item(name: Name) -> MetaItem {
|
||||
mk_spanned_word_item(DUMMY_SP, name)
|
||||
}
|
||||
|
||||
pub fn mk_spanned_name_value_item(sp: Span, name: InternedString, value: ast::Lit)
|
||||
-> P<MetaItem> {
|
||||
P(respan(sp, MetaItemKind::NameValue(name, value)))
|
||||
pub fn mk_spanned_name_value_item(sp: Span, name: Name, value: ast::Lit) -> MetaItem {
|
||||
MetaItem { span: sp, name: name, node: MetaItemKind::NameValue(value) }
|
||||
}
|
||||
|
||||
pub fn mk_spanned_list_item(sp: Span, name: InternedString, items: Vec<NestedMetaItem>)
|
||||
-> P<MetaItem> {
|
||||
P(respan(sp, MetaItemKind::List(name, items)))
|
||||
pub fn mk_spanned_list_item(sp: Span, name: Name, items: Vec<NestedMetaItem>) -> MetaItem {
|
||||
MetaItem { span: sp, name: name, node: MetaItemKind::List(items) }
|
||||
}
|
||||
|
||||
pub fn mk_spanned_word_item(sp: Span, name: InternedString) -> P<MetaItem> {
|
||||
P(respan(sp, MetaItemKind::Word(name)))
|
||||
pub fn mk_spanned_word_item(sp: Span, name: Name) -> MetaItem {
|
||||
MetaItem { span: sp, name: name, node: MetaItemKind::Word }
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -349,71 +340,63 @@ pub fn mk_attr_id() -> AttrId {
|
|||
}
|
||||
|
||||
/// Returns an inner attribute with the given value.
|
||||
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
|
||||
pub fn mk_attr_inner(id: AttrId, item: MetaItem) -> Attribute {
|
||||
mk_spanned_attr_inner(DUMMY_SP, id, item)
|
||||
}
|
||||
|
||||
/// Returns an innter attribute with the given value and span.
|
||||
pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: P<MetaItem>) -> Attribute {
|
||||
respan(sp,
|
||||
Attribute_ {
|
||||
id: id,
|
||||
style: ast::AttrStyle::Inner,
|
||||
value: item,
|
||||
is_sugared_doc: false,
|
||||
})
|
||||
pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute {
|
||||
Attribute {
|
||||
id: id,
|
||||
style: ast::AttrStyle::Inner,
|
||||
value: item,
|
||||
is_sugared_doc: false,
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Returns an outer attribute with the given value.
|
||||
pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {
|
||||
pub fn mk_attr_outer(id: AttrId, item: MetaItem) -> Attribute {
|
||||
mk_spanned_attr_outer(DUMMY_SP, id, item)
|
||||
}
|
||||
|
||||
/// Returns an outer attribute with the given value and span.
|
||||
pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: P<MetaItem>) -> Attribute {
|
||||
respan(sp,
|
||||
Attribute_ {
|
||||
id: id,
|
||||
style: ast::AttrStyle::Outer,
|
||||
value: item,
|
||||
is_sugared_doc: false,
|
||||
})
|
||||
pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute {
|
||||
Attribute {
|
||||
id: id,
|
||||
style: ast::AttrStyle::Outer,
|
||||
value: item,
|
||||
is_sugared_doc: false,
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_doc_attr_outer(id: AttrId, item: P<MetaItem>, is_sugared_doc: bool) -> Attribute {
|
||||
dummy_spanned(Attribute_ {
|
||||
pub fn mk_doc_attr_outer(id: AttrId, item: MetaItem, is_sugared_doc: bool) -> Attribute {
|
||||
Attribute {
|
||||
id: id,
|
||||
style: ast::AttrStyle::Outer,
|
||||
value: item,
|
||||
is_sugared_doc: is_sugared_doc,
|
||||
})
|
||||
span: DUMMY_SP,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos,
|
||||
hi: BytePos)
|
||||
pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, lo: BytePos, hi: BytePos)
|
||||
-> Attribute {
|
||||
let style = doc_comment_style(&text);
|
||||
let style = doc_comment_style(&text.as_str());
|
||||
let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::StrStyle::Cooked));
|
||||
let attr = Attribute_ {
|
||||
Attribute {
|
||||
id: id,
|
||||
style: style,
|
||||
value: P(spanned(lo, hi, MetaItemKind::NameValue(InternedString::new("doc"), lit))),
|
||||
is_sugared_doc: true
|
||||
};
|
||||
spanned(lo, hi, attr)
|
||||
}
|
||||
|
||||
/* Searching */
|
||||
/// Check if `needle` occurs in `haystack` by a structural
|
||||
/// comparison. This is slightly subtle, and relies on ignoring the
|
||||
/// span included in the `==` comparison a plain MetaItem.
|
||||
pub fn contains(haystack: &[P<MetaItem>], needle: &MetaItem) -> bool {
|
||||
debug!("attr::contains (name={})", needle.name());
|
||||
haystack.iter().any(|item| {
|
||||
debug!(" testing: {}", item.name());
|
||||
item.node == needle.node
|
||||
})
|
||||
value: MetaItem {
|
||||
span: mk_sp(lo, hi),
|
||||
name: Symbol::intern("doc"),
|
||||
node: MetaItemKind::NameValue(lit),
|
||||
},
|
||||
is_sugared_doc: true,
|
||||
span: mk_sp(lo, hi),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_contains_name(items: &[NestedMetaItem], name: &str) -> bool {
|
||||
|
|
@ -432,15 +415,13 @@ pub fn contains_name(attrs: &[Attribute], name: &str) -> bool {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str)
|
||||
-> Option<InternedString> {
|
||||
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) -> Option<Symbol> {
|
||||
attrs.iter()
|
||||
.find(|at| at.check_name(name))
|
||||
.and_then(|at| at.value_str())
|
||||
}
|
||||
|
||||
pub fn last_meta_item_value_str_by_name(items: &[P<MetaItem>], name: &str)
|
||||
-> Option<InternedString> {
|
||||
pub fn last_meta_item_value_str_by_name(items: &[MetaItem], name: &str) -> Option<Symbol> {
|
||||
items.iter()
|
||||
.rev()
|
||||
.find(|mi| mi.check_name(name))
|
||||
|
|
@ -449,12 +430,12 @@ pub fn last_meta_item_value_str_by_name(items: &[P<MetaItem>], name: &str)
|
|||
|
||||
/* Higher-level applications */
|
||||
|
||||
pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> {
|
||||
pub fn find_crate_name(attrs: &[Attribute]) -> Option<Symbol> {
|
||||
first_attr_value_str_by_name(attrs, "crate_name")
|
||||
}
|
||||
|
||||
/// Find the value of #[export_name=*] attribute and check its validity.
|
||||
pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<InternedString> {
|
||||
pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Symbol> {
|
||||
attrs.iter().fold(None, |ia,attr| {
|
||||
if attr.check_name("export_name") {
|
||||
if let s@Some(_) = attr.value_str() {
|
||||
|
|
@ -488,13 +469,14 @@ pub enum InlineAttr {
|
|||
|
||||
/// Determine what `#[inline]` attribute is present in `attrs`, if any.
|
||||
pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> InlineAttr {
|
||||
attrs.iter().fold(InlineAttr::None, |ia,attr| {
|
||||
match attr.node.value.node {
|
||||
MetaItemKind::Word(ref n) if n == "inline" => {
|
||||
attrs.iter().fold(InlineAttr::None, |ia, attr| {
|
||||
match attr.value.node {
|
||||
_ if attr.value.name != "inline" => ia,
|
||||
MetaItemKind::Word => {
|
||||
mark_used(attr);
|
||||
InlineAttr::Hint
|
||||
}
|
||||
MetaItemKind::List(ref n, ref items) if n == "inline" => {
|
||||
MetaItemKind::List(ref items) => {
|
||||
mark_used(attr);
|
||||
if items.len() != 1 {
|
||||
diagnostic.map(|d|{ span_err!(d, attr.span, E0534, "expected one argument"); });
|
||||
|
|
@ -527,7 +509,7 @@ pub fn requests_inline(attrs: &[Attribute]) -> bool {
|
|||
/// Tests if a cfg-pattern matches the cfg set
|
||||
pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Features>) -> bool {
|
||||
match cfg.node {
|
||||
ast::MetaItemKind::List(ref pred, ref mis) => {
|
||||
ast::MetaItemKind::List(ref mis) => {
|
||||
for mi in mis.iter() {
|
||||
if !mi.is_meta_item() {
|
||||
handle_errors(&sess.span_diagnostic, mi.span, AttrError::UnsupportedLiteral);
|
||||
|
|
@ -537,7 +519,7 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat
|
|||
|
||||
// The unwraps below may look dangerous, but we've already asserted
|
||||
// that they won't fail with the loop above.
|
||||
match &pred[..] {
|
||||
match &*cfg.name.as_str() {
|
||||
"any" => mis.iter().any(|mi| {
|
||||
cfg_matches(mi.meta_item().unwrap(), sess, features)
|
||||
}),
|
||||
|
|
@ -558,11 +540,11 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat
|
|||
}
|
||||
}
|
||||
},
|
||||
ast::MetaItemKind::Word(_) | ast::MetaItemKind::NameValue(..) => {
|
||||
ast::MetaItemKind::Word | ast::MetaItemKind::NameValue(..) => {
|
||||
if let (Some(feats), Some(gated_cfg)) = (features, GatedCfg::gate(cfg)) {
|
||||
gated_cfg.check_and_emit(sess, feats);
|
||||
}
|
||||
contains(&sess.config, cfg)
|
||||
sess.config.contains(&(cfg.name(), cfg.value_str()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -571,7 +553,7 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat
|
|||
#[derive(RustcEncodable, RustcDecodable, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Stability {
|
||||
pub level: StabilityLevel,
|
||||
pub feature: InternedString,
|
||||
pub feature: Symbol,
|
||||
pub rustc_depr: Option<RustcDeprecation>,
|
||||
}
|
||||
|
||||
|
|
@ -579,20 +561,20 @@ pub struct Stability {
|
|||
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Debug, Eq, Hash)]
|
||||
pub enum StabilityLevel {
|
||||
// Reason for the current stability level and the relevant rust-lang issue
|
||||
Unstable { reason: Option<InternedString>, issue: u32 },
|
||||
Stable { since: InternedString },
|
||||
Unstable { reason: Option<Symbol>, issue: u32 },
|
||||
Stable { since: Symbol },
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Debug, Eq, Hash)]
|
||||
pub struct RustcDeprecation {
|
||||
pub since: InternedString,
|
||||
pub reason: InternedString,
|
||||
pub since: Symbol,
|
||||
pub reason: Symbol,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Debug, Eq, Hash)]
|
||||
pub struct Deprecation {
|
||||
pub since: Option<InternedString>,
|
||||
pub note: Option<InternedString>,
|
||||
pub since: Option<Symbol>,
|
||||
pub note: Option<Symbol>,
|
||||
}
|
||||
|
||||
impl StabilityLevel {
|
||||
|
|
@ -611,7 +593,6 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
|
||||
'outer: for attr in attrs_iter {
|
||||
let tag = attr.name();
|
||||
let tag = &*tag;
|
||||
if tag != "rustc_deprecated" && tag != "unstable" && tag != "stable" {
|
||||
continue // not a stability level
|
||||
}
|
||||
|
|
@ -619,7 +600,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
mark_used(attr);
|
||||
|
||||
if let Some(metas) = attr.meta_item_list() {
|
||||
let get = |meta: &MetaItem, item: &mut Option<InternedString>| {
|
||||
let get = |meta: &MetaItem, item: &mut Option<Symbol>| {
|
||||
if item.is_some() {
|
||||
handle_errors(diagnostic, meta.span, AttrError::MultipleItem(meta.name()));
|
||||
return false
|
||||
|
|
@ -633,7 +614,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
}
|
||||
};
|
||||
|
||||
match tag {
|
||||
match &*tag.as_str() {
|
||||
"rustc_deprecated" => {
|
||||
if rustc_depr.is_some() {
|
||||
span_err!(diagnostic, item_sp, E0540,
|
||||
|
|
@ -645,7 +626,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
let mut reason = None;
|
||||
for meta in metas {
|
||||
if let Some(mi) = meta.meta_item() {
|
||||
match &*mi.name() {
|
||||
match &*mi.name().as_str() {
|
||||
"since" => if !get(mi, &mut since) { continue 'outer },
|
||||
"reason" => if !get(mi, &mut reason) { continue 'outer },
|
||||
_ => {
|
||||
|
|
@ -688,7 +669,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
let mut issue = None;
|
||||
for meta in metas {
|
||||
if let Some(mi) = meta.meta_item() {
|
||||
match &*mi.name() {
|
||||
match &*mi.name().as_str() {
|
||||
"feature" => if !get(mi, &mut feature) { continue 'outer },
|
||||
"reason" => if !get(mi, &mut reason) { continue 'outer },
|
||||
"issue" => if !get(mi, &mut issue) { continue 'outer },
|
||||
|
|
@ -710,7 +691,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
level: Unstable {
|
||||
reason: reason,
|
||||
issue: {
|
||||
if let Ok(issue) = issue.parse() {
|
||||
if let Ok(issue) = issue.as_str().parse() {
|
||||
issue
|
||||
} else {
|
||||
span_err!(diagnostic, attr.span(), E0545,
|
||||
|
|
@ -743,7 +724,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
|
|||
let mut since = None;
|
||||
for meta in metas {
|
||||
if let NestedMetaItemKind::MetaItem(ref mi) = meta.node {
|
||||
match &*mi.name() {
|
||||
match &*mi.name().as_str() {
|
||||
"feature" => if !get(mi, &mut feature) { continue 'outer },
|
||||
"since" => if !get(mi, &mut since) { continue 'outer },
|
||||
_ => {
|
||||
|
|
@ -821,7 +802,7 @@ fn find_deprecation_generic<'a, I>(diagnostic: &Handler,
|
|||
}
|
||||
|
||||
depr = if let Some(metas) = attr.meta_item_list() {
|
||||
let get = |meta: &MetaItem, item: &mut Option<InternedString>| {
|
||||
let get = |meta: &MetaItem, item: &mut Option<Symbol>| {
|
||||
if item.is_some() {
|
||||
handle_errors(diagnostic, meta.span, AttrError::MultipleItem(meta.name()));
|
||||
return false
|
||||
|
|
@ -839,7 +820,7 @@ fn find_deprecation_generic<'a, I>(diagnostic: &Handler,
|
|||
let mut note = None;
|
||||
for meta in metas {
|
||||
if let NestedMetaItemKind::MetaItem(ref mi) = meta.node {
|
||||
match &*mi.name() {
|
||||
match &*mi.name().as_str() {
|
||||
"since" => if !get(mi, &mut since) { continue 'outer },
|
||||
"note" => if !get(mi, &mut note) { continue 'outer },
|
||||
_ => {
|
||||
|
|
@ -875,7 +856,7 @@ pub fn find_deprecation(diagnostic: &Handler, attrs: &[Attribute],
|
|||
find_deprecation_generic(diagnostic, attrs.iter(), item_sp)
|
||||
}
|
||||
|
||||
pub fn require_unique_names(diagnostic: &Handler, metas: &[P<MetaItem>]) {
|
||||
pub fn require_unique_names(diagnostic: &Handler, metas: &[MetaItem]) {
|
||||
let mut set = HashSet::new();
|
||||
for meta in metas {
|
||||
let name = meta.name();
|
||||
|
|
@ -896,8 +877,8 @@ pub fn require_unique_names(diagnostic: &Handler, metas: &[P<MetaItem>]) {
|
|||
/// structure layout, and `packed` to remove padding.
|
||||
pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
let mut acc = Vec::new();
|
||||
match attr.node.value.node {
|
||||
ast::MetaItemKind::List(ref s, ref items) if s == "repr" => {
|
||||
match attr.value.node {
|
||||
ast::MetaItemKind::List(ref items) if attr.value.name == "repr" => {
|
||||
mark_used(attr);
|
||||
for item in items {
|
||||
if !item.is_meta_item() {
|
||||
|
|
@ -906,7 +887,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
|
|||
}
|
||||
|
||||
if let Some(mi) = item.word() {
|
||||
let word = &*mi.name();
|
||||
let word = &*mi.name().as_str();
|
||||
let hint = match word {
|
||||
// Can't use "extern" because it's not a lexical identifier.
|
||||
"C" => Some(ReprExtern),
|
||||
|
|
|
|||
|
|
@ -871,6 +871,7 @@ impl CodeMapper for CodeMap {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use symbol::keywords;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
|
|
@ -1097,10 +1098,9 @@ mod tests {
|
|||
#[test]
|
||||
fn t11() {
|
||||
// Test span_to_expanded_string works with expansion
|
||||
use ast::Name;
|
||||
let cm = init_code_map();
|
||||
let root = Span { lo: BytePos(0), hi: BytePos(11), expn_id: NO_EXPANSION };
|
||||
let format = ExpnFormat::MacroBang(Name(0u32));
|
||||
let format = ExpnFormat::MacroBang(keywords::Invalid.name());
|
||||
let callee = NameAndSpan { format: format,
|
||||
allow_internal_unstable: false,
|
||||
span: None };
|
||||
|
|
@ -1197,11 +1197,9 @@ mod tests {
|
|||
fn init_expansion_chain(cm: &CodeMap) -> Span {
|
||||
// Creates an expansion chain containing two recursive calls
|
||||
// root -> expA -> expA -> expB -> expB -> end
|
||||
use ast::Name;
|
||||
|
||||
let root = Span { lo: BytePos(0), hi: BytePos(11), expn_id: NO_EXPANSION };
|
||||
|
||||
let format_root = ExpnFormat::MacroBang(Name(0u32));
|
||||
let format_root = ExpnFormat::MacroBang(keywords::Invalid.name());
|
||||
let callee_root = NameAndSpan { format: format_root,
|
||||
allow_internal_unstable: false,
|
||||
span: Some(root) };
|
||||
|
|
@ -1210,7 +1208,7 @@ mod tests {
|
|||
let id_a1 = cm.record_expansion(info_a1);
|
||||
let span_a1 = Span { lo: BytePos(12), hi: BytePos(23), expn_id: id_a1 };
|
||||
|
||||
let format_a = ExpnFormat::MacroBang(Name(1u32));
|
||||
let format_a = ExpnFormat::MacroBang(keywords::As.name());
|
||||
let callee_a = NameAndSpan { format: format_a,
|
||||
allow_internal_unstable: false,
|
||||
span: Some(span_a1) };
|
||||
|
|
@ -1223,7 +1221,7 @@ mod tests {
|
|||
let id_b1 = cm.record_expansion(info_b1);
|
||||
let span_b1 = Span { lo: BytePos(25), hi: BytePos(36), expn_id: id_b1 };
|
||||
|
||||
let format_b = ExpnFormat::MacroBang(Name(2u32));
|
||||
let format_b = ExpnFormat::MacroBang(keywords::Box.name());
|
||||
let callee_b = NameAndSpan { format: format_b,
|
||||
allow_internal_unstable: false,
|
||||
span: None };
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use attr::HasAttrs;
|
|||
use feature_gate::{feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue};
|
||||
use {fold, attr};
|
||||
use ast;
|
||||
use codemap::{Spanned, respan};
|
||||
use codemap::Spanned;
|
||||
use parse::ParseSess;
|
||||
use ptr::P;
|
||||
|
||||
|
|
@ -106,12 +106,13 @@ impl<'a> StripUnconfigured<'a> {
|
|||
match (cfg.meta_item(), mi.meta_item()) {
|
||||
(Some(cfg), Some(mi)) =>
|
||||
if cfg_matches(&cfg, self.sess, self.features) {
|
||||
self.process_cfg_attr(respan(mi.span, ast::Attribute_ {
|
||||
self.process_cfg_attr(ast::Attribute {
|
||||
id: attr::mk_attr_id(),
|
||||
style: attr.node.style,
|
||||
style: attr.style,
|
||||
value: mi.clone(),
|
||||
is_sugared_doc: false,
|
||||
}))
|
||||
span: mi.span,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
|
@ -131,8 +132,8 @@ impl<'a> StripUnconfigured<'a> {
|
|||
return false;
|
||||
}
|
||||
|
||||
let mis = match attr.node.value.node {
|
||||
ast::MetaItemKind::List(_, ref mis) if is_cfg(&attr) => mis,
|
||||
let mis = match attr.value.node {
|
||||
ast::MetaItemKind::List(ref mis) if is_cfg(&attr) => mis,
|
||||
_ => return true
|
||||
};
|
||||
|
||||
|
|
@ -160,7 +161,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
attr.span,
|
||||
GateIssue::Language,
|
||||
EXPLAIN_STMT_ATTR_SYNTAX);
|
||||
if attr.node.is_sugared_doc {
|
||||
if attr.is_sugared_doc {
|
||||
err.help("`///` is for documentation comments. For a plain comment, use `//`.");
|
||||
}
|
||||
err.emit();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use ext::base::{ExtCtxt, MacEager, MacResult};
|
|||
use ext::build::AstBuilder;
|
||||
use parse::token;
|
||||
use ptr::P;
|
||||
use symbol::Symbol;
|
||||
use tokenstream::{TokenTree};
|
||||
use util::small_vector::SmallVector;
|
||||
|
||||
|
|
@ -141,7 +142,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
|
|||
));
|
||||
}
|
||||
});
|
||||
let sym = Ident::with_empty_ctxt(token::gensym(&format!(
|
||||
let sym = Ident::with_empty_ctxt(Symbol::gensym(&format!(
|
||||
"__register_diagnostic_{}", code
|
||||
)));
|
||||
MacEager::items(SmallVector::many(vec![
|
||||
|
|
@ -194,11 +195,11 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
|||
let (count, expr) =
|
||||
with_registered_diagnostics(|diagnostics| {
|
||||
let descriptions: Vec<P<ast::Expr>> =
|
||||
diagnostics.iter().filter_map(|(code, info)| {
|
||||
diagnostics.iter().filter_map(|(&code, info)| {
|
||||
info.description.map(|description| {
|
||||
ecx.expr_tuple(span, vec![
|
||||
ecx.expr_str(span, code.as_str()),
|
||||
ecx.expr_str(span, description.as_str())
|
||||
ecx.expr_str(span, code),
|
||||
ecx.expr_str(span, description)
|
||||
])
|
||||
})
|
||||
}).collect();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
|
|||
EntryPointType::Start
|
||||
} else if attr::contains_name(&item.attrs, "main") {
|
||||
EntryPointType::MainAttr
|
||||
} else if item.ident.name.as_str() == "main" {
|
||||
} else if item.ident.name == "main" {
|
||||
if depth == 1 {
|
||||
// This is a top-level function so can be 'main'
|
||||
EntryPointType::MainNamed
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue