diff options
| author | bors <bors@rust-lang.org> | 2015-01-01 04:01:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-01 04:01:02 +0000 |
| commit | 47b8479e73e40395f1b1b2d0c6281f28f80301e4 (patch) | |
| tree | a8ae69e94286da9d3b153e39300130271ad1f3f8 /src/libsyntax/parse | |
| parent | 7d4f4876d65bddf101784230c0347adcb01e5c21 (diff) | |
| parent | 10bbf69488b4863378e4acd9d55bde36b4a20909 (diff) | |
| download | rust-47b8479e73e40395f1b1b2d0c6281f28f80301e4.tar.gz rust-47b8479e73e40395f1b1b2d0c6281f28f80301e4.zip | |
auto merge of #20363 : japaric/rust/moar-uc, r=nmatsakis
The the last argument of the `ItemDecorator::expand` method has changed to `Box<FnMut>`. Syntax extensions will break.
[breaking-change]
---
This PR removes pretty much all the remaining uses of boxed closures from the libraries. There are still boxed closures under the `test` directory, but I think those should be removed or replaced with unboxed closures at the same time we remove boxed closures from the language.
In a few places I had to do some contortions (see the first commit for an example) to work around issue #19596. I have marked those workarounds with FIXMEs. In the future when `&mut F where F: FnMut` implements the `FnMut` trait, we should be able to remove those workarounds. I've take care to avoid placing the workaround functions in the public API.
Since `let f = || {}` always gets type checked as a boxed closure, I have explictly annotated those closures (with e.g. `|&:| {}`) to force the compiler to type check them as unboxed closures.
Instead of removing the type aliases (like `GetCrateDataCb`), I could have replaced them with newtypes. But this seemed like overcomplicating things for little to no gain.
I think we should be able to remove the boxed closures from the languge after this PR lands. (I'm being optimistic here)
r? @alexcrichton or @aturon
cc @nikomatsakis
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 8cefb111fd1..88c485a07ac 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -240,7 +240,7 @@ pub fn new_parser_from_tts<'a>(sess: &'a ParseSess, /// add the path to the session's codemap and return the new filemap. pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>) -> Rc<FileMap> { - let err = |msg: &str| { + let err = |&: msg: &str| { match spanopt { Some(sp) => sess.span_diagnostic.span_fatal(sp, msg), None => sess.span_diagnostic.handler().fatal(msg), @@ -399,7 +399,7 @@ pub fn char_lit(lit: &str) -> (char, int) { .map(|x| (x, len as int)) } - let unicode_escape: || -> Option<(char, int)> = || + let unicode_escape = |&: | -> Option<(char, int)> if lit.as_bytes()[2] == b'{' { let idx = lit.find('}').expect(msg2); let subslice = lit[3..idx]; @@ -426,7 +426,7 @@ pub fn str_lit(lit: &str) -> String { let mut res = String::with_capacity(lit.len()); // FIXME #8372: This could be a for-loop if it didn't borrow the iterator - let error = |i| format!("lexer should have rejected {} at {}", lit, i); + let error = |&: i| format!("lexer should have rejected {} at {}", lit, i); /// Eat everything up to a non-whitespace fn eat<'a>(it: &mut iter::Peekable<(uint, char), str::CharIndices<'a>>) { @@ -561,7 +561,7 @@ pub fn float_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> a /// Parse a string representing a byte literal into its final form. Similar to `char_lit` pub fn byte_lit(lit: &str) -> (u8, uint) { - let err = |i| format!("lexer accepted invalid byte literal {} step {}", lit, i); + let err = |&: i| format!("lexer accepted invalid byte literal {} step {}", lit, i); if lit.len() == 1 { (lit.as_bytes()[0], 1) @@ -595,7 +595,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> { let mut res = Vec::with_capacity(lit.len()); // FIXME #8372: This could be a for-loop if it didn't borrow the iterator - let error = |i| format!("lexer should have rejected {} at {}", lit, i); + let error = |&: i| format!("lexer should have rejected {} at {}", lit, i); /// Eat everything up to a non-whitespace fn eat<'a, I: Iterator<(uint, u8)>>(it: &mut iter::Peekable<(uint, u8), I>) { |
