Skip to content

Commit 784b283

Browse files
committed
add a test for nested type ascriptions of never type
1 parent 62f7cf4 commit 784b283

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/149542>.
2+
//
3+
// This checks that a nested type ascription doesn't cause a crash when the
4+
// compiler checks if it constitutes a read of the never type.
5+
//
6+
//@ known-bug: #149542
7+
8+
#![feature(never_type)]
9+
#![feature(type_ascription)]
10+
#![deny(unreachable_code)]
11+
12+
fn main() {
13+
unsafe {
14+
let _ = type_ascribe!(type_ascribe!(*std::ptr::null(), !), _);
15+
16+
// this is *not* unreachable, because previous line does not actually read the never type
17+
();
18+
}
19+
}
20+

0 commit comments

Comments
 (0)