Skip to content

Commit cd54b3e

Browse files
committed
forbid empty identifiers from concat_idents
1 parent 8a37c75 commit cd54b3e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/libsyntax_ext/concat_idents.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
3131
return base::DummyResult::expr(sp);
3232
}
3333

34+
if tts.is_empty() {
35+
cx.span_err(sp, "concat_idents! takes 1 or more arguments.");
36+
return DummyResult::expr(sp);
37+
}
38+
3439
let mut res_str = String::new();
3540
for (i, e) in tts.iter().enumerate() {
3641
if i & 1 == 1 {

src/test/ui/issue-50403.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 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(concat_idents)]
12+
13+
fn main() {
14+
let x = concat_idents!(); //~ ERROR concat_idents! takes 1 or more arguments
15+
}

0 commit comments

Comments
 (0)