Skip to content

Commit 0e53360

Browse files
committed
Fix build and add a macro lifetime labels test
1 parent e12b870 commit 0e53360

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ pub mod rt {
192192

193193
impl ToTokens for ast::Lifetime {
194194
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
195-
let lifetime_ident = ast::Ident::with_empty_ctxt(self.name);
196-
vec![TokenTree::Token(DUMMY_SP, token::Lifetime(lifetime_ident))]
195+
vec![TokenTree::Token(DUMMY_SP, token::Lifetime(self.ident))]
197196
}
198197
}
199198

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2012 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+
#![allow(unreachable_code)]
12+
13+
macro_rules! x {
14+
($a:lifetime) => {
15+
$a: loop {
16+
break $a;
17+
panic!("failed");
18+
}
19+
}
20+
}
21+
macro_rules! br {
22+
($a:lifetime) => {
23+
break $a;
24+
}
25+
}
26+
macro_rules! br2 {
27+
($b:lifetime) => {
28+
'b: loop {
29+
break $b; // this $b should refer to the outer loop.
30+
}
31+
}
32+
}
33+
fn main() {
34+
x!('a);
35+
'c: loop {
36+
br!('c);
37+
panic!("failed");
38+
}
39+
'b: loop {
40+
br2!('b);
41+
panic!("failed");
42+
}
43+
}

0 commit comments

Comments
 (0)