mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
syntax: unbox closures used in let bindings
This commit is contained in:
parent
12dd7781d6
commit
ab402c0744
@ -55,7 +55,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur
|
||||
cx.ident_of("Default"),
|
||||
cx.ident_of("default")
|
||||
);
|
||||
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
|
||||
let default_call = |&: span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
|
||||
|
||||
return match *substr.fields {
|
||||
StaticStruct(_, ref summary) => {
|
||||
|
@ -935,7 +935,7 @@ impl<'a> MethodDef<'a> {
|
||||
// where each tuple has length = self_args.len()
|
||||
let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
|
||||
.map(|(index, variant)| {
|
||||
let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
|
||||
let mk_self_pat = |&: cx: &mut ExtCtxt, self_arg_name: &str| {
|
||||
let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident,
|
||||
&**variant,
|
||||
self_arg_name,
|
||||
|
@ -71,7 +71,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
||||
_ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(Hash)`")
|
||||
};
|
||||
let hash_ident = substr.method_ident;
|
||||
let call_hash = |span, thing_expr| {
|
||||
let call_hash = |&: span, thing_expr| {
|
||||
let expr = cx.expr_method_call(span, thing_expr, hash_ident, vec!(state_expr.clone()));
|
||||
cx.stmt_expr(expr)
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
||||
cx.ident_of("Zero"),
|
||||
cx.ident_of("zero")
|
||||
);
|
||||
let zero_call = |span| cx.expr_call_global(span, zero_ident.clone(), Vec::new());
|
||||
let zero_call = |&: span| cx.expr_call_global(span, zero_ident.clone(), Vec::new());
|
||||
|
||||
return match *substr.fields {
|
||||
StaticStruct(_, ref summary) => {
|
||||
|
@ -1660,7 +1660,7 @@ mod test {
|
||||
assert!((shouldmatch.len() == 0) ||
|
||||
(varrefs.len() > *shouldmatch.iter().max().unwrap()));
|
||||
for (idx,varref) in varrefs.iter().enumerate() {
|
||||
let print_hygiene_debug_info = || {
|
||||
let print_hygiene_debug_info = |&:| {
|
||||
// good lord, you can't make a path with 0 segments, can you?
|
||||
let final_varref_ident = match varref.segments.last() {
|
||||
Some(pathsegment) => pathsegment.identifier,
|
||||
|
@ -800,11 +800,11 @@ fn expand_parse_call(cx: &ExtCtxt,
|
||||
tts: &[ast::TokenTree]) -> P<ast::Expr> {
|
||||
let (cx_expr, tts_expr) = expand_tts(cx, sp, tts);
|
||||
|
||||
let cfg_call = || cx.expr_method_call(
|
||||
let cfg_call = |&:| cx.expr_method_call(
|
||||
sp, cx.expr_ident(sp, id_ext("ext_cx")),
|
||||
id_ext("cfg"), Vec::new());
|
||||
|
||||
let parse_sess_call = || cx.expr_method_call(
|
||||
let parse_sess_call = |&:| cx.expr_method_call(
|
||||
sp, cx.expr_ident(sp, id_ext("ext_cx")),
|
||||
id_ext("parse_sess"), Vec::new());
|
||||
|
||||
|
@ -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>) {
|
||||
|
@ -545,11 +545,11 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
|
||||
let test_id = ecx.ident_of("test");
|
||||
|
||||
// creates self::test::$name
|
||||
let test_path = |name| {
|
||||
let test_path = |&: name| {
|
||||
ecx.path(span, vec![self_id, test_id, ecx.ident_of(name)])
|
||||
};
|
||||
// creates $name: $expr
|
||||
let field = |name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
|
||||
let field = |&: name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
|
||||
|
||||
debug!("encoding {}", ast_util::path_name_i(path[]));
|
||||
|
||||
@ -563,7 +563,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
|
||||
vec![name_expr]);
|
||||
|
||||
let ignore_expr = ecx.expr_bool(span, test.ignore);
|
||||
let should_fail_path = |name| {
|
||||
let should_fail_path = |&: name| {
|
||||
ecx.path(span, vec![self_id, test_id, ecx.ident_of("ShouldFail"), ecx.ident_of(name)])
|
||||
};
|
||||
let fail_expr = match test.should_fail {
|
||||
|
Loading…
Reference in New Issue
Block a user