Add regression test for `unsafe_extern_blocks` · rust-lang/rust@630c3ad

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,30 @@

1+

// Test to ensure the feature is working as expected.

2+
3+

#![feature(unsafe_extern_blocks)]

4+

#![crate_name = "foo"]

5+
6+

// @has 'foo/index.html'

7+
8+

// First we check that both the static and the function have a "sup" element

9+

// to tell they're unsafe.

10+
11+

// @count - '//ul[@class="item-table"]//sup[@title="unsafe static"]' 1

12+

// @has - '//ul[@class="item-table"]//sup[@title="unsafe static"]' '⚠'

13+

// @count - '//ul[@class="item-table"]//sup[@title="unsafe function"]' 1

14+

// @has - '//ul[@class="item-table"]//sup[@title="unsafe function"]' '⚠'

15+
16+

unsafe extern {

17+

// @has 'foo/static.FOO.html'

18+

// @has - '//pre[@class="rust item-decl"]' 'pub static FOO: i32'

19+

pub safe static FOO: i32;

20+

// @has 'foo/static.BAR.html'

21+

// @has - '//pre[@class="rust item-decl"]' 'pub unsafe static BAR: i32'

22+

pub static BAR: i32;

23+
24+

// @has 'foo/fn.foo.html'

25+

// @has - '//pre[@class="rust item-decl"]' 'pub extern "C" fn foo()'

26+

pub safe fn foo();

27+

// @has 'foo/fn.bar.html'

28+

// @has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn bar()'

29+

pub fn bar();

30+

}