Skip to content

Commit 6c06bfa

Browse files
committed
Auto merge of #47017 - topecongiro:issue-33469, r=estebank
Do not panic on interpolated token inside quote macro Closes #33469.
2 parents e687205 + d1aa29b commit 6c06bfa

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/libsyntax/ext/quote.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,11 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
669669
vec![mk_name(cx, sp, ast::Ident::with_empty_ctxt(ident))]);
670670
}
671671

672-
token::Interpolated(_) => panic!("quote! with interpolated token"),
672+
token::Interpolated(_) => {
673+
cx.span_err(sp, "quote! with interpolated token");
674+
// Use dummy name.
675+
"Interpolated"
676+
}
673677

674678
token::Eq => "Eq",
675679
token::Lt => "Lt",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 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(quote)]
12+
fn main() {
13+
macro_rules! foo {
14+
($bar:expr) => {
15+
quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token
16+
}
17+
}
18+
foo!(bar);
19+
}

0 commit comments

Comments
 (0)