Skip to content

Commit c4396f4

Browse files
committed
Added some tests for unsafe in const-dispay.rs
1 parent 5fb27bc commit c4396f4

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

src/test/rustdoc/const-display.rs

+47-6
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,57 @@
1313
#[rustc_const_unstable(feature="foo", issue = "none")]
1414
pub const fn foo() -> u32 { 42 }
1515

16+
// @has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32'
17+
// @has - '//span[@class="since"]' '1.0.0 (const: unstable)'
18+
#[stable(feature = "rust1", since = "1.0.0")]
19+
#[rustc_const_unstable(feature="foo", issue = "none")]
20+
pub const unsafe fn foo_unsafe() -> u32 { 42 }
21+
1622
// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
1723
#[unstable(feature = "humans", issue = "none")]
1824
pub const fn foo2() -> u32 { 42 }
1925

26+
// @has 'foo/fn.foo2_unsafe.html' '//pre' 'pub const unsafe fn foo2_unsafe() -> u32'
27+
#[unstable(feature = "humans", issue = "none")]
28+
pub const unsafe fn foo2_unsafe() -> u32 { 42 }
29+
2030
// @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32'
2131
// @has - //span '1.0.0 (const: 1.0.0)'
2232
#[stable(feature = "rust1", since = "1.0.0")]
2333
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
2434
pub const fn bar2() -> u32 { 42 }
2535

26-
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
36+
// @has 'foo/fn.bar2_unsafe.html' '//pre' 'pub const unsafe fn bar2_unsafe() -> u32'
37+
// @has - //span '1.0.0 (const: 1.0.0)'
38+
#[stable(feature = "rust1", since = "1.0.0")]
39+
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
40+
pub const unsafe fn bar2_unsafe() -> u32 { 42 }
41+
42+
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const fn foo2_gated() -> u32'
2743
#[unstable(feature = "foo2", issue = "none")]
28-
pub const unsafe fn foo2_gated() -> u32 { 42 }
44+
pub const fn foo2_gated() -> u32 { 42 }
2945

30-
// @has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32'
46+
// @has 'foo/fn.foo2_gated_unsafe.html' '//pre' 'pub const unsafe fn foo2_gated_unsafe() -> u32'
47+
#[unstable(feature = "foo2", issue = "none")]
48+
pub const unsafe fn foo2_gated_unsafe() -> u32 { 42 }
49+
50+
// @has 'foo/fn.bar2_gated.html' '//pre' 'pub const fn bar2_gated() -> u32'
3151
// @has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)'
3252
#[stable(feature = "rust1", since = "1.0.0")]
3353
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
34-
pub const unsafe fn bar2_gated() -> u32 { 42 }
54+
pub const fn bar2_gated() -> u32 { 42 }
3555

36-
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
37-
pub const unsafe fn bar_not_gated() -> u32 { 42 }
56+
// @has 'foo/fn.bar2_gated_unsafe.html' '//pre' 'pub const unsafe fn bar2_gated_unsafe() -> u32'
57+
// @has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)'
58+
#[stable(feature = "rust1", since = "1.0.0")]
59+
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
60+
pub const unsafe fn bar2_gated_unsafe() -> u32 { 42 }
61+
62+
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const fn bar_not_gated() -> u32'
63+
pub const fn bar_not_gated() -> u32 { 42 }
64+
65+
// @has 'foo/fn.bar_not_gated_unsafe.html' '//pre' 'pub const unsafe fn bar_not_gated_unsafe() -> u32'
66+
pub const unsafe fn bar_not_gated_unsafe() -> u32 { 42 }
3867

3968
pub struct Foo;
4069

@@ -45,9 +74,21 @@ impl Foo {
4574
#[rustc_const_unstable(feature="foo", issue = "none")]
4675
pub const fn gated() -> u32 { 42 }
4776

77+
// @has 'foo/struct.Foo.html' '//div[@id="method.gated_unsafe"]/code' 'pub unsafe fn gated_unsafe() -> u32'
78+
// @has - '//span[@class="since"]' '1.0.0 (const: unstable)'
79+
#[stable(feature = "rust1", since = "1.0.0")]
80+
#[rustc_const_unstable(feature="foo", issue = "none")]
81+
pub const unsafe fn gated_unsafe() -> u32 { 42 }
82+
4883
// @has 'foo/struct.Foo.html' '//div[@id="method.stable_impl"]/code' 'pub const fn stable_impl() -> u32'
4984
// @has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)'
5085
#[stable(feature = "rust1", since = "1.0.0")]
5186
#[rustc_const_stable(feature = "rust1", since = "1.2.0")]
5287
pub const fn stable_impl() -> u32 { 42 }
88+
89+
// @has 'foo/struct.Foo.html' '//div[@id="method.stable_impl_unsafe"]/code' 'pub const unsafe fn stable_impl_unsafe() -> u32'
90+
// @has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)'
91+
#[stable(feature = "rust1", since = "1.0.0")]
92+
#[rustc_const_stable(feature = "rust1", since = "1.2.0")]
93+
pub const unsafe fn stable_impl_unsafe() -> u32 { 42 }
5394
}

0 commit comments

Comments
 (0)