mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
Enable macros to pass $:literal to another macro
This commit is contained in:
parent
9f9ac89d11
commit
3d44da65cd
@ -302,6 +302,10 @@ impl Token {
|
||||
BinOp(Minus) => true,
|
||||
Ident(ident, false) if ident.name == keywords::True.name() => true,
|
||||
Ident(ident, false) if ident.name == keywords::False.name() => true,
|
||||
Interpolated(ref nt) => match nt.0 {
|
||||
NtLiteral(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
24
src/test/run-pass/issue-52169.rs
Normal file
24
src/test/run-pass/issue-52169.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(macro_literal_matcher)]
|
||||
|
||||
macro_rules! a {
|
||||
($i:literal) => { "right" };
|
||||
($i:tt) => { "wrong" };
|
||||
}
|
||||
|
||||
macro_rules! b {
|
||||
($i:literal) => { a!($i) };
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(b!(0), "right");
|
||||
}
|
Loading…
Reference in New Issue
Block a user