diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-12-06 11:26:52 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-12-06 11:28:51 +0100 |
| commit | 5e51edb0de138d3805db5ca16160c829d3d32291 (patch) | |
| tree | 5d5856c15639b0ef301d90ed00782f2b8720f685 /src/libsyntax_ext | |
| parent | f7c93c07b8533e1d38395cc2d9d37cd2d9bec978 (diff) | |
| download | rust-5e51edb0de138d3805db5ca16160c829d3d32291.tar.gz rust-5e51edb0de138d3805db5ca16160c829d3d32291.zip | |
annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/custom.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/proc_macro_registrar.rs | 25 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs index 1076a6a6d63..6f02a348f91 100644 --- a/src/libsyntax_ext/deriving/custom.rs +++ b/src/libsyntax_ext/deriving/custom.rs @@ -21,7 +21,7 @@ use syntax::visit::Visitor; struct MarkAttrs<'a>(&'a [ast::Name]); -impl<'a> Visitor for MarkAttrs<'a> { +impl<'a> Visitor<'a> for MarkAttrs<'a> { fn visit_attribute(&mut self, attr: &Attribute) { if self.0.contains(&attr.name()) { mark_used(attr); @@ -101,4 +101,3 @@ impl MultiItemModifier for CustomDerive { res } } - diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 63cd7678321..51199819dfc 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -361,8 +361,8 @@ fn find_type_parameters(ty: &ast::Ty, types: Vec<P<ast::Ty>>, } - impl<'a, 'b> visit::Visitor for Visitor<'a, 'b> { - fn visit_ty(&mut self, ty: &ast::Ty) { + impl<'a, 'b> visit::Visitor<'a> for Visitor<'a, 'b> { + fn visit_ty(&mut self, ty: &'a ast::Ty) { match ty.node { ast::TyKind::Path(_, ref path) if !path.global => { if let Some(segment) = path.segments.first() { diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index 6256440bc81..8fbd11a7a6e 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -52,14 +52,17 @@ pub fn modify(sess: &ParseSess, let ecfg = ExpansionConfig::default("proc_macro".to_string()); let mut cx = ExtCtxt::new(sess, ecfg, resolver); - let mut collect = CollectCustomDerives { - derives: Vec::new(), - in_root: true, - handler: handler, - is_proc_macro_crate: is_proc_macro_crate, - is_test_crate: is_test_crate, + let derives = { + let mut collect = CollectCustomDerives { + derives: Vec::new(), + in_root: true, + handler: handler, + is_proc_macro_crate: is_proc_macro_crate, + is_test_crate: is_test_crate, + }; + visit::walk_crate(&mut collect, &krate); + collect.derives }; - visit::walk_crate(&mut collect, &krate); if !is_proc_macro_crate { return krate @@ -79,7 +82,7 @@ pub fn modify(sess: &ParseSess, return krate; } - krate.module.items.push(mk_registrar(&mut cx, &collect.derives)); + krate.module.items.push(mk_registrar(&mut cx, &derives)); if krate.exported_macros.len() > 0 { handler.err("cannot export macro_rules! macros from a `proc-macro` \ @@ -103,8 +106,8 @@ impl<'a> CollectCustomDerives<'a> { } } -impl<'a> Visitor for CollectCustomDerives<'a> { - fn visit_item(&mut self, item: &ast::Item) { +impl<'a> Visitor<'a> for CollectCustomDerives<'a> { + fn visit_item(&mut self, item: &'a ast::Item) { // First up, make sure we're checking a bare function. If we're not then // we're just not interested in this item. // @@ -240,7 +243,7 @@ impl<'a> Visitor for CollectCustomDerives<'a> { visit::walk_item(self, item); } - fn visit_mod(&mut self, m: &ast::Mod, _s: Span, id: NodeId) { + fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, id: NodeId) { let mut prev_in_root = self.in_root; if id != ast::CRATE_NODE_ID { prev_in_root = mem::replace(&mut self.in_root, false); |
