File tree 2 files changed +32
-7
lines changed
2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -135,17 +135,21 @@ at INTERPOLATED tokens */
135
135
macro_rules! maybe_whole_expr (
136
136
( $p: expr) => (
137
137
{
138
- let mut maybe_path = match ( $p) . token {
139
- INTERPOLATED ( token:: NtPath ( ref pt) ) => Some ( ( * * pt) . clone( ) ) ,
140
- _ => None ,
141
- } ;
142
- let found = match ( $p) . token {
138
+ let found = match $p. token {
143
139
INTERPOLATED ( token:: NtExpr ( e) ) => {
144
140
Some ( e)
145
141
}
146
142
INTERPOLATED ( token:: NtPath ( _) ) => {
147
- let pt = maybe_path. take_unwrap( ) ;
148
- Some ( $p. mk_expr( ( $p) . span. lo, ( $p) . span. hi, ExprPath ( pt) ) )
143
+ // FIXME: The following avoids an issue with lexical borrowck scopes,
144
+ // but the clone is unfortunate.
145
+ let pt = match $p. token {
146
+ INTERPOLATED ( token:: NtPath ( ref pt) ) => ( * * pt) . clone( ) ,
147
+ _ => unreachable!( )
148
+ } ;
149
+ Some ( $p. mk_expr( $p. span. lo, $p. span. hi, ExprPath ( pt) ) )
150
+ }
151
+ INTERPOLATED ( token:: NtBlock ( b) ) => {
152
+ Some ( $p. mk_expr( $p. span. lo, $p. span. hi, ExprBlock ( b) ) )
149
153
}
150
154
_ => None
151
155
} ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 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
+ #![ feature( macro_rules) ]
12
+
13
+ macro_rules! do_block{
14
+ ( $val: block) => { $val}
15
+ }
16
+
17
+ fn main ( ) {
18
+ let s;
19
+ do_block ! ( { s = "it works!" ; } ) ;
20
+ assert_eq ! ( s, "it works!" ) ;
21
+ }
You can’t perform that action at this time.
0 commit comments