Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.

This commit is contained in:
Simon Sapin 2015-04-23 00:14:02 +02:00 committed by Josh Matthews
parent 7b87085c18
commit ef8edd4e87
168 changed files with 2247 additions and 2408 deletions

View file

@ -11,17 +11,17 @@ use syntax::parse::token;
pub fn expand_lower<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-> Box<base::MacResult + 'cx> {
expand_cased(cx, sp, tts, |c| { c.to_lowercase() })
expand_cased(cx, sp, tts, |s| { s.to_lowercase() })
}
pub fn expand_upper<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-> Box<base::MacResult + 'cx> {
expand_cased(cx, sp, tts, |c| { c.to_uppercase() })
expand_cased(cx, sp, tts, |s| { s.to_uppercase() })
}
fn expand_cased<'cx, T>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree], transform: T)
-> Box<base::MacResult + 'cx>
where T: Fn(char) -> char
where T: Fn(&str) -> String
{
let es = match base::get_exprs_from_tts(cx, sp, tts) {
Some(e) => e,
@ -47,8 +47,7 @@ fn expand_cased<'cx, T>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree],
};
match (res, it.count()) {
(Some((s, span)), 0) => {
let new_s = s.chars().map(transform).collect::<String>();
base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(&new_s)))
base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(&transform(&s))))
}
(_, rest) => {
if rest > 0 {

View file

@ -47,15 +47,16 @@ pub fn expand_jstraceable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item:
],
associated_types: vec![],
};
trait_def.expand(cx, mitem, item, |a| push(a))
trait_def.expand(cx, mitem, item, push)
}
// Mostly copied from syntax::ext::deriving::hash
/// Defines how the implementation for `trace()` is to be generated
fn jstraceable_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
let state_expr = match substr.nonself_args {
[ref state_expr] => state_expr,
_ => cx.span_bug(trait_span, "incorrect number of arguments in `jstraceable`")
let state_expr = if substr.nonself_args.len() == 1 {
&substr.nonself_args[0]
} else {
cx.span_bug(trait_span, "incorrect number of arguments in `jstraceable`")
};
let trace_ident = substr.method_ident;
let call_trace = |span, thing_expr| {

View file

@ -12,7 +12,7 @@
//! - `#[dom_struct]` : Implies `#[privatize]`,`#[jstraceable]`, and `#[must_root]`.
//! Use this for structs that correspond to a DOM type
#![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, unicode)]
#![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, collections)]
#[macro_use]
extern crate syntax;

View file

@ -33,7 +33,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
ast::TyPath(..) => {
match cx.tcx.def_map.borrow()[ty.id] {
match cx.tcx.def_map.borrow()[&ty.id] {
def::PathResolution{ base_def: def::DefTy(def_id, _), .. } => {
if ty::has_attr(cx.tcx, def_id, "must_root") {
cx.span_lint(UNROOTED_MUST_ROOT, ty.span, warning);
@ -78,11 +78,11 @@ impl LintPass for UnrootedPass {
fn check_fn(&mut self, cx: &Context, kind: visit::FnKind, decl: &ast::FnDecl,
block: &ast::Block, _span: codemap::Span, id: ast::NodeId) {
match kind {
visit::FkItemFn(i, _, _, _) |
visit::FkItemFn(i, _, _, _, _) |
visit::FkMethod(i, _, _) if i.as_str() == "new" || i.as_str() == "new_inherited" => {
return;
},
visit::FkItemFn(_, _, style, _) => match style {
visit::FkItemFn(_, _, style, _, _) => match style {
ast::Unsafety::Unsafe => return,
_ => ()
},

View file

@ -69,15 +69,9 @@ pub fn match_lang_ty(cx: &Context, ty: &Ty, value: &str) -> bool {
pub fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool {
match map.find(map.get_parent(id)) {
Some(ast_map::NodeImplItem(itm)) => {
match *itm {
ast::MethodImplItem(ref meth) => match meth.node {
ast::MethDecl(_, _, _, _, style, _, _, _) => match style {
ast::Unsafety::Unsafe => true,
_ => false,
},
_ => false,
},
_ => false,
match itm.node {
ast::MethodImplItem(ref sig, _) => sig.unsafety == ast::Unsafety::Unsafe,
_ => false
}
},
Some(ast_map::NodeItem(itm)) => {