Skip to content

Commit 70aa87b

Browse files
committed
tests: object-safety section in traits
1 parent 7580c67 commit 70aa87b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/rustdoc/sidebar-items.rs

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// @has - '//*[@class="sidebar-elems"]//section//a' 'Output'
1515
// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types'
1616
// @has - '//*[@class="sidebar-elems"]//section//a' 'Extra'
17+
// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety'
1718
pub trait Foo {
1819
const FOO: usize;
1920
const BAR: u32 = 0;
@@ -24,6 +25,12 @@ pub trait Foo {
2425
fn bar() -> Self::Output;
2526
}
2627

28+
// @has foo/trait.Safe.html
29+
// @!has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' ''
30+
pub trait Safe {
31+
fn access(&self);
32+
}
33+
2734
// @has foo/struct.Bar.html
2835
// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields'
2936
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f'

tests/rustdoc/trait-object-safe.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![crate_name = "foo"]
2+
3+
// @has 'foo/trait.Unsafe.html'
4+
// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.'
5+
// @has - '//*[@id="object-safety"]' 'Object Safety'
6+
pub trait Unsafe {
7+
fn foo() -> Self;
8+
}
9+
10+
// @has 'foo/trait.Unsafe2.html'
11+
// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.'
12+
// @has - '//*[@id="object-safety"]' 'Object Safety'
13+
pub trait Unsafe2<T> {
14+
fn foo(i: T);
15+
}
16+
17+
// @has 'foo/trait.Safe.html'
18+
// @!has - '//*[@class="object-safety-info"]' ''
19+
// @!has - '//*[@id="object-safety"]' ''
20+
pub trait Safe {
21+
fn foo(&self);
22+
}
23+
24+
// @has 'foo/struct.Foo.html'
25+
// @!has - '//*[@class="object-safety-info"]' ''
26+
// @!has - '//*[@id="object-safety"]' ''
27+
pub struct Foo;

0 commit comments

Comments
 (0)