auto merge of #16891 : eddyb/rust/patlit-from-expr-macros, r=kballard
Enables any macros using `MacExpr` to be treated as patterns when they produce a literal in the form `ExprLit` (e.g. `stringify!` or `line!`). Fixes #16876.
This commit is contained in:
commit
3768ef477e
3 changed files with 20 additions and 0 deletions
|
|
@ -18,4 +18,9 @@ pub fn main() {
|
|||
concat!(1, 2i, 3u, 4f32, 4.0, 'a', true, ()),
|
||||
"12344.0atrue"
|
||||
);
|
||||
|
||||
assert!(match "12344.0atrue" {
|
||||
concat!(1, 2i, 3u, 4f32, 4.0, 'a', true, ()) => true,
|
||||
_ => false
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,9 @@ pub fn main() {
|
|||
[1] == (42 as u8)); // '*'
|
||||
// The Windows tests are wrapped in an extra module for some reason
|
||||
assert!((m1::m2::where_am_i().as_slice().ends_with("m1::m2")));
|
||||
|
||||
assert!(match (47, "( 2 * 3 ) + 5") {
|
||||
(line!(), stringify!((2*3) + 5)) => true,
|
||||
_ => false
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue