Fix issue with for loop expansion

This commit is contained in:
w00ns 2015-08-14 07:23:29 +02:00 committed by tof
parent e9205a20a8
commit ae68e90af4
2 changed files with 20 additions and 10 deletions

View File

@ -385,16 +385,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
// expand <head>
let head = fld.fold_expr(head);
// create an hygienic ident
let iter = {
let ident = fld.cx.ident_of("iter");
let new_ident = fresh_name(&ident);
let rename = (ident, new_ident);
let mut rename_list = vec![rename];
let mut rename_fld = IdentRenamer{ renames: &mut rename_list };
rename_fld.fold_ident(ident)
};
let iter = token::gensym_ident("iter");
let pat_span = fld.new_span(pat.span);
// `::std::option::Option::Some(<pat>) => <body>`

View File

@ -0,0 +1,19 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty
fn main() {
const iter: i32 = 0;
for i in 1..10 {
println!("{}", i);
}
}