From 67d88f607ed831cf692387703c34441019b8db96 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:01:10 -0400 Subject: [PATCH 1/4] Remove constraints argument from path_all It was never used --- src/libsyntax/ext/build.rs | 11 +++++------ src/libsyntax_ext/deriving/clone.rs | 2 +- src/libsyntax_ext/deriving/cmp/eq.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 2 +- src/libsyntax_ext/deriving/generic/ty.rs | 8 ++++---- src/libsyntax_ext/env.rs | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f1d0e0b68f735..84a27fcb7dd94 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -14,20 +14,19 @@ pub trait AstBuilder {} impl<'a> ExtCtxt<'a> { pub fn path(&self, span: Span, strs: Vec ) -> ast::Path { - self.path_all(span, false, strs, vec![], vec![]) + self.path_all(span, false, strs, vec![]) } pub fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path { self.path(span, vec![id]) } pub fn path_global(&self, span: Span, strs: Vec ) -> ast::Path { - self.path_all(span, true, strs, vec![], vec![]) + self.path_all(span, true, strs, vec![]) } pub fn path_all(&self, span: Span, global: bool, mut idents: Vec , - args: Vec, - constraints: Vec ) + args: Vec) -> ast::Path { assert!(!idents.is_empty()); let add_root = global && !idents[0].is_path_segment_keyword(); @@ -39,8 +38,8 @@ impl<'a> ExtCtxt<'a> { segments.extend(idents.into_iter().map(|ident| { ast::PathSegment::from_ident(ident.with_span_pos(span)) })); - let args = if !args.is_empty() || !constraints.is_empty() { - ast::AngleBracketedArgs { args, constraints, span }.into() + let args = if !args.is_empty() { + ast::AngleBracketedArgs { args, constraints: Vec::new(), span }.into() } else { None }; diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 4dd0ecfebefd4..9a4c540dc6f1f 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -115,7 +115,7 @@ fn cs_clone_shallow(name: &str, let span = cx.with_def_site_ctxt(span); let assert_path = cx.path_all(span, true, cx.std_path(&[sym::clone, Symbol::intern(helper_name)]), - vec![GenericArg::Type(ty)], vec![]); + vec![GenericArg::Type(ty)]); stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path))); } fn process_variant(cx: &mut ExtCtxt<'_>, stmts: &mut Vec, variant: &VariantData) { diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 32ab47969ada4..471c92dd99949 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -56,7 +56,7 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt<'_>, let span = cx.with_def_site_ctxt(span); let assert_path = cx.path_all(span, true, cx.std_path(&[sym::cmp, Symbol::intern(helper_name)]), - vec![GenericArg::Type(ty)], vec![]); + vec![GenericArg::Type(ty)]); stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path))); } fn process_variant(cx: &mut ExtCtxt<'_>, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index aceee62e89b0c..5c332eccb62cc 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -664,7 +664,7 @@ impl<'a> TraitDef<'a> { }).collect(); // Create the type of `self`. - let path = cx.path_all(self.span, false, vec![type_ident], self_params, vec![]); + let path = cx.path_all(self.span, false, vec![type_ident], self_params); let self_type = cx.ty_path(path); let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived)); diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index b341a07675206..6ae02a5cab199 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -82,12 +82,12 @@ impl<'a> Path<'a> { .collect(); match self.kind { - PathKind::Global => cx.path_all(span, true, idents, params, Vec::new()), - PathKind::Local => cx.path_all(span, false, idents, params, Vec::new()), + PathKind::Global => cx.path_all(span, true, idents, params), + PathKind::Local => cx.path_all(span, false, idents, params), PathKind::Std => { let def_site = cx.with_def_site_ctxt(DUMMY_SP); idents.insert(0, Ident::new(kw::DollarCrate, def_site)); - cx.path_all(span, false, idents, params, Vec::new()) + cx.path_all(span, false, idents, params) } } @@ -183,7 +183,7 @@ impl<'a> Ty<'a> { } }).collect(); - cx.path_all(span, false, vec![self_ty], params, vec![]) + cx.path_all(span, false, vec![self_ty], params) } Literal(ref p) => p.to_path(cx, span, self_ty, generics), Ptr(..) => cx.span_bug(span, "pointer in a path in generic `derive`"), diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index 70e1fbe6af78a..02757bf6b1689 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -32,7 +32,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>, Ident::new(sym::str, sp)), Some(lt), ast::Mutability::Immutable))], - vec![])) + )) } Ok(s) => { cx.expr_call_global(sp, From 2aa9d29c6a054d0aca249eb2f9a002acea4ba175 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:07:28 -0400 Subject: [PATCH 2/4] Remove unused code --- src/libsyntax/ext/build.rs | 294 +------------------------------------ 1 file changed, 3 insertions(+), 291 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 84a27fcb7dd94..70f915bf8c4db 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1,12 +1,11 @@ -use crate::ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; +use crate::ast::{self, Ident, Expr, BlockCheckMode, UnOp, PatKind}; use crate::attr; -use crate::source_map::{dummy_spanned, respan, Spanned}; +use crate::source_map::{respan, Spanned}; use crate::ext::base::ExtCtxt; use crate::ptr::P; use crate::symbol::{kw, sym, Symbol}; use crate::ThinVec; -use rustc_target::spec::abi::Abi; use syntax_pos::{Pos, Span}; // Left so that Cargo tests don't break, this can be removed once those no longer use it @@ -51,42 +50,6 @@ impl<'a> ExtCtxt<'a> { ast::Path { span, segments } } - /// Constructs a qualified path. - /// - /// Constructs a path like `::ident`. - pub fn qpath(&self, - self_type: P, - trait_path: ast::Path, - ident: ast::Ident) - -> (ast::QSelf, ast::Path) { - self.qpath_all(self_type, trait_path, ident, vec![], vec![]) - } - - /// Constructs a qualified path. - /// - /// Constructs a path like `::ident<'a, T, A = Bar>`. - pub fn qpath_all(&self, - self_type: P, - trait_path: ast::Path, - ident: ast::Ident, - args: Vec, - constraints: Vec) - -> (ast::QSelf, ast::Path) { - let mut path = trait_path; - let args = if !args.is_empty() || !constraints.is_empty() { - ast::AngleBracketedArgs { args, constraints, span: ident.span }.into() - } else { - None - }; - path.segments.push(ast::PathSegment { ident, id: ast::DUMMY_NODE_ID, args }); - - (ast::QSelf { - ty: self_type, - path_span: path.span, - position: path.segments.len() - 1 - }, path) - } - pub fn ty_mt(&self, ty: P, mutbl: ast::Mutability) -> ast::MutTy { ast::MutTy { ty, @@ -219,14 +182,6 @@ impl<'a> ExtCtxt<'a> { } } - pub fn stmt_semi(&self, expr: P) -> ast::Stmt { - ast::Stmt { - id: ast::DUMMY_NODE_ID, - span: expr.span, - node: ast::StmtKind::Semi(expr), - } - } - pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P) -> ast::Stmt { let pat = if mutbl { @@ -250,34 +205,6 @@ impl<'a> ExtCtxt<'a> { } } - pub fn stmt_let_typed(&self, - sp: Span, - mutbl: bool, - ident: ast::Ident, - typ: P, - ex: P) - -> ast::Stmt { - let pat = if mutbl { - let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable); - self.pat_ident_binding_mode(sp, ident, binding_mode) - } else { - self.pat_ident(sp, ident) - }; - let local = P(ast::Local { - pat, - ty: Some(typ), - init: Some(ex), - id: ast::DUMMY_NODE_ID, - span: sp, - attrs: ThinVec::new(), - }); - ast::Stmt { - id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Local(local), - span: sp, - } - } - // Generates `let _: Type;`, which is usually used for type assertions. pub fn stmt_let_type_only(&self, span: Span, ty: P) -> ast::Stmt { let local = P(ast::Local { @@ -332,11 +259,6 @@ impl<'a> ExtCtxt<'a> { self.expr(path.span, ast::ExprKind::Path(None, path)) } - /// Constructs a `QPath` expression. - pub fn expr_qpath(&self, span: Span, qself: ast::QSelf, path: ast::Path) -> P { - self.expr(span, ast::ExprKind::Path(Some(qself), path)) - } - pub fn expr_ident(&self, span: Span, id: ast::Ident) -> P { self.expr_path(self.path_ident(span, id)) } @@ -350,27 +272,12 @@ impl<'a> ExtCtxt<'a> { } pub fn expr_deref(&self, sp: Span, e: P) -> P { - self.expr_unary(sp, UnOp::Deref, e) - } - pub fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P) -> P { - self.expr(sp, ast::ExprKind::Unary(op, e)) + self.expr(sp, ast::ExprKind::Unary(UnOp::Deref, e)) } - pub fn expr_field_access( - &self, sp: Span, expr: P, ident: ast::Ident, - ) -> P { - self.expr(sp, ast::ExprKind::Field(expr, ident.with_span_pos(sp))) - } - pub fn expr_tup_field_access(&self, sp: Span, expr: P, idx: usize) -> P { - let ident = Ident::new(sym::integer(idx), sp); - self.expr(sp, ast::ExprKind::Field(expr, ident)) - } pub fn expr_addr_of(&self, sp: Span, e: P) -> P { self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Immutable, e)) } - pub fn expr_mut_addr_of(&self, sp: Span, e: P) -> P { - self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Mutable, e)) - } pub fn expr_call( &self, span: Span, expr: P, args: Vec>, @@ -426,28 +333,10 @@ impl<'a> ExtCtxt<'a> { self.expr_lit(span, ast::LitKind::Int(i as u128, ast::LitIntType::Unsigned(ast::UintTy::Usize))) } - pub fn expr_isize(&self, sp: Span, i: isize) -> P { - if i < 0 { - let i = (-i) as u128; - let lit_ty = ast::LitIntType::Signed(ast::IntTy::Isize); - let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty)); - self.expr_unary(sp, ast::UnOp::Neg, lit) - } else { - self.expr_lit(sp, ast::LitKind::Int(i as u128, - ast::LitIntType::Signed(ast::IntTy::Isize))) - } - } pub fn expr_u32(&self, sp: Span, u: u32) -> P { self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U32))) } - pub fn expr_u16(&self, sp: Span, u: u16) -> P { - self.expr_lit(sp, ast::LitKind::Int(u as u128, - ast::LitIntType::Unsigned(ast::UintTy::U16))) - } - pub fn expr_u8(&self, sp: Span, u: u8) -> P { - self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U8))) - } pub fn expr_bool(&self, sp: Span, value: bool) -> P { self.expr_lit(sp, ast::LitKind::Bool(value)) } @@ -455,10 +344,6 @@ impl<'a> ExtCtxt<'a> { pub fn expr_vec(&self, sp: Span, exprs: Vec>) -> P { self.expr(sp, ast::ExprKind::Array(exprs)) } - pub fn expr_vec_ng(&self, sp: Span) -> P { - self.expr_call_global(sp, self.std_path(&[sym::vec, sym::Vec, sym::new]), - Vec::new()) - } pub fn expr_vec_slice(&self, sp: Span, exprs: Vec>) -> P { self.expr_addr_of(sp, self.expr_vec(sp, exprs)) } @@ -475,16 +360,6 @@ impl<'a> ExtCtxt<'a> { self.expr_call_global(sp, some, vec![expr]) } - pub fn expr_none(&self, sp: Span) -> P { - let none = self.std_path(&[sym::option, sym::Option, sym::None]); - let none = self.path_global(sp, none); - self.expr_path(none) - } - - pub fn expr_break(&self, sp: Span) -> P { - self.expr(sp, ast::ExprKind::Break(None, None)) - } - pub fn expr_tuple(&self, sp: Span, exprs: Vec>) -> P { self.expr(sp, ast::ExprKind::Tup(exprs)) } @@ -513,11 +388,6 @@ impl<'a> ExtCtxt<'a> { self.expr_call_global(sp, ok, vec![expr]) } - pub fn expr_err(&self, sp: Span, expr: P) -> P { - let err = self.std_path(&[sym::result, sym::Result, sym::Err]); - self.expr_call_global(sp, err, vec![expr]) - } - pub fn expr_try(&self, sp: Span, head: P) -> P { let ok = self.std_path(&[sym::result, sym::Result, sym::Ok]); let ok_path = self.path_global(sp, ok); @@ -634,10 +504,6 @@ impl<'a> ExtCtxt<'a> { self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els)) } - pub fn expr_loop(&self, span: Span, block: P) -> P { - self.expr(span, ast::ExprKind::Loop(block, None)) - } - pub fn lambda_fn_decl(&self, span: Span, fn_decl: P, @@ -681,16 +547,6 @@ impl<'a> ExtCtxt<'a> { self.lambda(span, vec![ident], body) } - pub fn lambda_stmts(&self, - span: Span, - ids: Vec, - stmts: Vec) - -> P { - self.lambda(span, ids, self.expr_block(self.block(span, stmts))) - } - pub fn lambda_stmts_0(&self, span: Span, stmts: Vec) -> P { - self.lambda0(span, self.expr_block(self.block(span, stmts))) - } pub fn lambda_stmts_1(&self, span: Span, stmts: Vec, ident: ast::Ident) -> P { self.lambda1(span, self.expr_block(self.block(span, stmts)), ident) @@ -732,43 +588,6 @@ impl<'a> ExtCtxt<'a> { }) } - pub fn item_fn_poly(&self, - span: Span, - name: Ident, - inputs: Vec , - output: P, - generics: Generics, - body: P) -> P { - self.item(span, - name, - Vec::new(), - ast::ItemKind::Fn(self.fn_decl(inputs, ast::FunctionRetTy::Ty(output)), - ast::FnHeader { - unsafety: ast::Unsafety::Normal, - asyncness: dummy_spanned(ast::IsAsync::NotAsync), - constness: dummy_spanned(ast::Constness::NotConst), - abi: Abi::Rust, - }, - generics, - body)) - } - - pub fn item_fn(&self, - span: Span, - name: Ident, - inputs: Vec , - output: P, - body: P - ) -> P { - self.item_fn_poly( - span, - name, - inputs, - output, - Generics::default(), - body) - } - pub fn variant(&self, span: Span, ident: Ident, tys: Vec> ) -> ast::Variant { let fields: Vec<_> = tys.into_iter().map(|ty| { ast::StructField { @@ -799,52 +618,6 @@ impl<'a> ExtCtxt<'a> { } } - pub fn item_enum_poly(&self, span: Span, name: Ident, - enum_definition: ast::EnumDef, - generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::Enum(enum_definition, generics)) - } - - pub fn item_enum(&self, span: Span, name: Ident, - enum_definition: ast::EnumDef) -> P { - self.item_enum_poly(span, name, enum_definition, - Generics::default()) - } - - pub fn item_struct(&self, span: Span, name: Ident, - struct_def: ast::VariantData) -> P { - self.item_struct_poly( - span, - name, - struct_def, - Generics::default() - ) - } - - pub fn item_struct_poly(&self, span: Span, name: Ident, - struct_def: ast::VariantData, generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::Struct(struct_def, generics)) - } - - pub fn item_mod(&self, span: Span, inner_span: Span, name: Ident, - attrs: Vec, - items: Vec>) -> P { - self.item( - span, - name, - attrs, - ast::ItemKind::Mod(ast::Mod { - inner: inner_span, - items, - inline: true - }) - ) - } - - pub fn item_extern_crate(&self, span: Span, name: Ident) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::ExternCrate(None)) - } - pub fn item_static(&self, span: Span, name: Ident, @@ -864,15 +637,6 @@ impl<'a> ExtCtxt<'a> { self.item(span, name, Vec::new(), ast::ItemKind::Const(ty, expr)) } - pub fn item_ty_poly(&self, span: Span, name: Ident, ty: P, - generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::TyAlias(ty, generics)) - } - - pub fn item_ty(&self, span: Span, name: Ident, ty: P) -> P { - self.item_ty_poly(span, name, ty, Generics::default()) - } - pub fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute { attr::mk_attr_outer(mi) } @@ -894,56 +658,4 @@ impl<'a> ExtCtxt<'a> { -> ast::MetaItem { attr::mk_name_value_item(Ident::new(name, span), lit_kind, span) } - - pub fn item_use(&self, sp: Span, - vis: ast::Visibility, vp: P) -> P { - P(ast::Item { - id: ast::DUMMY_NODE_ID, - ident: Ident::invalid(), - attrs: vec![], - node: ast::ItemKind::Use(vp), - vis, - span: sp, - tokens: None, - }) - } - - pub fn item_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> P { - self.item_use_simple_(sp, vis, None, path) - } - - pub fn item_use_simple_(&self, sp: Span, vis: ast::Visibility, - rename: Option, path: ast::Path) -> P { - self.item_use(sp, vis, P(ast::UseTree { - span: sp, - prefix: path, - kind: ast::UseTreeKind::Simple(rename, ast::DUMMY_NODE_ID, ast::DUMMY_NODE_ID), - })) - } - - pub fn item_use_list(&self, sp: Span, vis: ast::Visibility, - path: Vec, imports: &[ast::Ident]) -> P { - let imports = imports.iter().map(|id| { - (ast::UseTree { - span: sp, - prefix: self.path(sp, vec![*id]), - kind: ast::UseTreeKind::Simple(None, ast::DUMMY_NODE_ID, ast::DUMMY_NODE_ID), - }, ast::DUMMY_NODE_ID) - }).collect(); - - self.item_use(sp, vis, P(ast::UseTree { - span: sp, - prefix: self.path(sp, path), - kind: ast::UseTreeKind::Nested(imports), - })) - } - - pub fn item_use_glob(&self, sp: Span, - vis: ast::Visibility, path: Vec) -> P { - self.item_use(sp, vis, P(ast::UseTree { - span: sp, - prefix: self.path(sp, path), - kind: ast::UseTreeKind::Glob, - })) - } } From e41aa8c0d04d9a663638e66a82868f0fbeb83bd8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:05:31 -0400 Subject: [PATCH 3/4] Inline ty_infer --- src/libsyntax/ext/build.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 70f915bf8c4db..cadd7d563dab2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -111,10 +111,6 @@ impl<'a> ExtCtxt<'a> { ast::TyKind::Ptr(self.ty_mt(ty, mutbl))) } - pub fn ty_infer(&self, span: Span) -> P { - self.ty(span, ast::TyKind::Infer) - } - pub fn typaram(&self, span: Span, ident: ast::Ident, @@ -524,7 +520,7 @@ impl<'a> ExtCtxt<'a> { body: P) -> P { let fn_decl = self.fn_decl( - ids.iter().map(|id| self.param(span, *id, self.ty_infer(span))).collect(), + ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(), ast::FunctionRetTy::Default(span)); // FIXME -- We are using `span` as the span of the `|...|` From 8417ac67c3fe979098facad586438ea5244617b3 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:26:15 -0400 Subject: [PATCH 4/4] Inline attribute constructors --- src/libsyntax/ext/build.rs | 14 -------------- src/libsyntax_ext/deriving/cmp/eq.rs | 6 +++--- src/libsyntax_ext/deriving/generic/mod.rs | 7 +++++-- src/libsyntax_ext/test.rs | 4 ++-- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index cadd7d563dab2..ccd73bb66c677 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -640,18 +640,4 @@ impl<'a> ExtCtxt<'a> { pub fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem { attr::mk_word_item(Ident::new(w, sp)) } - - pub fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem { - attr::mk_nested_word_item(Ident::new(w, sp)) - } - - pub fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec) - -> ast::MetaItem { - attr::mk_list_item(Ident::new(name, sp), mis) - } - - pub fn meta_name_value(&self, span: Span, name: ast::Name, lit_kind: ast::LitKind) - -> ast::MetaItem { - attr::mk_name_value_item(Ident::new(name, span), lit_kind, span) - } } diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 471c92dd99949..c92339dd2fbd5 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -2,7 +2,7 @@ use crate::deriving::path_std; use crate::deriving::generic::*; use crate::deriving::generic::ty::*; -use syntax::ast::{self, Expr, MetaItem, GenericArg}; +use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg}; use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives}; use syntax::ptr::P; use syntax::symbol::{sym, Symbol}; @@ -16,8 +16,8 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>, cx.resolver.add_derives(cx.current_expansion.id.expn_data().parent, SpecialDerives::EQ); let inline = cx.meta_word(span, sym::inline); - let hidden = cx.meta_list_item_word(span, sym::hidden); - let doc = cx.meta_list(span, sym::doc, vec![hidden]); + let hidden = syntax::attr::mk_nested_word_item(Ident::new(sym::hidden, span)); + let doc = syntax::attr::mk_list_item(Ident::new(sym::doc, span), vec![hidden]); let attrs = vec![cx.attribute(inline), cx.attribute(doc)]; let trait_def = TraitDef { span, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 5c332eccb62cc..fec035d331dc5 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -672,8 +672,11 @@ impl<'a> TraitDef<'a> { attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); let unused_qual = { - let word = cx.meta_list_item_word(self.span, Symbol::intern("unused_qualifications")); - cx.attribute(cx.meta_list(self.span, sym::allow, vec![word])) + let word = syntax::attr::mk_nested_word_item( + Ident::new(Symbol::intern("unused_qualifications"), self.span)); + let list = syntax::attr::mk_list_item( + Ident::new(sym::allow, self.span), vec![word]); + cx.attribute(list) }; let mut a = vec![attr, unused_qual]; diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index 0910c00a8a2a9..6c7e3e3eb9875 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -145,8 +145,8 @@ pub fn expand_test_or_bench( let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp), vec![ // #[cfg(test)] - cx.attribute(cx.meta_list(attr_sp, sym::cfg, vec![ - cx.meta_list_item_word(attr_sp, sym::test) + cx.attribute(attr::mk_list_item(ast::Ident::new(sym::cfg, attr_sp), vec![ + attr::mk_nested_word_item(ast::Ident::new(sym::test, attr_sp)) ])), // #[rustc_test_marker] cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)),