Skip to content

Commit

Permalink
Libsyntax has been updated
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 6, 2015
1 parent 12f1f4c commit 8b12d3d
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 121 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/check_match.rs
Expand Up @@ -249,11 +249,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
span_warn!(cx.tcx.sess, p.span, E0170,
"pattern binding `{}` is named the same as one \
of the variants of the type `{}`",
token::get_ident(ident.node).get(), ty_to_string(cx.tcx, pat_ty));
token::get_ident(&ident.node)[], ty_to_string(cx.tcx, pat_ty));
span_help!(cx.tcx.sess, p.span,
"if you meant to match on a variant, \
consider making the path in the pattern qualified: `{}::{}`",
ty_to_string(cx.tcx, pat_ty), token::get_ident(ident.node).get());
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node)[]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/svh.rs
Expand Up @@ -329,7 +329,7 @@ mod svh_visitor {
// macro invocations, namely macro_rules definitions,
// *can* appear as items, even in the expanded crate AST.

if macro_name(mac).get() == "macro_rules" {
if &macro_name(mac)[] == "macro_rules" {
// Pretty-printing definition to a string strips out
// surface artifacts (currently), such as the span
// information, yielding a content-based hash.
Expand Down
9 changes: 4 additions & 5 deletions src/libsyntax/ast.rs
Expand Up @@ -68,7 +68,6 @@ use std::fmt::Show;
use std::num::Int;
use std::rc::Rc;
use serialize::{Encodable, Decodable, Encoder, Decoder};
use std::ops::Deref;

// FIXME #6993: in librustc, uses of "ident" should be replaced
// by just "Name".
Expand Down Expand Up @@ -113,13 +112,13 @@ impl fmt::Display for Ident {
impl fmt::Debug for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Name(nm) = *self;
write!(f, "{:?}({})", token::get_name(*self).deref(), nm)
write!(f, "{:?}({})", token::get_name(*self), nm)
}
}

impl fmt::Display for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(token::get_name(*self).deref(), f)
fmt::Display::fmt(&token::get_name(*self)[], f)
}
}

Expand Down Expand Up @@ -175,7 +174,7 @@ impl Name {
pub fn as_str<'a>(&'a self) -> &'a str {
unsafe {
// FIXME #12938: can't use copy_lifetime since &str isn't a &T
::std::mem::transmute::<&str,&str>(token::get_name(*self).deref())
::std::mem::transmute::<&str,&str>(&token::get_name(*self)[])
}
}

Expand All @@ -194,7 +193,7 @@ pub type Mrk = u32;

impl Encodable for Ident {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_str(token::get_ident(*self).deref())
s.emit_str(&token::get_ident(*self)[])
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/ast_util.rs
Expand Up @@ -23,12 +23,11 @@ use visit;

use std::cmp;
use std::u32;
use std::ops::Deref;

pub fn path_name_i(idents: &[Ident]) -> String {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
idents.iter().map(|i| {
token::get_ident(*i).deref().to_string()
token::get_ident(*i).to_string()
}).collect::<Vec<String>>().connect("::")
}

Expand Down
25 changes: 12 additions & 13 deletions src/libsyntax/attr.rs
Expand Up @@ -29,7 +29,6 @@ use std::cell::{RefCell, Cell};
use std::collections::BitvSet;
use std::collections::HashSet;
use std::fmt;
use std::ops::Deref;

thread_local! { static USED_ATTRS: RefCell<BitvSet> = RefCell::new(BitvSet::new()) }

Expand All @@ -45,7 +44,7 @@ pub fn is_used(attr: &Attribute) -> bool {

pub trait AttrMetaMethods {
fn check_name(&self, name: &str) -> bool {
name == self.name().deref()
name == &self.name()[]
}

/// Retrieve the name of the meta item, e.g. `foo` in `#[foo]`,
Expand All @@ -63,7 +62,7 @@ pub trait AttrMetaMethods {

impl AttrMetaMethods for Attribute {
fn check_name(&self, name: &str) -> bool {
let matches = name == self.name().deref();
let matches = name == &self.name()[];
if matches {
mark_used(self);
}
Expand Down Expand Up @@ -143,7 +142,7 @@ impl AttributeMethods for Attribute {
let meta = mk_name_value_item_str(
InternedString::new("doc"),
token::intern_and_get_ident(&strip_doc_comment_decoration(
comment.deref())[]));
&comment[])[]));
if self.node.style == ast::AttrOuter {
f(&mk_attr_outer(self.node.id, meta))
} else {
Expand Down Expand Up @@ -210,7 +209,7 @@ pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {
pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos,
hi: BytePos)
-> Attribute {
let style = doc_comment_style(text.deref());
let style = doc_comment_style(&text[]);
let lit = spanned(lo, hi, ast::LitStr(text, ast::CookedStr));
let attr = Attribute_ {
id: id,
Expand Down Expand Up @@ -327,11 +326,11 @@ pub fn requests_inline(attrs: &[Attribute]) -> bool {
/// Tests if a cfg-pattern matches the cfg set
pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::MetaItem) -> bool {
match cfg.node {
ast::MetaList(ref pred, ref mis) if pred.deref() == "any" =>
ast::MetaList(ref pred, ref mis) if &pred[] == "any" =>
mis.iter().any(|mi| cfg_matches(diagnostic, cfgs, &**mi)),
ast::MetaList(ref pred, ref mis) if pred.deref() == "all" =>
ast::MetaList(ref pred, ref mis) if &pred[] == "all" =>
mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)),
ast::MetaList(ref pred, ref mis) if pred.deref() == "not" => {
ast::MetaList(ref pred, ref mis) if &pred[] == "not" => {
if mis.len() != 1 {
diagnostic.span_err(cfg.span, "expected 1 cfg-pattern");
return false;
Expand Down Expand Up @@ -383,7 +382,7 @@ fn find_stability_generic<'a,

'outer: for attr in attrs {
let tag = attr.name();
let tag = tag.deref();
let tag = &tag[];
if tag != "deprecated" && tag != "unstable" && tag != "stable" {
continue // not a stability level
}
Expand All @@ -405,7 +404,7 @@ fn find_stability_generic<'a,
}
}
}
if meta.name().deref() == "since" {
if &meta.name()[] == "since" {
match meta.value_str() {
Some(v) => since = Some(v),
None => {
Expand All @@ -414,7 +413,7 @@ fn find_stability_generic<'a,
}
}
}
if meta.name().deref() == "reason" {
if &meta.name()[] == "reason" {
match meta.value_str() {
Some(v) => reason = Some(v),
None => {
Expand Down Expand Up @@ -522,11 +521,11 @@ pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAt
for item in items {
match item.node {
ast::MetaWord(ref word) => {
let hint = match word.deref() {
let hint = match &word[] {
// Can't use "extern" because it's not a lexical identifier.
"C" => Some(ReprExtern),
"packed" => Some(ReprPacked),
_ => match int_type_of_word(word.deref()) {
_ => match int_type_of_word(&word[]) {
Some(ity) => Some(ReprInt(item.span, ity)),
None => {
// Not a word we recognize
Expand Down
9 changes: 4 additions & 5 deletions src/libsyntax/diagnostics/plugin.rs
Expand Up @@ -10,7 +10,6 @@

use std::cell::RefCell;
use std::collections::BTreeMap;
use std::ops::Deref;

use ast;
use ast::{Ident, Name, TokenTree};
Expand Down Expand Up @@ -59,7 +58,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
match diagnostics.insert(code.name, span) {
Some(previous_span) => {
ecx.span_warn(span, &format!(
"diagnostic code {} already used", token::get_ident(code).deref()
"diagnostic code {} already used", &token::get_ident(code)[]
)[]);
ecx.span_note(previous_span, "previous invocation");
},
Expand All @@ -70,7 +69,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
with_registered_diagnostics(|diagnostics| {
if !diagnostics.contains_key(&code.name) {
ecx.span_err(span, &format!(
"used diagnostic code {} not registered", token::get_ident(code).deref()
"used diagnostic code {} not registered", &token::get_ident(code)[]
)[]);
}
});
Expand All @@ -95,12 +94,12 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
with_registered_diagnostics(|diagnostics| {
if diagnostics.insert(code.name, description).is_some() {
ecx.span_err(span, &format!(
"diagnostic code {} already registered", token::get_ident(*code).deref()
"diagnostic code {} already registered", &token::get_ident(*code)[]
)[]);
}
});
let sym = Ident::new(token::gensym(&(
"__register_diagnostic_".to_string() + token::get_ident(*code).deref()
"__register_diagnostic_".to_string() + &token::get_ident(*code)[]
)[]));
MacItems::new(vec![quote_item!(ecx, mod $sym {}).unwrap()].into_iter())
}
Expand Down
10 changes: 4 additions & 6 deletions src/libsyntax/ext/asm.rs
Expand Up @@ -22,8 +22,6 @@ use parse::token::InternedString;
use parse::token;
use ptr::P;

use std::ops::Deref;

enum State {
Asm,
Outputs,
Expand Down Expand Up @@ -104,7 +102,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
// It's the opposite of '=&' which means that the memory
// cannot be shared with any other operand (usually when
// a register is clobbered early.)
let output = match constraint.deref().slice_shift_char() {
let output = match constraint.slice_shift_char() {
Some(('=', _)) => None,
Some(('+', operand)) => {
Some(token::intern_and_get_ident(&format!(
Expand All @@ -131,9 +129,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])

let (constraint, _str_style) = p.parse_str();

if constraint.deref().starts_with("=") {
if constraint.starts_with("=") {
cx.span_err(p.last_span, "input operand constraint contains '='");
} else if constraint.deref().starts_with("+") {
} else if constraint.starts_with("+") {
cx.span_err(p.last_span, "input operand constraint contains '+'");
}

Expand Down Expand Up @@ -215,7 +213,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
MacExpr::new(P(ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprInlineAsm(ast::InlineAsm {
asm: token::intern_and_get_ident(asm.deref()),
asm: token::intern_and_get_ident(&asm[]),
asm_str_style: asm_str_style.unwrap(),
outputs: outputs,
inputs: inputs,
Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/ext/base.rs
Expand Up @@ -28,7 +28,6 @@ use fold::Folder;

use std::collections::HashMap;
use std::rc::Rc;
use std::ops::Deref;

pub trait ItemDecorator {
fn expand(&self,
Expand Down Expand Up @@ -791,7 +790,7 @@ pub fn get_single_str_from_tts(cx: &mut ExtCtxt,
cx.span_err(sp, &format!("{} takes 1 argument", name)[]);
}
expr_to_string(cx, ret, "argument must be a string literal").map(|(s, _)| {
s.deref().to_string()
s.to_string()
})
}

Expand Down
4 changes: 1 addition & 3 deletions src/libsyntax/ext/build.rs
Expand Up @@ -21,8 +21,6 @@ use parse::token::InternedString;
use parse::token;
use ptr::P;

use std::ops::Deref;

// Transitional reexports so qquote can find the paths it is looking for
mod syntax {
pub use ext;
Expand Down Expand Up @@ -577,7 +575,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
let field_name = token::get_ident(ident);
let field_span = Span {
lo: sp.lo - Pos::from_usize(field_name.deref().len()),
lo: sp.lo - Pos::from_usize(field_name.len()),
hi: sp.hi,
expn_id: sp.expn_id,
};
Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/ext/concat.rs
Expand Up @@ -15,7 +15,6 @@ use ext::build::AstBuilder;
use parse::token;

use std::string::String;
use std::ops::Deref;

pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
sp: codemap::Span,
Expand All @@ -33,7 +32,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
ast::LitStr(ref s, _) |
ast::LitFloat(ref s, _) |
ast::LitFloatUnsuffixed(ref s) => {
accumulator.push_str(s.deref());
accumulator.push_str(&s[]);
}
ast::LitChar(c) => {
accumulator.push(c);
Expand Down
4 changes: 1 addition & 3 deletions src/libsyntax/ext/concat_idents.rs
Expand Up @@ -16,8 +16,6 @@ use parse::token;
use parse::token::{str_to_ident};
use ptr::P;

use std::ops::Deref;

pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-> Box<base::MacResult+'cx> {
let mut res_str = String::new();
Expand All @@ -33,7 +31,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
} else {
match *e {
ast::TtToken(_, token::Ident(ident, _)) => {
res_str.push_str(token::get_ident(ident).deref())
res_str.push_str(&token::get_ident(ident)[])
},
_ => {
cx.span_err(sp, "concat_idents! requires ident args.");
Expand Down
4 changes: 1 addition & 3 deletions src/libsyntax/ext/deriving/bounds.rs
Expand Up @@ -15,8 +15,6 @@ use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use ptr::P;

use std::ops::Deref;

pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
Expand All @@ -26,7 +24,7 @@ pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
{
let name = match mitem.node {
MetaWord(ref tname) => {
match tname.deref() {
match &tname[] {
"Copy" => "Copy",
"Send" | "Sync" => {
return cx.span_err(span,
Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/ext/deriving/generic/mod.rs
Expand Up @@ -189,7 +189,6 @@ use self::StructType::*;

use std::cell::RefCell;
use std::vec;
use std::ops::Deref;

use abi::Abi;
use abi;
Expand Down Expand Up @@ -364,7 +363,7 @@ impl<'a> TraitDef<'a> {
// generated implementations are linted
let mut attrs = newitem.attrs.clone();
attrs.extend(item.attrs.iter().filter(|a| {
match a.name().deref() {
match &a.name()[] {
"allow" | "warn" | "deny" | "forbid" => true,
_ => false,
}
Expand Down
4 changes: 1 addition & 3 deletions src/libsyntax/ext/deriving/mod.rs
Expand Up @@ -18,8 +18,6 @@ use ext::base::ExtCtxt;
use codemap::Span;
use ptr::P;

use std::ops::Deref;

pub mod bounds;
pub mod clone;
pub mod encodable;
Expand Down Expand Up @@ -76,7 +74,7 @@ pub fn expand_meta_derive(cx: &mut ExtCtxt,
|i| push(i)))
}

match tname.deref() {
match &tname[] {
"Clone" => expand!(clone::expand_deriving_clone),

"Hash" => expand!(hash::expand_deriving_hash),
Expand Down

0 comments on commit 8b12d3d

Please sign in to comment.