Skip to content

Commit 2f9481e

Browse files
Add regression tests for keywords wrongly considered as macros
1 parent a2239ad commit 2f9481e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This code crashed because a `if` followed by a `!` was considered a macro,
2+
// creating an invalid class stack.
3+
// Regression test for <https://github.com/rust-lang/rust/issues/148617>.
4+
5+
//@ compile-flags: -Zunstable-options --generate-macro-expansion
6+
7+
enum Enum {
8+
Variant,
9+
}
10+
11+
pub fn repro() {
12+
if !matches!(Enum::Variant, Enum::Variant) {}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This test ensures that keywords which can be followed by values (and therefore `!`)
2+
// are not considered as macros.
3+
// This is a regression test for <https://github.com/rust-lang/rust/issues/148617>.
4+
5+
#![crate_name = "foo"]
6+
7+
//@ has 'src/foo/keyword-macros.rs.html'
8+
9+
fn a() {
10+
//@ has - '//*[@class="rust"]//*[@class="kw"]' 'if'
11+
if !true{}
12+
//@ has - '//*[@class="rust"]//*[@class="kw"]' 'match'
13+
match !true { _ => {} }
14+
//@ has - '//*[@class="rust"]//*[@class="kw"]' 'while'
15+
let _ = while !true {
16+
//@ has - '//*[@class="rust"]//*[@class="kw"]' 'break'
17+
break !true;
18+
};
19+
}

0 commit comments

Comments
 (0)