From 6019816da858f900b729a5021248b53c648690a2 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Mon, 23 May 2016 08:54:37 +0000 Subject: [PATCH] Refactor away `set_expn_info` --- src/libsyntax_ext/deriving/generic/mod.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index b5dc5f8da35..d6adec84e84 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -1420,20 +1420,13 @@ impl<'a> MethodDef<'a> { // general helper methods. impl<'a> TraitDef<'a> { - fn set_expn_info(&self, - _cx: &mut ExtCtxt, - mut to_set: Span) -> Span { - to_set.expn_id = self.span.expn_id; - to_set - } - fn summarise_struct(&self, cx: &mut ExtCtxt, struct_def: &VariantData) -> StaticFields { let mut named_idents = Vec::new(); let mut just_spans = Vec::new(); for field in struct_def.fields(){ - let sp = self.set_expn_info(cx, field.span); + let sp = Span { expn_id: self.span.expn_id, ..field.span }; match field.ident { Some(ident) => named_idents.push((ident, sp)), _ => just_spans.push(sp), @@ -1475,7 +1468,7 @@ impl<'a> TraitDef<'a> { let mut paths = Vec::new(); let mut ident_exprs = Vec::new(); for (i, struct_field) in struct_def.fields().iter().enumerate() { - let sp = self.set_expn_info(cx, struct_field.span); + let sp = Span { expn_id: self.span.expn_id, ..struct_field.span }; let ident = cx.ident_of(&format!("{}_{}", prefix, i)); paths.push(codemap::Spanned{span: sp, node: ident}); let val = cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident)));