diff options
| author | bors <bors@rust-lang.org> | 2015-08-15 14:50:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-08-15 14:50:13 +0000 |
| commit | 29455557aa48d1047f274e60703edf7813fe5b6b (patch) | |
| tree | 8e3d678e2e736b1119e79ae9cc0cf64085dc00ed | |
| parent | 316f5e5acfe6e69bc7ab39b0e4feed116a86a58a (diff) | |
| parent | ae68e90af49c4cf9c75778e570d436fe36011b23 (diff) | |
| download | rust-29455557aa48d1047f274e60703edf7813fe5b6b.tar.gz rust-29455557aa48d1047f274e60703edf7813fe5b6b.zip | |
Auto merge of #27827 - w00ns:for-loop-expn-issue-27639, r=alexcrichton
Fixes #27639
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 11 | ||||
| -rw-r--r-- | src/test/run-pass/issue-27639.rs | 19 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 6c09d6c107e..e61a0b5401e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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>` diff --git a/src/test/run-pass/issue-27639.rs b/src/test/run-pass/issue-27639.rs new file mode 100644 index 00000000000..44c1eb86de8 --- /dev/null +++ b/src/test/run-pass/issue-27639.rs @@ -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); + } +} |
