Skip to content

Commit 2945555

Browse files
committed
Auto merge of #27827 - w00ns:for-loop-expn-issue-27639, r=alexcrichton
Fixes #27639
2 parents 316f5e5 + ae68e90 commit 2945555

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
385385
// expand <head>
386386
let head = fld.fold_expr(head);
387387

388-
// create an hygienic ident
389-
let iter = {
390-
let ident = fld.cx.ident_of("iter");
391-
let new_ident = fresh_name(&ident);
392-
let rename = (ident, new_ident);
393-
let mut rename_list = vec![rename];
394-
let mut rename_fld = IdentRenamer{ renames: &mut rename_list };
395-
396-
rename_fld.fold_ident(ident)
397-
};
388+
let iter = token::gensym_ident("iter");
398389

399390
let pat_span = fld.new_span(pat.span);
400391
// `::std::option::Option::Some(<pat>) => <body>`

src/test/run-pass/issue-27639.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-pretty
12+
13+
fn main() {
14+
const iter: i32 = 0;
15+
16+
for i in 1..10 {
17+
println!("{}", i);
18+
}
19+
}

0 commit comments

Comments
 (0)