diff options
| author | bors <bors@rust-lang.org> | 2016-02-11 12:52:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-02-11 12:52:42 +0000 |
| commit | 7732c0aa9ea12262cbe46fa77c2fa636e8aecf6a (patch) | |
| tree | 8d0364921d0d70e6fdc67176297a1f1ee3e5070e /src/libsyntax_ext | |
| parent | f5f8e0bfbeee2abc425f26a3ad36430f23010e69 (diff) | |
| parent | bafea3bf78e75c99958ef15fd3d06652cb63133c (diff) | |
| download | rust-7732c0aa9ea12262cbe46fa77c2fa636e8aecf6a.tar.gz rust-7732c0aa9ea12262cbe46fa77c2fa636e8aecf6a.zip | |
Auto merge of #31487 - oli-obk:breaking_batch/ast/unop, r=Manishearth
r? @Manishearth I just noticed they can't be rolled up (often modifying the same line(s) in imports). So once I reach the critical amount for them to be merged I'll create a PR that merges all of them.
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/asm.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_ext/concat.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax_ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/ord.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/partial_eq.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/partial_ord.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/debug.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/decodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/encodable.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 92 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/ty.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/hash.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/env.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_ext/format.rs | 16 |
15 files changed, 106 insertions, 113 deletions
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 2f50f610d2b..b9ba1f107ad 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -247,7 +247,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprInlineAsm(ast::InlineAsm { + node: ast::ExprKind::InlineAsm(ast::InlineAsm { asm: token::intern_and_get_ident(&asm), asm_str_style: asm_str_style.unwrap(), outputs: outputs, diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index de913fe0431..db731adf794 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -27,30 +27,26 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, let mut accumulator = String::new(); for e in es { match e.node { - ast::ExprLit(ref lit) => { + ast::ExprKind::Lit(ref lit) => { match lit.node { - ast::LitStr(ref s, _) | - ast::LitFloat(ref s, _) | - ast::LitFloatUnsuffixed(ref s) => { + ast::LitKind::Str(ref s, _) | + ast::LitKind::Float(ref s, _) | + ast::LitKind::FloatUnsuffixed(ref s) => { accumulator.push_str(&s); } - ast::LitChar(c) => { + ast::LitKind::Char(c) => { accumulator.push(c); } - ast::LitInt(i, ast::UnsignedIntLit(_)) | - ast::LitInt(i, ast::SignedIntLit(_, ast::Plus)) | - ast::LitInt(i, ast::UnsuffixedIntLit(ast::Plus)) => { + ast::LitKind::Int(i, ast::LitIntType::Unsigned(_)) | + ast::LitKind::Int(i, ast::LitIntType::Signed(_)) | + ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) => { accumulator.push_str(&format!("{}", i)); } - ast::LitInt(i, ast::SignedIntLit(_, ast::Minus)) | - ast::LitInt(i, ast::UnsuffixedIntLit(ast::Minus)) => { - accumulator.push_str(&format!("-{}", i)); - } - ast::LitBool(b) => { + ast::LitKind::Bool(b) => { accumulator.push_str(&format!("{}", b)); } - ast::LitByte(..) | - ast::LitByteStr(..) => { + ast::LitKind::Byte(..) | + ast::LitKind::ByteStr(..) => { cx.span_err(e.span, "cannot concatenate a byte string literal"); } } diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 9702b24ffd4..85453f6dfcb 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -54,7 +54,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) let e = P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprPath(None, + node: ast::ExprKind::Path(None, ast::Path { span: sp, global: false, diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs index 95a5d184d0e..2fa847ee430 100644 --- a/src/libsyntax_ext/deriving/cmp/ord.rs +++ b/src/libsyntax_ext/deriving/cmp/ord.rs @@ -11,8 +11,7 @@ use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast; -use syntax::ast::{MetaItem, Expr}; +use syntax::ast::{MetaItem, Expr, BinOpKind, self}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -116,7 +115,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, let assign = cx.stmt_let(span, false, test_id, new); - let cond = cx.expr_binary(span, ast::BiEq, + let cond = cx.expr_binary(span, BinOpKind::Eq, cx.expr_ident(span, test_id), cx.expr_path(equals_path.clone())); let if_ = cx.expr_if(span, diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index 29be5a7ddc3..0150a073b07 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -11,7 +11,7 @@ use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{MetaItem, Expr, self}; +use syntax::ast::{MetaItem, Expr, BinOpKind}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -35,9 +35,9 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`") }; - let eq = cx.expr_binary(span, ast::BiEq, self_f, other_f.clone()); + let eq = cx.expr_binary(span, BinOpKind::Eq, self_f, other_f.clone()); - cx.expr_binary(span, ast::BiAnd, subexpr, eq) + cx.expr_binary(span, BinOpKind::And, subexpr, eq) }, cx.expr_bool(span, true), Box::new(|cx, span, _, _| cx.expr_bool(span, false)), @@ -52,9 +52,9 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`") }; - let eq = cx.expr_binary(span, ast::BiNe, self_f, other_f.clone()); + let eq = cx.expr_binary(span, BinOpKind::Ne, self_f, other_f.clone()); - cx.expr_binary(span, ast::BiOr, subexpr, eq) + cx.expr_binary(span, BinOpKind::Or, subexpr, eq) }, cx.expr_bool(span, false), Box::new(|cx, span, _, _| cx.expr_bool(span, true)), diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index bd825e5c8df..e857f7d52f9 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -13,8 +13,7 @@ pub use self::OrderingOp::*; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast; -use syntax::ast::{MetaItem, Expr}; +use syntax::ast::{MetaItem, Expr, BinOpKind, self}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -161,7 +160,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, let assign = cx.stmt_let(span, false, test_id, new); - let cond = cx.expr_binary(span, ast::BiEq, + let cond = cx.expr_binary(span, BinOpKind::Eq, cx.expr_ident(span, test_id), equals_expr.clone()); let if_ = cx.expr_if(span, @@ -183,7 +182,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, /// Strict inequality. fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> { - let op = if less {ast::BiLt} else {ast::BiGt}; + let op = if less { BinOpKind::Lt } else { BinOpKind::Gt }; cs_fold( false, // need foldr, |cx, span, subexpr, self_f, other_fs| { @@ -211,11 +210,11 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, let cmp = cx.expr_binary(span, op, self_f.clone(), other_f.clone()); - let not_cmp = cx.expr_unary(span, ast::UnNot, + let not_cmp = cx.expr_unary(span, ast::UnOp::Not, cx.expr_binary(span, op, other_f.clone(), self_f)); - let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr); - cx.expr_binary(span, ast::BiOr, cmp, and) + let and = cx.expr_binary(span, BinOpKind::And, not_cmp, subexpr); + cx.expr_binary(span, BinOpKind::Or, cmp, and) }, cx.expr_bool(span, equal), Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 008067f39a3..858066cb626 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -27,7 +27,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt, { // &mut ::std::fmt::Formatter let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))), - Borrowed(None, ast::MutMutable)); + Borrowed(None, ast::Mutability::Mutable)); let trait_def = TraitDef { span: span, @@ -71,8 +71,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, // We want to make sure we have the expn_id set so that we can use unstable methods let span = Span { expn_id: cx.backtrace(), .. span }; - let name = cx.expr_lit(span, ast::Lit_::LitStr(ident.name.as_str(), - ast::StrStyle::CookedStr)); + let name = cx.expr_lit(span, ast::LitKind::Str(ident.name.as_str(), ast::StrStyle::Cooked)); let builder = token::str_to_ident("builder"); let builder_expr = cx.expr_ident(span, builder.clone()); @@ -112,9 +111,9 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, stmts.push(cx.stmt_let(DUMMY_SP, true, builder, expr)); for field in fields { - let name = cx.expr_lit(field.span, ast::Lit_::LitStr( + let name = cx.expr_lit(field.span, ast::LitKind::Str( field.name.unwrap().name.as_str(), - ast::StrStyle::CookedStr)); + ast::StrStyle::Cooked)); // Use double indirection to make sure this works for unsized types let field = cx.expr_addr_of(field.span, field.self_.clone()); @@ -151,6 +150,6 @@ fn stmt_let_undescore(cx: &mut ExtCtxt, span: sp, attrs: None, }); - let decl = respan(sp, ast::DeclLocal(local)); - P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))) + let decl = respan(sp, ast::DeclKind::Local(local)); + P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) } diff --git a/src/libsyntax_ext/deriving/decodable.rs b/src/libsyntax_ext/deriving/decodable.rs index 4ea4f04623a..092f8548966 100644 --- a/src/libsyntax_ext/deriving/decodable.rs +++ b/src/libsyntax_ext/deriving/decodable.rs @@ -14,7 +14,7 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast; -use syntax::ast::{MetaItem, Expr, MutMutable}; +use syntax::ast::{MetaItem, Expr, Mutability}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -72,7 +72,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, }, explicit_self: None, args: vec!(Ptr(Box::new(Literal(Path::new_local("__D"))), - Borrowed(None, MutMutable))), + Borrowed(None, Mutability::Mutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core::result::Result), None, diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 02747d38c00..614a6381962 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -91,7 +91,7 @@ use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{MetaItem, Expr, ExprRet, MutMutable}; +use syntax::ast::{MetaItem, Expr, ExprKind, Mutability}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt,Annotatable}; use syntax::ext::build::AstBuilder; @@ -148,7 +148,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, }, explicit_self: borrowed_explicit_self(), args: vec!(Ptr(Box::new(Literal(Path::new_local("__S"))), - Borrowed(None, MutMutable))), + Borrowed(None, Mutability::Mutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core::result::Result), None, @@ -208,16 +208,15 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, let call = if i != last { cx.expr_try(span, call) } else { - cx.expr(span, ExprRet(Some(call))) + cx.expr(span, ExprKind::Ret(Some(call))) }; stmts.push(cx.stmt_expr(call)); } // unit structs have no fields and need to return Ok() if stmts.is_empty() { - let ret_ok = cx.expr(trait_span, - ExprRet(Some(cx.expr_ok(trait_span, - cx.expr_tuple(trait_span, vec![]))))); + let ok = cx.expr_ok(trait_span, cx.expr_tuple(trait_span, vec![])); + let ret_ok = cx.expr(trait_span, ExprKind::Ret(Some(ok))); stmts.push(cx.stmt_expr(ret_ok)); } @@ -254,14 +253,13 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, let call = if i != last { cx.expr_try(span, call) } else { - cx.expr(span, ExprRet(Some(call))) + cx.expr(span, ExprKind::Ret(Some(call))) }; stmts.push(cx.stmt_expr(call)); } } else { - let ret_ok = cx.expr(trait_span, - ExprRet(Some(cx.expr_ok(trait_span, - cx.expr_tuple(trait_span, vec![]))))); + let ok = cx.expr_ok(trait_span, cx.expr_tuple(trait_span, vec![])); + let ret_ok = cx.expr(trait_span, ExprKind::Ret(Some(ok))); stmts.push(cx.stmt_expr(ret_ok)); } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 3af701739b4..1e4babfac1e 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -193,9 +193,7 @@ use std::collections::HashSet; use std::vec; use syntax::abi::Abi; -use syntax::abi; -use syntax::ast; -use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData}; +use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, self}; use syntax::ast_util; use syntax::attr; use syntax::attr::AttrMetaMethods; @@ -356,7 +354,7 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec<P<ast impl<'a> visit::Visitor<'a> for Visitor<'a> { fn visit_ty(&mut self, ty: &'a ast::Ty) { match ty.node { - ast::TyPath(_, ref path) if !path.global => { + ast::TyKind::Path(_, ref path) if !path.global => { match path.segments.first() { Some(segment) => { if self.ty_param_names.contains(&segment.identifier.name) { @@ -393,13 +391,13 @@ impl<'a> TraitDef<'a> { match *item { Annotatable::Item(ref item) => { let newitem = match item.node { - ast::ItemStruct(ref struct_def, ref generics) => { + ast::ItemKind::Struct(ref struct_def, ref generics) => { self.expand_struct_def(cx, &struct_def, item.ident, generics) } - ast::ItemEnum(ref enum_def, ref generics) => { + ast::ItemKind::Enum(ref enum_def, ref generics) => { self.expand_enum_def(cx, enum_def, &item.attrs, @@ -477,7 +475,7 @@ impl<'a> TraitDef<'a> { id: ast::DUMMY_NODE_ID, span: self.span, ident: ident, - vis: ast::Inherited, + vis: ast::Visibility::Inherited, attrs: Vec::new(), node: ast::ImplItemKind::Type(type_def.to_ty(cx, self.span, @@ -559,7 +557,7 @@ impl<'a> TraitDef<'a> { for ty in tys { // if we have already handled this type, skip it - if let ast::TyPath(_, ref p) = ty.node { + if let ast::TyKind::Path(_, ref p) = ty.node { if p.segments.len() == 1 && ty_param_names.contains(&p.segments[0].identifier.name) || processed_field_types.contains(&p.segments) { @@ -639,12 +637,12 @@ impl<'a> TraitDef<'a> { self.span, ident, a, - ast::ItemImpl(unsafety, - ast::ImplPolarity::Positive, - trait_generics, - opt_trait_ref, - self_type, - methods.into_iter().chain(associated_types).collect())) + ast::ItemKind::Impl(unsafety, + ast::ImplPolarity::Positive, + trait_generics, + opt_trait_ref, + self_type, + methods.into_iter().chain(associated_types).collect())) } fn expand_struct_def(&self, @@ -682,7 +680,7 @@ impl<'a> TraitDef<'a> { self, type_ident, generics, - abi::Rust, + Abi::Rust, explicit_self, tys, body) @@ -731,7 +729,7 @@ impl<'a> TraitDef<'a> { self, type_ident, generics, - abi::Rust, + Abi::Rust, explicit_self, tys, body) @@ -750,17 +748,17 @@ fn find_repr_type_name(diagnostic: &Handler, attr::ReprAny | attr::ReprPacked | attr::ReprSimd => continue, attr::ReprExtern => "i32", - attr::ReprInt(_, attr::SignedInt(ast::TyIs)) => "isize", - attr::ReprInt(_, attr::SignedInt(ast::TyI8)) => "i8", - attr::ReprInt(_, attr::SignedInt(ast::TyI16)) => "i16", - attr::ReprInt(_, attr::SignedInt(ast::TyI32)) => "i32", - attr::ReprInt(_, attr::SignedInt(ast::TyI64)) => "i64", - - attr::ReprInt(_, attr::UnsignedInt(ast::TyUs)) => "usize", - attr::ReprInt(_, attr::UnsignedInt(ast::TyU8)) => "u8", - attr::ReprInt(_, attr::UnsignedInt(ast::TyU16)) => "u16", - attr::ReprInt(_, attr::UnsignedInt(ast::TyU32)) => "u32", - attr::ReprInt(_, attr::UnsignedInt(ast::TyU64)) => "u64", + attr::ReprInt(_, attr::SignedInt(ast::IntTy::Is)) => "isize", + attr::ReprInt(_, attr::SignedInt(ast::IntTy::I8)) => "i8", + attr::ReprInt(_, attr::SignedInt(ast::IntTy::I16)) => "i16", + attr::ReprInt(_, attr::SignedInt(ast::IntTy::I32)) => "i32", + attr::ReprInt(_, attr::SignedInt(ast::IntTy::I64)) => "i64", + + attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::Us)) => "usize", + attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U8)) => "u8", + attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U16)) => "u16", + attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U32)) => "u32", + attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U64)) => "u64", } } } @@ -823,7 +821,7 @@ impl<'a> MethodDef<'a> { explicit_self } - None => codemap::respan(trait_.span, ast::SelfStatic), + None => codemap::respan(trait_.span, ast::SelfKind::Static), }; for (i, ty) in self.args.iter().enumerate() { @@ -864,9 +862,11 @@ impl<'a> MethodDef<'a> { let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics); let self_arg = match explicit_self.node { - ast::SelfStatic => None, + ast::SelfKind::Static => None, // creating fresh self id - _ => Some(ast::Arg::new_self(trait_.span, ast::MutImmutable, special_idents::self_)) + _ => Some(ast::Arg::new_self(trait_.span, + ast::Mutability::Immutable, + special_idents::self_)) }; let args = { let args = arg_types.into_iter().map(|(name, ty)| { @@ -892,7 +892,7 @@ impl<'a> MethodDef<'a> { id: ast::DUMMY_NODE_ID, attrs: self.attributes.clone(), span: trait_.span, - vis: ast::Inherited, + vis: ast::Visibility::Inherited, ident: method_ident, node: ast::ImplItemKind::Method(ast::MethodSig { generics: fn_generics, @@ -944,7 +944,7 @@ impl<'a> MethodDef<'a> { struct_def, &format!("__self_{}", i), - ast::MutImmutable); + ast::Mutability::Immutable); patterns.push(pat); raw_fields.push(ident_expr); } @@ -1137,11 +1137,12 @@ impl<'a> MethodDef<'a> { let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate() .map(|(index, variant)| { let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| { - let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident, - &**variant, - self_arg_name, - ast::MutImmutable); - (cx.pat(sp, ast::PatRegion(p, ast::MutImmutable)), idents) + let (p, idents) = trait_.create_enum_variant_pattern( + cx, type_ident, + &**variant, + self_arg_name, + ast::Mutability::Immutable); + (cx.pat(sp, ast::PatRegion(p, ast::Mutability::Immutable)), idents) }; // A single arm has form (&VariantK, &VariantK, ...) => BodyK @@ -1267,7 +1268,7 @@ impl<'a> MethodDef<'a> { stmts: vec![], expr: Some(call), id: ast::DUMMY_NODE_ID, - rules: ast::UnsafeBlock(ast::CompilerGenerated), + rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated), span: sp })); let target_ty = cx.ty_ident(sp, cx.ident_of(target_type_name)); @@ -1279,8 +1280,9 @@ impl<'a> MethodDef<'a> { Some(first) => { let first_expr = cx.expr_ident(sp, first); let id = cx.expr_ident(sp, ident); - let test = cx.expr_binary(sp, ast::BiEq, first_expr, id); - discriminant_test = cx.expr_binary(sp, ast::BiAnd, discriminant_test, test) + let test = cx.expr_binary(sp, BinOpKind::Eq, first_expr, id); + discriminant_test = cx.expr_binary(sp, BinOpKind::And, + discriminant_test, test) } None => { first_ident = Some(ident); @@ -1302,7 +1304,7 @@ impl<'a> MethodDef<'a> { stmts: vec![], expr: Some(call), id: ast::DUMMY_NODE_ID, - rules: ast::UnsafeBlock(ast::CompilerGenerated), + rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated), span: sp })); match_arms.push(cx.arm(sp, vec![cx.pat_wild(sp)], unreachable)); @@ -1312,7 +1314,7 @@ impl<'a> MethodDef<'a> { // expression; here add a layer of borrowing, turning // `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`. let borrowed_self_args = self_args.move_map(|self_arg| cx.expr_addr_of(sp, self_arg)); - let match_arg = cx.expr(sp, ast::ExprTup(borrowed_self_args)); + let match_arg = cx.expr(sp, ast::ExprKind::Tup(borrowed_self_args)); //Lastly we create an expression which branches on all discriminants being equal // if discriminant_test { @@ -1390,7 +1392,7 @@ impl<'a> MethodDef<'a> { // expression; here add a layer of borrowing, turning // `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`. let borrowed_self_args = self_args.move_map(|self_arg| cx.expr_addr_of(sp, self_arg)); - let match_arg = cx.expr(sp, ast::ExprTup(borrowed_self_args)); + let match_arg = cx.expr(sp, ast::ExprKind::Tup(borrowed_self_args)); cx.expr_match(sp, match_arg, match_arms) } } @@ -1510,8 +1512,8 @@ impl<'a> TraitDef<'a> { }; let ident = cx.ident_of(&format!("{}_{}", prefix, i)); paths.push(codemap::Spanned{span: sp, node: ident}); - let val = cx.expr( - sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident))))); + let val = cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident))); + let val = cx.expr(sp, ast::ExprKind::Paren(val)); ident_expr.push((sp, opt_id, val, &struct_field.node.attrs[..])); } diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 10564b5f698..a924cc06953 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -98,7 +98,7 @@ pub enum Ty<'a> { } pub fn borrowed_ptrty<'r>() -> PtrTy<'r> { - Borrowed(None, ast::MutImmutable) + Borrowed(None, ast::Mutability::Immutable) } pub fn borrowed<'r>(ty: Box<Ty<'r>>) -> Ty<'r> { Ptr(ty, borrowed_ptrty()) @@ -153,7 +153,7 @@ impl<'a> Ty<'a> { cx.ty_path(self.to_path(cx, span, self_ty, self_generics)) } Tuple(ref fields) => { - let ty = ast::TyTup(fields.iter() + let ty = ast::TyKind::Tup(fields.iter() .map(|f| f.to_ty(cx, span, self_ty, self_generics)) .collect()); cx.ty(span, ty) @@ -264,7 +264,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) let self_path = cx.expr_self(span); match *self_ptr { None => { - (self_path, respan(span, ast::SelfValue(special_idents::self_))) + (self_path, respan(span, ast::SelfKind::Value(special_idents::self_))) } Some(ref ptr) => { let self_ty = respan( @@ -272,7 +272,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) match *ptr { Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s).name)); - ast::SelfRegion(lt, mutbl, special_idents::self_) + ast::SelfKind::Region(lt, mutbl, special_idents::self_) } Raw(_) => cx.span_bug(span, "attempted to use *self in deriving definition") }); diff --git a/src/libsyntax_ext/deriving/hash.rs b/src/libsyntax_ext/deriving/hash.rs index 6bd21f7c0e0..371ba732b48 100644 --- a/src/libsyntax_ext/deriving/hash.rs +++ b/src/libsyntax_ext/deriving/hash.rs @@ -11,7 +11,7 @@ use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{MetaItem, Expr, MutMutable}; +use syntax::ast::{MetaItem, Expr, Mutability}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -43,7 +43,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, vec![path_std!(cx, core::hash::Hasher)])], }, explicit_self: borrowed_explicit_self(), - args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, MutMutable))), + args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mutable))), ret_ty: nil_ty(), attributes: vec![], is_unsafe: false, diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index dcaa9644603..4e2142f1fb4 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -13,7 +13,7 @@ //! FIXME (#2810): hygiene. Search for "__" strings (in other files too). We also assume "extra" is //! the standard library, and "std" is the core library. -use syntax::ast::{MetaItem, MetaWord}; +use syntax::ast::{MetaItem, MetaItemKind}; use syntax::attr::AttrMetaMethods; use syntax::ext::base::{ExtCtxt, SyntaxEnv, Annotatable}; use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier}; @@ -94,7 +94,7 @@ fn expand_derive(cx: &mut ExtCtxt, for titem in traits.iter().rev() { let tname = match titem.node { - MetaWord(ref tname) => tname, + MetaItemKind::Word(ref tname) => tname, _ => { cx.span_err(titem.span, "malformed `derive` entry"); continue; diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index f1dd6854a3a..63ec9cac073 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -42,7 +42,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT Some(cx.lifetime(sp, cx.ident_of( "'static").name)), - ast::MutImmutable)), + ast::Mutability::Immutable)), Vec::new())) } Ok(s) => { diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 77bf90abbcc..4e24eb9f6d7 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -409,7 +409,7 @@ impl<'a, 'b> Context<'a, 'b> { } // Translate the format - let fill = self.ecx.expr_lit(sp, ast::LitChar(fill)); + let fill = self.ecx.expr_lit(sp, ast::LitKind::Char(fill)); let align = |name| { let mut p = Context::rtpath(self.ecx, "Alignment"); p.push(self.ecx.ident_of(name)); @@ -448,20 +448,20 @@ impl<'a, 'b> Context<'a, 'b> { -> P<ast::Expr> { let sp = piece_ty.span; let ty = ecx.ty_rptr(sp, - ecx.ty(sp, ast::TyVec(piece_ty)), + ecx.ty(sp, ast::TyKind::Vec(piece_ty)), Some(ecx.lifetime(sp, special_idents::static_lifetime.name)), - ast::MutImmutable); + ast::Mutability::Immutable); let slice = ecx.expr_vec_slice(sp, pieces); // static instead of const to speed up codegen by not requiring this to be inlined - let st = ast::ItemStatic(ty, ast::MutImmutable, slice); + let st = ast::ItemKind::Static(ty, ast::Mutability::Immutable, slice); let name = ecx.ident_of(name); let item = ecx.item(sp, name, vec![], st); - let decl = respan(sp, ast::DeclItem(item)); + let decl = respan(sp, ast::DeclKind::Item(item)); // Wrap the declaration in a block so that it forms a single expression. ecx.expr_block(ecx.block(sp, - vec![P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))], + vec![P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)))], Some(ecx.expr_ident(sp, name)))) } @@ -480,7 +480,7 @@ impl<'a, 'b> Context<'a, 'b> { self.fmtsp, self.ecx.ty_ident(self.fmtsp, self.ecx.ident_of("str")), Some(static_lifetime), - ast::MutImmutable); + ast::Mutability::Immutable); let pieces = Context::static_array(self.ecx, "__STATIC_FMTSTR", piece_ty, @@ -559,7 +559,7 @@ impl<'a, 'b> Context<'a, 'b> { // as series of let's; the first approach does. let pat = self.ecx.pat_tuple(self.fmtsp, pats); let arm = self.ecx.arm(self.fmtsp, vec!(pat), args_array); - let head = self.ecx.expr(self.fmtsp, ast::ExprTup(heads)); + let head = self.ecx.expr(self.fmtsp, ast::ExprKind::Tup(heads)); let result = self.ecx.expr_match(self.fmtsp, head, vec!(arm)); let args_slice = self.ecx.expr_addr_of(self.fmtsp, result); |
