diff options
| author | bors <bors@rust-lang.org> | 2016-05-26 22:46:08 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-26 22:46:08 -0700 |
| commit | 36d5dc7c9bcfd287b5c4e4ac3e2f0ab93bdaa0c9 (patch) | |
| tree | 7e1af7784abe1ebab1c219d13e1a57439eb91996 /src/libsyntax_ext | |
| parent | 97e3a2401e4b2f659d69ed0c0822cae04e3495b7 (diff) | |
| parent | 63dfbdbc1bc1ace106a525682f77b3d08af9ad71 (diff) | |
| download | rust-36d5dc7c9bcfd287b5c4e4ac3e2f0ab93bdaa0c9.tar.gz rust-36d5dc7c9bcfd287b5c4e4ac3e2f0ab93bdaa0c9.zip | |
Auto merge of #33864 - Manishearth:breaking-batch, r=Manishearth
Batch up libsyntax breaking changes cc https://github.com/rust-lang/rust/issues/31645
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 39 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/ty.rs | 10 |
2 files changed, 19 insertions, 30 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 20fb4bf32cc..9095230df63 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -197,7 +197,7 @@ use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; -use syntax::codemap::{self, DUMMY_SP}; +use syntax::codemap::{self, respan, DUMMY_SP}; use syntax::codemap::Span; use syntax::errors::Handler; use syntax::util::move_map::MoveMap; @@ -806,25 +806,21 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, type_ident: Ident, generics: &Generics) - -> (ast::ExplicitSelf, Vec<P<Expr>>, Vec<P<Expr>>, Vec<(Ident, P<ast::Ty>)>) { + -> (Option<ast::ExplicitSelf>, Vec<P<Expr>>, Vec<P<Expr>>, Vec<(Ident, P<ast::Ty>)>) { let mut self_args = Vec::new(); let mut nonself_args = Vec::new(); let mut arg_tys = Vec::new(); let mut nonstatic = false; - let ast_explicit_self = match self.explicit_self { - Some(ref self_ptr) => { - let (self_expr, explicit_self) = - ty::get_explicit_self(cx, trait_.span, self_ptr); + let ast_explicit_self = self.explicit_self.as_ref().map(|self_ptr| { + let (self_expr, explicit_self) = ty::get_explicit_self(cx, trait_.span, self_ptr); - self_args.push(self_expr); - nonstatic = true; + self_args.push(self_expr); + nonstatic = true; - explicit_self - } - None => codemap::respan(trait_.span, ast::SelfKind::Static), - }; + explicit_self + }); for (i, ty) in self.args.iter().enumerate() { let ast_ty = ty.to_ty(cx, trait_.span, type_ident, generics); @@ -857,24 +853,20 @@ impl<'a> MethodDef<'a> { type_ident: Ident, generics: &Generics, abi: Abi, - explicit_self: ast::ExplicitSelf, + explicit_self: Option<ast::ExplicitSelf>, arg_types: Vec<(Ident, P<ast::Ty>)> , body: P<Expr>) -> ast::ImplItem { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics); - let self_arg = match explicit_self.node { - ast::SelfKind::Static => None, - // creating fresh self id - _ => Some(ast::Arg::from_self(explicit_self.clone(), trait_.span, - ast::Mutability::Immutable)), - }; let args = { - let args = arg_types.into_iter().map(|(name, ty)| { - cx.arg(trait_.span, name, ty) - }); - self_arg.into_iter().chain(args).collect() + let self_args = explicit_self.map(|explicit_self| { + ast::Arg::from_self(explicit_self, respan(trait_.span, keywords::SelfValue.ident())) + }); + let nonself_args = arg_types.into_iter() + .map(|(name, ty)| cx.arg(trait_.span, name, ty)); + self_args.into_iter().chain(nonself_args).collect() }; let ret_type = self.get_ret_ty(cx, trait_, generics, type_ident); @@ -900,7 +892,6 @@ impl<'a> MethodDef<'a> { node: ast::ImplItemKind::Method(ast::MethodSig { generics: fn_generics, abi: abi, - explicit_self: explicit_self, unsafety: unsafety, constness: ast::Constness::NotConst, decl: fn_decl diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index e31d45d91a5..b581f5267ea 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -15,11 +15,10 @@ pub use self::PtrTy::*; pub use self::Ty::*; use syntax::ast; -use syntax::ast::{Expr,Generics,Ident}; +use syntax::ast::{Expr, Generics, Ident, SelfKind}; use syntax::ext::base::ExtCtxt; use syntax::ext::build::AstBuilder; use syntax::codemap::{Span,respan}; -use syntax::parse::token::keywords; use syntax::ptr::P; /// The types of pointers @@ -258,12 +257,11 @@ impl<'a> LifetimeBounds<'a> { pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) -> (P<Expr>, ast::ExplicitSelf) { - // this constructs a fresh `self` path, which will match the fresh `self` binding - // created below. + // this constructs a fresh `self` path let self_path = cx.expr_self(span); match *self_ptr { None => { - (self_path, respan(span, ast::SelfKind::Value(keywords::SelfValue.ident()))) + (self_path, respan(span, SelfKind::Value(ast::Mutability::Immutable))) } Some(ref ptr) => { let self_ty = respan( @@ -271,7 +269,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::SelfKind::Region(lt, mutbl, keywords::SelfValue.ident()) + SelfKind::Region(lt, mutbl) } Raw(_) => cx.span_bug(span, "attempted to use *self in deriving definition") }); |
