From 77cc5764b9d8b53e01788886d3b3882dffc0001e Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 11 Feb 2016 23:33:09 +0300 Subject: Remove some unnecessary indirection from AST structures --- src/libsyntax_ext/deriving/debug.rs | 4 ++-- src/libsyntax_ext/deriving/generic/mod.rs | 20 ++++++++++---------- src/libsyntax_ext/format.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 858066cb626..6439e9aa498 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -141,7 +141,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, fn stmt_let_undescore(cx: &mut ExtCtxt, sp: Span, - expr: P) -> P { + expr: P) -> ast::Stmt { let local = P(ast::Local { pat: cx.pat_wild(sp), ty: None, @@ -151,5 +151,5 @@ fn stmt_let_undescore(cx: &mut ExtCtxt, attrs: None, }); let decl = respan(sp, ast::DeclKind::Local(local)); - P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) + respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)) } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 1e4babfac1e..160d230f86b 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -312,7 +312,7 @@ pub enum SubstructureFields<'a> { /// variants for the enum itself, and the third component is a list of /// `Ident`s bound to the variant index values for each of the actual /// input `Self` arguments. - EnumNonMatchingCollapsed(Vec, &'a [P], &'a [Ident]), + EnumNonMatchingCollapsed(Vec, &'a [ast::Variant], &'a [Ident]), /// A static method where `Self` is a struct. StaticStruct(&'a ast::VariantData, StaticFields), @@ -466,12 +466,12 @@ impl<'a> TraitDef<'a> { type_ident: Ident, generics: &Generics, field_tys: Vec>, - methods: Vec>) -> P { + methods: Vec) -> P { let trait_path = self.path.to_path(cx, self.span, type_ident, generics); // Transform associated types from `deriving::ty::Ty` into `ast::ImplItem` let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| { - P(ast::ImplItem { + ast::ImplItem { id: ast::DUMMY_NODE_ID, span: self.span, ident: ident, @@ -482,7 +482,7 @@ impl<'a> TraitDef<'a> { type_ident, generics )), - }) + } }); let Generics { mut lifetimes, ty_params, mut where_clause } = @@ -857,7 +857,7 @@ impl<'a> MethodDef<'a> { abi: Abi, explicit_self: ast::ExplicitSelf, arg_types: Vec<(Ident, P)> , - body: P) -> P { + body: P) -> ast::ImplItem { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics); @@ -888,7 +888,7 @@ impl<'a> MethodDef<'a> { }; // Create the method. - P(ast::ImplItem { + ast::ImplItem { id: ast::DUMMY_NODE_ID, attrs: self.attributes.clone(), span: trait_.span, @@ -902,7 +902,7 @@ impl<'a> MethodDef<'a> { constness: ast::Constness::NotConst, decl: fn_decl }, body_block) - }) + } } /// ```ignore @@ -1139,7 +1139,7 @@ impl<'a> MethodDef<'a> { let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| { let (p, idents) = trait_.create_enum_variant_pattern( cx, type_ident, - &**variant, + variant, self_arg_name, ast::Mutability::Immutable); (cx.pat(sp, ast::PatRegion(p, ast::Mutability::Immutable)), idents) @@ -1209,7 +1209,7 @@ impl<'a> MethodDef<'a> { // Self arg, assuming all are instances of VariantK. // Build up code associated with such a case. let substructure = EnumMatching(index, - &**variant, + variant, field_tuples); let arm_expr = self.call_substructure_method( cx, trait_, type_ident, &self_args[..], nonself_args, @@ -1250,7 +1250,7 @@ impl<'a> MethodDef<'a> { // let __self2_vi = unsafe { // std::intrinsics::discriminant_value(&__arg2) } as i32; // ``` - let mut index_let_stmts: Vec> = Vec::new(); + let mut index_let_stmts: Vec = Vec::new(); //We also build an expression which checks whether all discriminants are equal // discriminant_test = __self0_vi == __self1_vi && __self0_vi == __self2_vi && ... diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 4e24eb9f6d7..fd68ba73427 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -461,7 +461,7 @@ impl<'a, 'b> Context<'a, 'b> { // Wrap the declaration in a block so that it forms a single expression. ecx.expr_block(ecx.block(sp, - vec![P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)))], + vec![respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))], Some(ecx.expr_ident(sp, name)))) } -- cgit 1.4.1-3-g733a5