Skip to content

Commit 6a5c4e7

Browse files
committed
Auto merge of #27691 - jonas-schievink:for-macro, r=alexcrichton
Closes #27004
2 parents d07d465 + a016dfb commit 6a5c4e7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/libsyntax/ext/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
400400
// `::std::option::Option::Some(<pat>) => <body>`
401401
let pat_arm = {
402402
let body_expr = fld.cx.expr_block(body);
403-
let pat = noop_fold_pat(pat, fld);
403+
let pat = fld.fold_pat(pat);
404404
let some_pat = fld.cx.pat_some(pat_span, pat);
405405

406406
fld.cx.arm(pat_span, vec![some_pat], body_expr)

src/test/run-pass/for-loop-macro.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
macro_rules! var {
12+
( $name:ident ) => ( $name );
13+
}
14+
15+
pub fn main() {
16+
let x = [ 3, 3, 3 ];
17+
for var!(i) in &x {
18+
assert_eq!(*i, 3);
19+
}
20+
}

0 commit comments

Comments
 (0)