diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-02-12 10:41:47 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-02-16 10:55:37 -0500 |
| commit | f58a1bfa981eee4ba4d4c3c801f94772e4ab0019 (patch) | |
| tree | 9bbdee51ea1d846b8af6aa3549de7b76f2d69891 /src/libsyntax/ext/base.rs | |
| parent | 369adaf5150877c124de99a1b9a94f7b522aade6 (diff) | |
| download | rust-f58a1bfa981eee4ba4d4c3c801f94772e4ab0019.tar.gz rust-f58a1bfa981eee4ba4d4c3c801f94772e4ab0019.zip | |
Fix fallout in libsyntax from RFC 599. Clarity and efficiency seems to be mostly improved, to my eye.
Nonetheless, as this commit demonstrates, the previous commits was a [breaking-change]. In practice, breakage is focused on functions of this form: ```rust fn foo(..., object: Box<FnMut()>) ```` where `FnMut()` could be any trait object type. The older scheme defaulted objects in argument position so that they were bounded by a fresh lifetime: ```rust fn foo<'a>(..., object: Box<FnMut()+'a>) ``` This meant that the object could contain borrowed data. The newer scheme defaults to a lifetime bound of `'static`: ```rust fn foo(..., object: Box<FnMut()+'static>) ``` This means that the object cannot contain borrowed data. In some cases, the best fix is to stop using `Box`: ```rust fn foo(..., object: &mut FnMut()) ``` but another option is to write an explicit annotation for the `'a` lifetime that used to be implicit. Both fixes are demonstrated in this commit.
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 64ae6162ef4..083039995ee 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -35,18 +35,18 @@ pub trait ItemDecorator { sp: Span, meta_item: &ast::MetaItem, item: &ast::Item, - push: Box<FnMut(P<ast::Item>)>); + push: &mut FnMut(P<ast::Item>)); } impl<F> ItemDecorator for F - where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, Box<FnMut(P<ast::Item>)>) + where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, &mut FnMut(P<ast::Item>)) { fn expand(&self, ecx: &mut ExtCtxt, sp: Span, meta_item: &ast::MetaItem, item: &ast::Item, - push: Box<FnMut(P<ast::Item>)>) { + push: &mut FnMut(P<ast::Item>)) { (*self)(ecx, sp, meta_item, item, push) } } |
