File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
tests/rustdoc/source-code-pages Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ #![ feature( negative_impls) ]
7+
8+ //@ has 'src/foo/keyword-macros.rs.html'
9+
10+ //@ has - '//*[@class="rust"]//*[@class="number"]' '2'
11+ //@ has - '//*[@class="rust"]//*[@class="number"]' '0'
12+ //@ has - '//*[@class="rust"]//*[@class="number"]' '1'
13+ const ARR : [ u8 ; 2 ] = [ !0 , ! 1 ] ;
14+
15+ trait X { }
16+
17+ //@ has - '//*[@class="rust"]//*[@class="kw"]' 'impl'
18+ impl !X for i32 { }
19+
20+ fn a ( ) {
21+ //@ has - '//*[@class="rust"]//*[@class="kw"]' 'if'
22+ if ! true { }
23+ //@ has - '//*[@class="rust"]//*[@class="kw"]' 'match'
24+ match !true { _ => { } }
25+ //@ has - '//*[@class="rust"]//*[@class="kw"]' 'while'
26+ let _ = while !true {
27+ //@ has - '//*[@class="rust"]//*[@class="kw"]' 'break'
28+ break !true ;
29+ } ;
30+ }
You can’t perform that action at this time.
0 commit comments